sequence
stringlengths
1.19k
35k
code
stringlengths
75
8.58k
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'put_file'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'object_type'}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'object_id'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'width'}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'height'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'mimetype'}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'reproducible'}; {'id': '12', 'type': 'block', 'children': ['13']}, {'id': '13', 'type': 'raise_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'NotImplementedError'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}, {'id': '17', 'type': 'string', 'children': [], 'value': "'put_file() has to be implemented'"}
def put_file(self, file, object_type, object_id, width, height, mimetype, reproducible): raise NotImplementedError('put_file() has to be implemented')
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_original_images'}, {'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', '44', '178']}; {'id': '8', 'type': 'function_definition', 'children': ['9', '10', '12']}, {'id': '9', 'type': 'function_name', 'children': [], 'value': 'test'}; {'id': '10', 'type': 'parameters', 'children': ['11']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '12', 'type': 'block', 'children': ['13', '21', '42']}, {'id': '13', 'type': 'if_statement', 'children': ['14', '18']}; {'id': '14', 'type': 'not_operator', 'children': ['15']}, {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'image'}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'original'}; {'id': '18', 'type': 'block', 'children': ['19']}, {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'False', 'children': []}, {'id': '21', 'type': 'for_statement', 'children': ['22', '25', '30']}; {'id': '22', 'type': 'pattern_list', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'items'}, {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31']}, {'id': '31', 'type': 'if_statement', 'children': ['32', '39']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '38'], 'value': '!='}, {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'getattr'}, {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'image'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}, {'id': '41', 'type': 'False', 'children': []}; {'id': '42', 'type': 'return_statement', 'children': ['43']}, {'id': '43', 'type': 'True', 'children': []}; {'id': '44', 'type': 'if_statement', 'children': ['45', '55', '155']}, {'id': '45', 'type': 'comparison_operator', 'children': ['46', '54'], 'value': 'is'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}, {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'Session'}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'object_session'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}, {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '54', 'type': 'None', 'children': []}, {'id': '55', 'type': 'block', 'children': ['56', '60', '81', '90', '129']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}, {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'images'}, {'id': '59', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '60', 'type': 'for_statement', 'children': ['61', '64', '67']}, {'id': '61', 'type': 'pattern_list', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'image'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '_stored_images'}, {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'if_statement', 'children': ['69', '73']}, {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'test'}, {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'image'}, {'id': '73', 'type': 'block', 'children': ['74']}; {'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': 'images'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'image'}, {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '84', 'type': 'call', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'instance_state'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}, {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '90', 'type': 'try_statement', 'children': ['91', '106', '110']}, {'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': 'added'}, {'id': '95', 'type': 'attribute', 'children': ['96', '105']}; {'id': '96', 'type': 'subscript', 'children': ['97', '100']}, {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'state'}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'committed_state'}; {'id': '100', 'type': 'attribute', 'children': ['101', '104']}, {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'added_items'}; {'id': '106', 'type': 'except_clause', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '108', 'type': 'block', 'children': ['109']}, {'id': '109', 'type': 'pass_statement', 'children': []}; {'id': '110', 'type': 'else_clause', 'children': ['111']}, {'id': '111', 'type': 'block', 'children': ['112']}; {'id': '112', 'type': 'for_statement', 'children': ['113', '114', '115']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'added'}, {'id': '115', 'type': 'block', 'children': ['116']}; {'id': '116', 'type': 'if_statement', 'children': ['117', '121']}, {'id': '117', 'type': 'call', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'test'}, {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'image'}, {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}, {'id': '123', 'type': 'call', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'images'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'image'}, {'id': '129', 'type': 'if_statement', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'session'}, {'id': '133', 'type': 'block', 'children': ['134']}; {'id': '134', 'type': 'for_statement', 'children': ['135', '136', '141']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '136', 'type': 'attribute', 'children': ['137', '140']}, {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'new'}, {'id': '141', 'type': 'block', 'children': ['142']}; {'id': '142', 'type': 'if_statement', 'children': ['143', '147']}, {'id': '143', 'type': 'call', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'test'}, {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'image'}, {'id': '147', 'type': 'block', 'children': ['148']}; {'id': '148', 'type': 'expression_statement', 'children': ['149']}, {'id': '149', 'type': 'call', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'images'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '153', 'type': 'argument_list', 'children': ['154']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'image'}, {'id': '155', 'type': 'else_clause', 'children': ['156']}; {'id': '156', 'type': 'block', 'children': ['157', '170']}, {'id': '157', 'type': 'expression_statement', 'children': ['158']}; {'id': '158', 'type': 'assignment', 'children': ['159', '160']}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '160', 'type': 'call', 'children': ['161', '164']}, {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'filter_by'}; {'id': '164', 'type': 'argument_list', 'children': ['165', '168']}, {'id': '165', 'type': 'keyword_argument', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'original'}, {'id': '167', 'type': 'True', 'children': []}; {'id': '168', 'type': 'dictionary_splat', 'children': ['169']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '170', 'type': 'expression_statement', 'children': ['171']}, {'id': '171', 'type': 'assignment', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'images'}, {'id': '173', 'type': 'call', 'children': ['174', '177']}; {'id': '174', 'type': 'attribute', 'children': ['175', '176']}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'all'}, {'id': '177', 'type': 'argument_list', 'children': []}; {'id': '178', 'type': 'return_statement', 'children': ['179']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'images'}
def _original_images(self, **kwargs): def test(image): if not image.original: return False for filter, value in kwargs.items(): if getattr(image, filter) != value: return False return True if Session.object_session(self.instance) is None: images = [] for image, store in self._stored_images: if test(image): images.append(image) state = instance_state(self.instance) try: added = state.committed_state[self.attr.key].added_items except KeyError: pass else: for image in added: if test(image): images.append(image) if self.session: for image in self.session.new: if test(image): images.append(image) else: query = self.filter_by(original=True, **kwargs) images = query.all() return images
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_file'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'current_store'}, {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'extra_args'}, {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'extra_kwargs'}; {'id': '14', 'type': 'None', 'children': []}, {'id': '15', 'type': 'block', 'children': ['16', '31', '39', '47', '54']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '24']}, {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'isinstance'}, {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'file'}, {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'cgi'}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'FieldStorage'}; {'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': 'file'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'file'}, {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}, {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'io'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'BytesIO'}; {'id': '38', 'type': 'argument_list', 'children': []}, {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}, {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'shutil'}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'copyfileobj'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'data'}, {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}, {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'data'}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'seek'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}, {'id': '53', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'from_raw_file'}, {'id': '59', 'type': 'argument_list', 'children': ['60', '61', '62', '65', '68']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'data'}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'original'}; {'id': '64', 'type': 'True', 'children': []}, {'id': '65', 'type': 'keyword_argument', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'extra_args'}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'extra_args'}; {'id': '68', 'type': 'keyword_argument', 'children': ['69', '70']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'extra_kwargs'}
def from_file(self, file, store=current_store, extra_args=None, extra_kwargs=None): if isinstance(file, cgi.FieldStorage): file = file.file data = io.BytesIO() shutil.copyfileobj(file, data) data.seek(0) return self.from_raw_file(data, store, original=True, extra_args=extra_args, extra_kwargs=extra_kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'copy_modules'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'filespath'}; {'id': '6', 'type': 'None', 'children': []}, {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'modules_path'}, {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '12', 'type': 'None', 'children': []}, {'id': '13', 'type': 'block', 'children': ['14', '16', '113', '125', '143', '156', '173', '217', '229']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}, {'id': '15', 'type': 'string', 'children': [], 'value': "''' Copy over the tree module files into your path '''"}; {'id': '16', 'type': 'if_statement', 'children': ['17', '19']}, {'id': '17', 'type': 'not_operator', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'modules_path'}, {'id': '19', 'type': 'block', 'children': ['20', '29']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}, {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'modulepath'}, {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'getenv'}, {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"MODULEPATH"'}, {'id': '29', 'type': 'if_statement', 'children': ['30', '32', '40']}; {'id': '30', 'type': 'not_operator', 'children': ['31']}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'modulepath'}; {'id': '32', 'type': 'block', 'children': ['33']}, {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'modules_path'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'input'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}, {'id': '39', 'type': 'string', 'children': [], 'value': "'Enter the root path for your module files:'"}; {'id': '40', 'type': 'else_clause', 'children': ['41']}, {'id': '41', 'type': 'block', 'children': ['42', '51']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}, {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'split_mods'}, {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'modulepath'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'split'}, {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'string', 'children': [], 'value': "':'"}, {'id': '51', 'type': 'if_statement', 'children': ['52', '58', '105']}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '57'], 'value': '>'}, {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'split_mods'}, {'id': '57', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '58', 'type': 'block', 'children': ['59', '67']}, {'id': '59', 'type': 'if_statement', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'verbose'}, {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}, {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'print'}, {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'string', 'children': [], 'value': "'Multiple module paths found. Finding all that contain a tree directory.'"}, {'id': '67', 'type': 'for_statement', 'children': ['68', '69', '70']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'mfile'}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'split_mods'}; {'id': '70', 'type': 'block', 'children': ['71']}, {'id': '71', 'type': 'if_statement', 'children': ['72', '88', '102']}; {'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': 'exists'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}, {'id': '79', 'type': 'call', 'children': ['80', '85']}; {'id': '80', 'type': 'attribute', 'children': ['81', '84']}, {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '85', 'type': 'argument_list', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'mfile'}, {'id': '87', 'type': 'string', 'children': [], 'value': "'tree'"}; {'id': '88', 'type': 'block', 'children': ['89']}, {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '92']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'copy_modules'}; {'id': '92', 'type': 'argument_list', 'children': ['93', '96', '99']}, {'id': '93', 'type': 'keyword_argument', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'filespath'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'filespath'}; {'id': '96', 'type': 'keyword_argument', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'modules_path'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'mfile'}, {'id': '99', 'type': 'keyword_argument', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'verbose'}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '102', 'type': 'else_clause', 'children': ['103']}, {'id': '103', 'type': 'block', 'children': ['104']}; {'id': '104', 'type': 'return_statement', 'children': []}, {'id': '105', 'type': 'else_clause', 'children': ['106']}; {'id': '106', 'type': 'block', 'children': ['107']}, {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'modules_path'}; {'id': '110', 'type': 'subscript', 'children': ['111', '112']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'split_mods'}; {'id': '112', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'assignment', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'tree_mod'}; {'id': '116', 'type': 'call', 'children': ['117', '122']}, {'id': '117', 'type': 'attribute', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '122', 'type': 'argument_list', 'children': ['123', '124']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'modules_path'}; {'id': '124', 'type': 'string', 'children': [], 'value': "'tree'"}, {'id': '125', 'type': 'if_statement', 'children': ['126', '135']}; {'id': '126', 'type': 'not_operator', 'children': ['127']}, {'id': '127', 'type': 'call', 'children': ['128', '133']}; {'id': '128', 'type': 'attribute', 'children': ['129', '132']}, {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'isdir'}, {'id': '133', 'type': 'argument_list', 'children': ['134']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'tree_mod'}, {'id': '135', 'type': 'block', 'children': ['136']}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}, {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'makedirs'}, {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'tree_mod'}, {'id': '143', 'type': 'if_statement', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'verbose'}, {'id': '145', 'type': 'block', 'children': ['146']}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}, {'id': '147', 'type': 'call', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'print'}, {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'call', 'children': ['151', '154']}, {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'string', 'children': [], 'value': "'Copying modules from etc/ into {0}'"}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '154', 'type': 'argument_list', 'children': ['155']}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'tree_mod'}; {'id': '156', 'type': 'expression_statement', 'children': ['157']}, {'id': '157', 'type': 'assignment', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'module_files'}, {'id': '159', 'type': 'call', 'children': ['160', '163']}; {'id': '160', 'type': 'attribute', 'children': ['161', '162']}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'glob'}, {'id': '163', 'type': 'argument_list', 'children': ['164']}; {'id': '164', 'type': 'call', 'children': ['165', '170']}, {'id': '165', 'type': 'attribute', 'children': ['166', '169']}; {'id': '166', 'type': 'attribute', 'children': ['167', '168']}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '170', 'type': 'argument_list', 'children': ['171', '172']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'filespath'}; {'id': '172', 'type': 'string', 'children': [], 'value': "'*.module'"}, {'id': '173', 'type': 'for_statement', 'children': ['174', '175', '176']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'mfile'}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'module_files'}; {'id': '176', 'type': 'block', 'children': ['177', '197', '209']}, {'id': '177', 'type': 'expression_statement', 'children': ['178']}; {'id': '178', 'type': 'assignment', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '180', 'type': 'subscript', 'children': ['181', '196']}, {'id': '181', 'type': 'call', 'children': ['182', '187']}; {'id': '182', 'type': 'attribute', 'children': ['183', '186']}, {'id': '183', 'type': 'attribute', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'splitext'}, {'id': '187', 'type': 'argument_list', 'children': ['188']}; {'id': '188', 'type': 'call', 'children': ['189', '194']}, {'id': '189', 'type': 'attribute', 'children': ['190', '193']}; {'id': '190', 'type': 'attribute', 'children': ['191', '192']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '194', 'type': 'argument_list', 'children': ['195']}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'mfile'}; {'id': '196', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '197', 'type': 'expression_statement', 'children': ['198']}; {'id': '198', 'type': 'assignment', 'children': ['199', '200']}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'tree_out'}; {'id': '200', 'type': 'call', 'children': ['201', '206']}, {'id': '201', 'type': 'attribute', 'children': ['202', '205']}; {'id': '202', 'type': 'attribute', 'children': ['203', '204']}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '206', 'type': 'argument_list', 'children': ['207', '208']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'tree_mod'}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'base'}, {'id': '209', 'type': 'expression_statement', 'children': ['210']}; {'id': '210', 'type': 'call', 'children': ['211', '214']}, {'id': '211', 'type': 'attribute', 'children': ['212', '213']}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'shutil'}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'copy2'}; {'id': '214', 'type': 'argument_list', 'children': ['215', '216']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'mfile'}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'tree_out'}, {'id': '217', 'type': 'expression_statement', 'children': ['218']}; {'id': '218', 'type': 'assignment', 'children': ['219', '220']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '220', 'type': 'call', 'children': ['221', '226']}, {'id': '221', 'type': 'attribute', 'children': ['222', '225']}; {'id': '222', 'type': 'attribute', 'children': ['223', '224']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '226', 'type': 'argument_list', 'children': ['227', '228']}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'filespath'}; {'id': '228', 'type': 'string', 'children': [], 'value': "'.version'"}, {'id': '229', 'type': 'if_statement', 'children': ['230', '238']}; {'id': '230', 'type': 'call', 'children': ['231', '236']}, {'id': '231', 'type': 'attribute', 'children': ['232', '235']}; {'id': '232', 'type': 'attribute', 'children': ['233', '234']}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '235', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '236', 'type': 'argument_list', 'children': ['237']}, {'id': '237', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '238', 'type': 'block', 'children': ['239']}, {'id': '239', 'type': 'expression_statement', 'children': ['240']}; {'id': '240', 'type': 'call', 'children': ['241', '244']}, {'id': '241', 'type': 'attribute', 'children': ['242', '243']}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'shutil'}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'copy2'}; {'id': '244', 'type': 'argument_list', 'children': ['245', '246']}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'version'}
def copy_modules(filespath=None, modules_path=None, verbose=None): ''' Copy over the tree module files into your path ''' if not modules_path: modulepath = os.getenv("MODULEPATH") if not modulepath: modules_path = input('Enter the root path for your module files:') else: split_mods = modulepath.split(':') if len(split_mods) > 1: if verbose: print('Multiple module paths found. Finding all that contain a tree directory.') for mfile in split_mods: if os.path.exists(os.path.join(mfile, 'tree')): copy_modules(filespath=filespath, modules_path=mfile, verbose=verbose) else: return else: modules_path = split_mods[0] tree_mod = os.path.join(modules_path, 'tree') if not os.path.isdir(tree_mod): os.makedirs(tree_mod) if verbose: print('Copying modules from etc/ into {0}'.format(tree_mod)) module_files = glob.glob(os.path.join(filespath, '*.module')) for mfile in module_files: base = os.path.splitext(os.path.basename(mfile))[0] tree_out = os.path.join(tree_mod, base) shutil.copy2(mfile, tree_out) version = os.path.join(filespath, '.version') if os.path.isfile(version): shutil.copy2(version, tree_mod)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_repr_html_'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'indices'}, {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'iops'}; {'id': '10', 'type': 'None', 'children': []}, {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'lx'}, {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'li'}; {'id': '16', 'type': 'None', 'children': []}, {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'lls'}, {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21', '27', '33', '47', '86', '111', '146', '150', '157', '164', '178', '206', '232', '243', '302']}, {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'filter_'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_current_slice_'}, {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'flat'}, {'id': '33', 'type': 'if_statement', 'children': ['34', '37']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '36'], 'value': 'is'}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'indices'}; {'id': '36', 'type': 'None', 'children': []}, {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}, {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'indices'}, {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_indices'}, {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'filter_'}, {'id': '47', 'type': 'if_statement', 'children': ['48', '51']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': 'is'}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'iops'}; {'id': '50', 'type': 'None', 'children': []}, {'id': '51', 'type': 'block', 'children': ['52', '61']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}, {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'ravi'}, {'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': '_raveled_index'}, {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'filter_'}, {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'iops'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '66', 'type': 'generator_expression', 'children': ['67', '75']}, {'id': '67', 'type': 'list', 'children': ['68', '69'], 'value': '[name, iop.properties_for(ravi)]'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'iop'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'properties_for'}, {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'ravi'}, {'id': '75', 'type': 'for_in_clause', 'children': ['76', '79']}; {'id': '76', 'type': 'pattern_list', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'iop'}, {'id': '79', 'type': 'call', 'children': ['80', '85']}; {'id': '80', 'type': 'attribute', 'children': ['81', '84']}, {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': '_index_operations'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'items'}, {'id': '85', 'type': 'argument_list', 'children': []}; {'id': '86', 'type': 'if_statement', 'children': ['87', '90']}, {'id': '87', 'type': 'comparison_operator', 'children': ['88', '89'], 'value': 'is'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'lls'}, {'id': '89', 'type': 'None', 'children': []}; {'id': '90', 'type': 'block', 'children': ['91']}, {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'lls'}; {'id': '94', 'type': 'list_comprehension', 'children': ['95', '102']}, {'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': '_max_len_names'}, {'id': '99', 'type': 'argument_list', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'iop'}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '102', 'type': 'for_in_clause', 'children': ['103', '106']}, {'id': '103', 'type': 'pattern_list', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'iop'}; {'id': '106', 'type': 'call', 'children': ['107', '110']}, {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'iops'}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '110', 'type': 'argument_list', 'children': []}, {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'assignment', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'header_format'}; {'id': '114', 'type': 'assignment', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '116', 'type': 'call', 'children': ['117', '120']}, {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'header_format'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '120', 'type': 'argument_list', 'children': ['121', '128', '131']}, {'id': '121', 'type': 'keyword_argument', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '123', 'type': 'call', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'hierarchy_name'}, {'id': '127', 'type': 'argument_list', 'children': []}; {'id': '128', 'type': 'keyword_argument', 'children': ['129', '130']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': '__index_name__'}, {'id': '131', 'type': 'keyword_argument', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'iops'}, {'id': '133', 'type': 'call', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}, {'id': '135', 'type': 'string', 'children': [], 'value': '"</b></th><th><b>"'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '140']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}, {'id': '141', 'type': 'call', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'iops'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'keys'}, {'id': '145', 'type': 'argument_list', 'children': []}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}, {'id': '147', 'type': 'assignment', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'to_print'}, {'id': '149', 'type': 'list', 'children': [], 'value': '[\n]'}; {'id': '150', 'type': 'expression_statement', 'children': ['151']}, {'id': '151', 'type': 'call', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'to_print'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '155', 'type': 'argument_list', 'children': ['156']}; {'id': '156', 'type': 'string', 'children': [], 'value': '\'<table class="tg">\''}, {'id': '157', 'type': 'expression_statement', 'children': ['158']}; {'id': '158', 'type': 'call', 'children': ['159', '162']}, {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'to_print'}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '162', 'type': 'argument_list', 'children': ['163']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '164', 'type': 'expression_statement', 'children': ['165']}, {'id': '165', 'type': 'assignment', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'format_spec'}, {'id': '167', 'type': 'call', 'children': ['168', '171']}; {'id': '168', 'type': 'attribute', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': '_format_spec'}, {'id': '171', 'type': 'argument_list', 'children': ['172', '173', '174', '175', '176', '177']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'indices'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'iops'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'lx'}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'li'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'lls'}, {'id': '177', 'type': 'False', 'children': []}; {'id': '178', 'type': 'expression_statement', 'children': ['179']}, {'id': '179', 'type': 'assignment', 'children': ['180', '185']}; {'id': '180', 'type': 'subscript', 'children': ['181', '182']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'format_spec'}; {'id': '182', 'type': 'slice', 'children': ['183', '184']}, {'id': '183', 'type': 'colon', 'children': []}; {'id': '184', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '185', 'type': 'list', 'children': ['186', '196'], 'value': '["<tr><td class=tg-left>{i}</td>".format(i=format_spec[0]), "<td class=tg-right>{i}</td>".format(i=format_spec[1])]'}; {'id': '186', 'type': 'call', 'children': ['187', '190']}, {'id': '187', 'type': 'attribute', 'children': ['188', '189']}; {'id': '188', 'type': 'string', 'children': [], 'value': '"<tr><td class=tg-left>{i}</td>"'}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '190', 'type': 'argument_list', 'children': ['191']}, {'id': '191', 'type': 'keyword_argument', 'children': ['192', '193']}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '193', 'type': 'subscript', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'format_spec'}, {'id': '195', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '196', 'type': 'call', 'children': ['197', '200']}, {'id': '197', 'type': 'attribute', 'children': ['198', '199']}; {'id': '198', 'type': 'string', 'children': [], 'value': '"<td class=tg-right>{i}</td>"'}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '200', 'type': 'argument_list', 'children': ['201']}, {'id': '201', 'type': 'keyword_argument', 'children': ['202', '203']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '203', 'type': 'subscript', 'children': ['204', '205']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'format_spec'}, {'id': '205', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '206', 'type': 'for_statement', 'children': ['207', '208', '216']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '208', 'type': 'call', 'children': ['209', '210']}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '210', 'type': 'argument_list', 'children': ['211', '212']}, {'id': '211', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '212', 'type': 'call', 'children': ['213', '214']}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '214', 'type': 'argument_list', 'children': ['215']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'format_spec'}; {'id': '216', 'type': 'block', 'children': ['217']}, {'id': '217', 'type': 'expression_statement', 'children': ['218']}; {'id': '218', 'type': 'assignment', 'children': ['219', '222']}, {'id': '219', 'type': 'subscript', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'format_spec'}, {'id': '221', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '222', 'type': 'call', 'children': ['223', '226']}, {'id': '223', 'type': 'attribute', 'children': ['224', '225']}; {'id': '224', 'type': 'string', 'children': [], 'value': "'<td class=tg-left>{c}</td>'"}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '226', 'type': 'argument_list', 'children': ['227']}, {'id': '227', 'type': 'keyword_argument', 'children': ['228', '229']}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'c'}, {'id': '229', 'type': 'subscript', 'children': ['230', '231']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'format_spec'}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '232', 'type': 'expression_statement', 'children': ['233']}, {'id': '233', 'type': 'assignment', 'children': ['234', '235']}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'format_spec'}, {'id': '235', 'type': 'binary_operator', 'children': ['236', '242'], 'value': '+'}; {'id': '236', 'type': 'call', 'children': ['237', '240']}, {'id': '237', 'type': 'attribute', 'children': ['238', '239']}; {'id': '238', 'type': 'string', 'children': [], 'value': '""'}, {'id': '239', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '240', 'type': 'argument_list', 'children': ['241']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'format_spec'}; {'id': '242', 'type': 'string', 'children': [], 'value': "'</tr>'"}, {'id': '243', 'type': 'for_statement', 'children': ['244', '245', '251']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '245', 'type': 'call', 'children': ['246', '247']}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'range'}, {'id': '247', 'type': 'argument_list', 'children': ['248']}; {'id': '248', 'type': 'attribute', 'children': ['249', '250']}, {'id': '249', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'size'}, {'id': '251', 'type': 'block', 'children': ['252']}; {'id': '252', 'type': 'expression_statement', 'children': ['253']}, {'id': '253', 'type': 'call', 'children': ['254', '257']}; {'id': '254', 'type': 'attribute', 'children': ['255', '256']}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'to_print'}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '257', 'type': 'argument_list', 'children': ['258']}; {'id': '258', 'type': 'call', 'children': ['259', '262']}, {'id': '259', 'type': 'attribute', 'children': ['260', '261']}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'format_spec'}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '262', 'type': 'argument_list', 'children': ['263', '268', '279']}, {'id': '263', 'type': 'keyword_argument', 'children': ['264', '265']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'index'}, {'id': '265', 'type': 'subscript', 'children': ['266', '267']}; {'id': '266', 'type': 'identifier', 'children': [], 'value': 'indices'}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '268', 'type': 'keyword_argument', 'children': ['269', '270']}, {'id': '269', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '270', 'type': 'call', 'children': ['271', '274']}, {'id': '271', 'type': 'attribute', 'children': ['272', '273']}; {'id': '272', 'type': 'string', 'children': [], 'value': '"{1:.{0}f}"'}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '274', 'type': 'argument_list', 'children': ['275', '276']}, {'id': '275', 'type': 'identifier', 'children': [], 'value': '__precision__'}; {'id': '276', 'type': 'subscript', 'children': ['277', '278']}, {'id': '277', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '279', 'type': 'dictionary_splat', 'children': ['280']}; {'id': '280', 'type': 'call', 'children': ['281', '282']}, {'id': '281', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '282', 'type': 'generator_expression', 'children': ['283', '299']}, {'id': '283', 'type': 'tuple', 'children': ['284', '285']}; {'id': '284', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '285', 'type': 'call', 'children': ['286', '289']}; {'id': '286', 'type': 'attribute', 'children': ['287', '288']}, {'id': '287', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '289', 'type': 'argument_list', 'children': ['290']}; {'id': '290', 'type': 'call', 'children': ['291', '292']}, {'id': '291', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '292', 'type': 'argument_list', 'children': ['293', '294']}, {'id': '293', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '294', 'type': 'subscript', 'children': ['295', '298']}, {'id': '295', 'type': 'subscript', 'children': ['296', '297']}; {'id': '296', 'type': 'identifier', 'children': [], 'value': 'iops'}, {'id': '297', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '298', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '299', 'type': 'for_in_clause', 'children': ['300', '301']}; {'id': '300', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '301', 'type': 'identifier', 'children': [], 'value': 'iops'}; {'id': '302', 'type': 'return_statement', 'children': ['303']}, {'id': '303', 'type': 'call', 'children': ['304', '307']}; {'id': '304', 'type': 'attribute', 'children': ['305', '306']}, {'id': '305', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '306', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '307', 'type': 'argument_list', 'children': ['308']}
def _repr_html_(self, indices=None, iops=None, lx=None, li=None, lls=None): filter_ = self._current_slice_ vals = self.flat if indices is None: indices = self._indices(filter_) if iops is None: ravi = self._raveled_index(filter_) iops = OrderedDict([name, iop.properties_for(ravi)] for name, iop in self._index_operations.items()) if lls is None: lls = [self._max_len_names(iop, name) for name, iop in iops.items()] header_format = header = header_format.format(x=self.hierarchy_name(), i=__index_name__, iops="</b></th><th><b>".join(list(iops.keys()))) to_print = [ ] to_print.append('<table class="tg">') to_print.append(header) format_spec = self._format_spec(indices, iops, lx, li, lls, False) format_spec[:2] = ["<tr><td class=tg-left>{i}</td>".format(i=format_spec[0]), "<td class=tg-right>{i}</td>".format(i=format_spec[1])] for i in range(2, len(format_spec)): format_spec[i] = '<td class=tg-left>{c}</td>'.format(c=format_spec[i]) format_spec = "".join(format_spec) + '</tr>' for i in range(self.size): to_print.append(format_spec.format(index=indices[i], value="{1:.{0}f}".format(__precision__, vals[i]), **dict((name, ' '.join(map(str, iops[name][i]))) for name in iops))) return '\n'.join(to_print)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'optimize_restarts'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'num_restarts'}, {'id': '7', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'robust'}; {'id': '10', 'type': 'False', 'children': []}, {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'verbose'}, {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'parallel'}; {'id': '16', 'type': 'False', 'children': []}, {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'num_processes'}, {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'dictionary_splat_pattern', 'children': ['21']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '22', 'type': 'block', 'children': ['23', '32', '42', '138', '235', '288']}, {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'initial_length'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}, {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'optimization_runs'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}, {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'initial_parameters'}, {'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': 'optimizer_array'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'copy'}, {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'if_statement', 'children': ['43', '44']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'parallel'}; {'id': '44', 'type': 'block', 'children': ['45']}, {'id': '45', 'type': 'try_statement', 'children': ['46', '118']}; {'id': '46', 'type': 'block', 'children': ['47', '58', '73', '90', '106', '112']}, {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'pool'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}, {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'mp'}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'Pool'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}, {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'processes'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'num_processes'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}, {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'obs'}, {'id': '61', 'type': 'list_comprehension', 'children': ['62', '67']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}, {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '66', 'type': 'argument_list', 'children': []}, {'id': '67', 'type': 'for_in_clause', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'range'}, {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'num_restarts'}, {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'list_comprehension', 'children': ['75', '82']}, {'id': '75', 'type': 'call', 'children': ['76', '81']}; {'id': '76', 'type': 'attribute', 'children': ['77', '80']}, {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'obs'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'randomize'}, {'id': '81', 'type': 'argument_list', 'children': []}; {'id': '82', 'type': 'for_in_clause', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '84', 'type': 'call', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}, {'id': '87', 'type': 'binary_operator', 'children': ['88', '89'], 'value': '-'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'num_restarts'}, {'id': '89', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}, {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'jobs'}, {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'pool'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'map'}, {'id': '97', 'type': 'argument_list', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'opt_wrapper'}, {'id': '99', 'type': 'list_comprehension', 'children': ['100', '103']}; {'id': '100', 'type': 'tuple', 'children': ['101', '102']}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'kwargs'}, {'id': '103', 'type': 'for_in_clause', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'o'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'obs'}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}, {'id': '107', 'type': 'call', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'pool'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'close'}, {'id': '111', 'type': 'argument_list', 'children': []}; {'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': 'pool'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '117', 'type': 'argument_list', 'children': []}; {'id': '118', 'type': 'except_clause', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'KeyboardInterrupt'}; {'id': '120', 'type': 'block', 'children': ['121', '126', '132']}, {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'call', 'children': ['123', '124']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}, {'id': '125', 'type': 'string', 'children': [], 'value': '"Ctrl+c received, terminating and joining pool."'}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}, {'id': '127', 'type': 'call', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'pool'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'terminate'}, {'id': '131', 'type': 'argument_list', 'children': []}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}, {'id': '133', 'type': 'call', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'pool'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '137', 'type': 'argument_list', 'children': []}; {'id': '138', 'type': 'for_statement', 'children': ['139', '140', '144']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '140', 'type': 'call', 'children': ['141', '142']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'num_restarts'}; {'id': '144', 'type': 'block', 'children': ['145']}, {'id': '145', 'type': 'try_statement', 'children': ['146', '208']}; {'id': '146', 'type': 'block', 'children': ['147', '183']}, {'id': '147', 'type': 'if_statement', 'children': ['148', '150', '170']}; {'id': '148', 'type': 'not_operator', 'children': ['149']}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'parallel'}; {'id': '150', 'type': 'block', 'children': ['151', '162']}, {'id': '151', 'type': 'if_statement', 'children': ['152', '155']}; {'id': '152', 'type': 'comparison_operator', 'children': ['153', '154'], 'value': '>'}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '154', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '155', 'type': 'block', 'children': ['156']}; {'id': '156', 'type': 'expression_statement', 'children': ['157']}, {'id': '157', 'type': 'call', 'children': ['158', '161']}; {'id': '158', 'type': 'attribute', 'children': ['159', '160']}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'randomize'}, {'id': '161', 'type': 'argument_list', 'children': []}; {'id': '162', 'type': 'expression_statement', 'children': ['163']}, {'id': '163', 'type': 'call', 'children': ['164', '167']}; {'id': '164', 'type': 'attribute', 'children': ['165', '166']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'optimize'}, {'id': '167', 'type': 'argument_list', 'children': ['168']}; {'id': '168', 'type': 'dictionary_splat', 'children': ['169']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '170', 'type': 'else_clause', 'children': ['171']}, {'id': '171', 'type': 'block', 'children': ['172']}; {'id': '172', 'type': 'expression_statement', 'children': ['173']}, {'id': '173', 'type': 'call', 'children': ['174', '179']}; {'id': '174', 'type': 'attribute', 'children': ['175', '178']}, {'id': '175', 'type': 'attribute', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'optimization_runs'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '179', 'type': 'argument_list', 'children': ['180']}; {'id': '180', 'type': 'subscript', 'children': ['181', '182']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'jobs'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '183', 'type': 'if_statement', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'verbose'}, {'id': '185', 'type': 'block', 'children': ['186']}; {'id': '186', 'type': 'expression_statement', 'children': ['187']}, {'id': '187', 'type': 'call', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'print'}, {'id': '189', 'type': 'argument_list', 'children': ['190']}; {'id': '190', 'type': 'parenthesized_expression', 'children': ['191']}, {'id': '191', 'type': 'call', 'children': ['192', '195']}; {'id': '192', 'type': 'attribute', 'children': ['193', '194']}, {'id': '193', 'type': 'string', 'children': [], 'value': '"Optimization restart {0}/{1}, f = {2}"'}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'format'}, {'id': '195', 'type': 'argument_list', 'children': ['196', '199', '200']}; {'id': '196', 'type': 'binary_operator', 'children': ['197', '198'], 'value': '+'}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '198', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'num_restarts'}; {'id': '200', 'type': 'attribute', 'children': ['201', '207']}, {'id': '201', 'type': 'subscript', 'children': ['202', '205']}; {'id': '202', 'type': 'attribute', 'children': ['203', '204']}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'optimization_runs'}, {'id': '205', 'type': 'unary_operator', 'children': ['206'], 'value': '-'}; {'id': '206', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'f_opt'}; {'id': '208', 'type': 'except_clause', 'children': ['209', '213']}, {'id': '209', 'type': 'as_pattern', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'Exception'}, {'id': '211', 'type': 'as_pattern_target', 'children': ['212']}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'e'}, {'id': '213', 'type': 'block', 'children': ['214']}; {'id': '214', 'type': 'if_statement', 'children': ['215', '216', '231']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'robust'}; {'id': '216', 'type': 'block', 'children': ['217']}, {'id': '217', 'type': 'expression_statement', 'children': ['218']}; {'id': '218', 'type': 'call', 'children': ['219', '220']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '220', 'type': 'argument_list', 'children': ['221']}, {'id': '221', 'type': 'parenthesized_expression', 'children': ['222']}; {'id': '222', 'type': 'call', 'children': ['223', '226']}, {'id': '223', 'type': 'attribute', 'children': ['224', '225']}; {'id': '224', 'type': 'string', 'children': [], 'value': '"Warning - optimization restart {0}/{1} failed"'}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '226', 'type': 'argument_list', 'children': ['227', '230']}, {'id': '227', 'type': 'binary_operator', 'children': ['228', '229'], 'value': '+'}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '229', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'num_restarts'}, {'id': '231', 'type': 'else_clause', 'children': ['232']}; {'id': '232', 'type': 'block', 'children': ['233']}, {'id': '233', 'type': 'raise_statement', 'children': ['234']}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'e'}, {'id': '235', 'type': 'if_statement', 'children': ['236', '244', '280']}; {'id': '236', 'type': 'comparison_operator', 'children': ['237', '243'], 'value': '>'}, {'id': '237', 'type': 'call', 'children': ['238', '239']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '239', 'type': 'argument_list', 'children': ['240']}; {'id': '240', 'type': 'attribute', 'children': ['241', '242']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'optimization_runs'}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'initial_length'}; {'id': '244', 'type': 'block', 'children': ['245', '266']}, {'id': '245', 'type': 'expression_statement', 'children': ['246']}; {'id': '246', 'type': 'assignment', 'children': ['247', '248']}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '248', 'type': 'call', 'children': ['249', '252']}, {'id': '249', 'type': 'attribute', 'children': ['250', '251']}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '251', 'type': 'identifier', 'children': [], 'value': 'argmin'}; {'id': '252', 'type': 'argument_list', 'children': ['253']}, {'id': '253', 'type': 'list_comprehension', 'children': ['254', '257']}; {'id': '254', 'type': 'attribute', 'children': ['255', '256']}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'f_opt'}, {'id': '257', 'type': 'for_in_clause', 'children': ['258', '259']}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'o'}, {'id': '259', 'type': 'subscript', 'children': ['260', '263']}; {'id': '260', 'type': 'attribute', 'children': ['261', '262']}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '262', 'type': 'identifier', 'children': [], 'value': 'optimization_runs'}, {'id': '263', 'type': 'slice', 'children': ['264', '265']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'initial_length'}, {'id': '265', 'type': 'colon', 'children': []}; {'id': '266', 'type': 'expression_statement', 'children': ['267']}, {'id': '267', 'type': 'assignment', 'children': ['268', '271']}; {'id': '268', 'type': 'attribute', 'children': ['269', '270']}, {'id': '269', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'optimizer_array'}, {'id': '271', 'type': 'attribute', 'children': ['272', '279']}; {'id': '272', 'type': 'subscript', 'children': ['273', '276']}, {'id': '273', 'type': 'attribute', 'children': ['274', '275']}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 'optimization_runs'}; {'id': '276', 'type': 'binary_operator', 'children': ['277', '278'], 'value': '+'}, {'id': '277', 'type': 'identifier', 'children': [], 'value': 'initial_length'}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '279', 'type': 'identifier', 'children': [], 'value': 'x_opt'}; {'id': '280', 'type': 'else_clause', 'children': ['281']}, {'id': '281', 'type': 'block', 'children': ['282']}; {'id': '282', 'type': 'expression_statement', 'children': ['283']}, {'id': '283', 'type': 'assignment', 'children': ['284', '287']}; {'id': '284', 'type': 'attribute', 'children': ['285', '286']}, {'id': '285', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '286', 'type': 'identifier', 'children': [], 'value': 'optimizer_array'}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'initial_parameters'}; {'id': '288', 'type': 'return_statement', 'children': ['289']}, {'id': '289', 'type': 'attribute', 'children': ['290', '291']}; {'id': '290', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '291', 'type': 'identifier', 'children': [], 'value': 'optimization_runs'}
def optimize_restarts(self, num_restarts=10, robust=False, verbose=True, parallel=False, num_processes=None, **kwargs): initial_length = len(self.optimization_runs) initial_parameters = self.optimizer_array.copy() if parallel: try: pool = mp.Pool(processes=num_processes) obs = [self.copy() for i in range(num_restarts)] [obs[i].randomize() for i in range(num_restarts-1)] jobs = pool.map(opt_wrapper, [(o,kwargs) for o in obs]) pool.close() pool.join() except KeyboardInterrupt: print("Ctrl+c received, terminating and joining pool.") pool.terminate() pool.join() for i in range(num_restarts): try: if not parallel: if i > 0: self.randomize() self.optimize(**kwargs) else: self.optimization_runs.append(jobs[i]) if verbose: print(("Optimization restart {0}/{1}, f = {2}".format(i + 1, num_restarts, self.optimization_runs[-1].f_opt))) except Exception as e: if robust: print(("Warning - optimization restart {0}/{1} failed".format(i + 1, num_restarts))) else: raise e if len(self.optimization_runs) > initial_length: i = np.argmin([o.f_opt for o in self.optimization_runs[initial_length:]]) self.optimizer_array = self.optimization_runs[initial_length + i].x_opt else: self.optimizer_array = initial_parameters return self.optimization_runs
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'optimizer_array'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6', '42', '102', '123']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '28']}, {'id': '7', 'type': 'boolean_operator', 'children': ['8', '19'], 'value': 'or'}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '18'], 'value': 'is'}, {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}, {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '13', 'type': 'identifier', 'children': [], 'value': '__dict__'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get'}, {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'_optimizer_copy_'"}, {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'None', 'children': []}, {'id': '19', 'type': 'comparison_operator', 'children': ['20', '23'], 'value': '!='}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'size'}, {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_optimizer_copy_'}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '28', 'type': 'block', 'children': ['29']}, {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '34']}, {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': '_optimizer_copy_'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}, {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'empty'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}, {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '47']}, {'id': '43', 'type': 'not_operator', 'children': ['44']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_optimizer_copy_transformed'}, {'id': '47', 'type': 'block', 'children': ['48', '60', '96']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}, {'id': '49', 'type': 'assignment', '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': '_optimizer_copy_'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'flat'}, {'id': '55', 'type': 'attribute', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'param_array'}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'flat'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}, {'id': '61', 'type': 'list_comprehension', 'children': ['62', '81', '92']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}, {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'put'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '70', '71']}, {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '69', 'type': 'identifier', 'children': [], 'value': '_optimizer_copy_'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'ind'}, {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'finv'}, {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'subscript', 'children': ['77', '80']}, {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'param_array'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'ind'}, {'id': '81', 'type': 'for_in_clause', 'children': ['82', '85']}; {'id': '82', 'type': 'pattern_list', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'ind'}, {'id': '85', 'type': 'call', 'children': ['86', '91']}; {'id': '86', 'type': 'attribute', 'children': ['87', '90']}, {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'constraints'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'items'}, {'id': '91', 'type': 'argument_list', 'children': []}; {'id': '92', 'type': 'if_clause', 'children': ['93']}, {'id': '93', 'type': 'comparison_operator', 'children': ['94', '95'], 'value': '!='}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'c'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': '__fixed__'}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}, {'id': '97', 'type': 'assignment', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': '_optimizer_copy_transformed'}, {'id': '101', 'type': 'True', 'children': []}; {'id': '102', 'type': 'if_statement', 'children': ['103', '108']}, {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': '_has_fixes'}, {'id': '107', 'type': 'argument_list', 'children': []}; {'id': '108', 'type': 'block', 'children': ['109', '115']}, {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}, {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': '_ensure_fixes'}; {'id': '114', 'type': 'argument_list', 'children': []}, {'id': '115', 'type': 'return_statement', 'children': ['116']}; {'id': '116', 'type': 'subscript', 'children': ['117', '120']}, {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': '_optimizer_copy_'}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': '_fixes_'}, {'id': '123', 'type': 'return_statement', 'children': ['124']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}
def optimizer_array(self): if self.__dict__.get('_optimizer_copy_', None) is None or self.size != self._optimizer_copy_.size: self._optimizer_copy_ = np.empty(self.size) if not self._optimizer_copy_transformed: self._optimizer_copy_.flat = self.param_array.flat [np.put(self._optimizer_copy_, ind, c.finv(self.param_array[ind])) for c, ind in self.constraints.items() if c != __fixed__] self._optimizer_copy_transformed = True if self._has_fixes(): self._ensure_fixes() return self._optimizer_copy_[self._fixes_] return self._optimizer_copy_
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'ERROR', 'children': ['2', '281']}; {'id': '2', 'type': 'function_definition', 'children': ['3', '4', '6']}, {'id': '3', 'type': 'function_name', 'children': [], 'value': '_parse_content'}; {'id': '4', 'type': 'parameters', 'children': ['5']}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '18', '104', '159', '170', '181', '191', '249', '256', '262', '268']}, {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'iter'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}, {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'deps'}, {'id': '17', 'type': 'dictionary', 'children': []}; {'id': '18', 'type': 'for_statement', 'children': ['19', '20', '21', '92']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'content'}, {'id': '21', 'type': 'ERROR', 'children': ['22', '28', '57', '60', '63', '69', '72', '75', '76', '77', '82', '89', '90']}; {'id': '22', 'type': 'if_statement', 'children': ['23', '26']}, {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': 'not'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'fades'"}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '26', 'type': 'block', 'children': ['27']}, {'id': '27', 'type': 'continue_statement', 'children': []}; {'id': '28', 'type': 'if_statement', 'children': ['29', '45', '55']}, {'id': '29', 'type': 'ERROR', 'children': ['30', '31', '32', '37', '38', '44']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'continue'}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}, {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '36', 'type': 'argument_list', 'children': []}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'index_of_last_fades'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}, {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'rfind'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}, {'id': '43', 'type': 'string', 'children': [], 'value': "'fades'"}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'index_of_first_hash'}, {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'index'}, {'id': '49', 'type': 'argument_list', 'children': ['50', '52']}; {'id': '50', 'type': 'ERROR', 'children': ['51']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'if'}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '54'], 'value': '>'}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'index_of_first_hash'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'index_of_last_fades'}, {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'continue_statement', 'children': []}, {'id': '57', 'type': 'pattern_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'import_part'}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'fades_part'}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'rsplit'}, {'id': '63', 'type': 'comparison_operator', 'children': ['64', '65', '68'], 'value': 'in'}; {'id': '64', 'type': 'string', 'children': [], 'value': '"\n if "'}, {'id': '65', 'type': 'ERROR', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'fades'}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'not'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'fades_part'}, {'id': '69', 'type': 'pattern_list', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'import_part'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'fades_part'}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'import_part'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'rsplit'}, {'id': '75', 'type': 'ERROR', 'children': []}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'fades_part'}, {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'fades_part'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'strip'}, {'id': '81', 'type': 'argument_list', 'children': []}; {'id': '82', 'type': 'not_operator', 'children': ['83']}, {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'fades_part'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'startswith'}, {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'string', 'children': [], 'value': '"fades"'}, {'id': '89', 'type': 'ERROR', 'children': []}; {'id': '90', 'type': 'not_operator', 'children': ['91']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'import_part'}; {'id': '92', 'type': 'block', 'children': ['93']}, {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'import_part'}; {'id': '96', 'type': 'call', 'children': ['97', '103']}, {'id': '97', 'type': 'attribute', 'children': ['98', '102']}; {'id': '98', 'type': 'call', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'next'}; {'id': '100', 'type': 'argument_list', 'children': ['101']}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'strip'}, {'id': '103', 'type': 'argument_list', 'children': []}; {'id': '104', 'type': 'if_statement', 'children': ['105', '108', '122', '129', '148']}, {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'import_part'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '108', 'type': 'ERROR', 'children': ['109', '111', '112', '117']}, {'id': '109', 'type': 'ERROR', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'continue'}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'import_tokens'}; {'id': '112', 'type': 'call', 'children': ['113', '116']}, {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'import_part'}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '116', 'type': 'argument_list', 'children': []}, {'id': '117', 'type': 'comparison_operator', 'children': ['118', '121'], 'value': '=='}; {'id': '118', 'type': 'subscript', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'import_tokens'}; {'id': '120', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '121', 'type': 'string', 'children': [], 'value': "'import'"}; {'id': '122', 'type': 'block', 'children': ['123']}, {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'module_path'}; {'id': '126', 'type': 'subscript', 'children': ['127', '128']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'import_tokens'}; {'id': '128', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '129', 'type': 'elif_clause', 'children': ['130', '141']}; {'id': '130', 'type': 'boolean_operator', 'children': ['131', '136'], 'value': 'and'}, {'id': '131', 'type': 'comparison_operator', 'children': ['132', '135'], 'value': '=='}; {'id': '132', 'type': 'subscript', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'import_tokens'}; {'id': '134', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '135', 'type': 'string', 'children': [], 'value': "'from'"}; {'id': '136', 'type': 'comparison_operator', 'children': ['137', '140'], 'value': '=='}, {'id': '137', 'type': 'subscript', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'import_tokens'}, {'id': '139', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '140', 'type': 'string', 'children': [], 'value': "'import'"}, {'id': '141', 'type': 'block', 'children': ['142']}; {'id': '142', 'type': 'expression_statement', 'children': ['143']}, {'id': '143', 'type': 'assignment', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'module_path'}, {'id': '145', 'type': 'subscript', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'import_tokens'}, {'id': '147', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '148', 'type': 'else_clause', 'children': ['149']}, {'id': '149', 'type': 'block', 'children': ['150', '158']}; {'id': '150', 'type': 'expression_statement', 'children': ['151']}, {'id': '151', 'type': 'call', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'debug'}, {'id': '155', 'type': 'argument_list', 'children': ['156', '157']}; {'id': '156', 'type': 'string', 'children': [], 'value': '"Not understood import info: %s"'}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'import_tokens'}; {'id': '158', 'type': 'continue_statement', 'children': []}, {'id': '159', 'type': 'expression_statement', 'children': ['160']}; {'id': '160', 'type': 'assignment', 'children': ['161', '162']}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '162', 'type': 'subscript', 'children': ['163', '169']}, {'id': '163', 'type': 'call', 'children': ['164', '167']}; {'id': '164', 'type': 'attribute', 'children': ['165', '166']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'module_path'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'split'}, {'id': '167', 'type': 'argument_list', 'children': ['168']}; {'id': '168', 'type': 'string', 'children': [], 'value': '"."'}, {'id': '169', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '170', 'type': 'if_statement', 'children': ['171', '174']}, {'id': '171', 'type': 'comparison_operator', 'children': ['172', '173'], 'value': 'in'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'module'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'PKG_NAMES_DB'}; {'id': '174', 'type': 'block', 'children': ['175']}, {'id': '175', 'type': 'expression_statement', 'children': ['176']}; {'id': '176', 'type': 'assignment', 'children': ['177', '178']}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '178', 'type': 'subscript', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'PKG_NAMES_DB'}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'module'}, {'id': '181', 'type': 'expression_statement', 'children': ['182']}; {'id': '182', 'type': 'assignment', 'children': ['183', '184']}, {'id': '183', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '184', 'type': 'call', 'children': ['185', '188']}, {'id': '185', 'type': 'attribute', 'children': ['186', '187']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'module'}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '188', 'type': 'argument_list', 'children': ['189', '190']}, {'id': '189', 'type': 'string', 'children': [], 'value': "'_'"}; {'id': '190', 'type': 'string', 'children': [], 'value': "'-'"}, {'id': '191', 'type': 'if_statement', 'children': ['192', '212', '223', '239']}; {'id': '192', 'type': 'boolean_operator', 'children': ['193', '199'], 'value': 'or'}, {'id': '193', 'type': 'comparison_operator', 'children': ['194', '198'], 'value': '=='}; {'id': '194', 'type': 'call', 'children': ['195', '196']}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '196', 'type': 'argument_list', 'children': ['197']}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'fades_part'}; {'id': '198', 'type': 'integer', 'children': [], 'value': '5'}, {'id': '199', 'type': 'comparison_operator', 'children': ['200', '211'], 'value': 'in'}; {'id': '200', 'type': 'subscript', 'children': ['201', '210']}, {'id': '201', 'type': 'call', 'children': ['202', '209']}; {'id': '202', 'type': 'attribute', 'children': ['203', '208']}, {'id': '203', 'type': 'subscript', 'children': ['204', '205']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'fades_part'}, {'id': '205', 'type': 'slice', 'children': ['206', '207']}; {'id': '206', 'type': 'integer', 'children': [], 'value': '5'}, {'id': '207', 'type': 'colon', 'children': []}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'strip'}, {'id': '209', 'type': 'argument_list', 'children': []}; {'id': '210', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '211', 'type': 'string', 'children': [], 'value': '"<>=!"'}; {'id': '212', 'type': 'block', 'children': ['213']}, {'id': '213', 'type': 'expression_statement', 'children': ['214']}; {'id': '214', 'type': 'assignment', 'children': ['215', '216']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'requirement'}; {'id': '216', 'type': 'binary_operator', 'children': ['217', '218'], 'value': '+'}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '218', 'type': 'subscript', 'children': ['219', '220']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'fades_part'}; {'id': '220', 'type': 'slice', 'children': ['221', '222']}, {'id': '221', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '222', 'type': 'colon', 'children': []}, {'id': '223', 'type': 'elif_clause', 'children': ['224', '229']}; {'id': '224', 'type': 'comparison_operator', 'children': ['225', '228'], 'value': '!='}, {'id': '225', 'type': 'subscript', 'children': ['226', '227']}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'fades_part'}, {'id': '227', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '228', 'type': 'string', 'children': [], 'value': '" "'}, {'id': '229', 'type': 'block', 'children': ['230', '238']}; {'id': '230', 'type': 'expression_statement', 'children': ['231']}, {'id': '231', 'type': 'call', 'children': ['232', '235']}; {'id': '232', 'type': 'attribute', 'children': ['233', '234']}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'warning'}, {'id': '235', 'type': 'argument_list', 'children': ['236', '237']}; {'id': '236', 'type': 'string', 'children': [], 'value': '"Not understood fades info: %r"'}, {'id': '237', 'type': 'identifier', 'children': [], 'value': 'fades_part'}; {'id': '238', 'type': 'continue_statement', 'children': []}, {'id': '239', 'type': 'else_clause', 'children': ['240']}; {'id': '240', 'type': 'block', 'children': ['241']}, {'id': '241', 'type': 'expression_statement', 'children': ['242']}; {'id': '242', 'type': 'assignment', 'children': ['243', '244']}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'requirement'}; {'id': '244', 'type': 'subscript', 'children': ['245', '246']}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'fades_part'}; {'id': '246', 'type': 'slice', 'children': ['247', '248']}, {'id': '247', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '248', 'type': 'colon', 'children': []}, {'id': '249', 'type': 'expression_statement', 'children': ['250']}; {'id': '250', 'type': 'assignment', 'children': ['251', '252']}, {'id': '251', 'type': 'identifier', 'children': [], 'value': 'parsed_req'}; {'id': '252', 'type': 'call', 'children': ['253', '254']}, {'id': '253', 'type': 'identifier', 'children': [], 'value': 'parse_fade_requirement'}; {'id': '254', 'type': 'argument_list', 'children': ['255']}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'requirement'}; {'id': '256', 'type': 'if_statement', 'children': ['257', '260']}, {'id': '257', 'type': 'comparison_operator', 'children': ['258', '259'], 'value': 'is'}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'parsed_req'}, {'id': '259', 'type': 'None', 'children': []}; {'id': '260', 'type': 'block', 'children': ['261']}, {'id': '261', 'type': 'continue_statement', 'children': []}; {'id': '262', 'type': 'expression_statement', 'children': ['263']}, {'id': '263', 'type': 'assignment', 'children': ['264', '267']}; {'id': '264', 'type': 'pattern_list', 'children': ['265', '266']}, {'id': '265', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '266', 'type': 'identifier', 'children': [], 'value': 'dependency'}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'parsed_req'}; {'id': '268', 'type': 'expression_statement', 'children': ['269']}, {'id': '269', 'type': 'call', 'children': ['270', '279']}; {'id': '270', 'type': 'attribute', 'children': ['271', '278']}, {'id': '271', 'type': 'call', 'children': ['272', '275']}; {'id': '272', 'type': 'attribute', 'children': ['273', '274']}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'deps'}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'setdefault'}, {'id': '275', 'type': 'argument_list', 'children': ['276', '277']}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'repo'}, {'id': '277', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '279', 'type': 'argument_list', 'children': ['280']}; {'id': '280', 'type': 'identifier', 'children': [], 'value': 'dependency'}, {'id': '281', 'type': 'return_statement', 'children': ['282']}
def _parse_content(fh): content = iter(fh) deps = {} for line in content: if 'fades' not in line: continue if ' continue line = line.strip() index_of_last_fades = line.rfind('fades') index_of_first_hash = line.index(' if index_of_first_hash > index_of_last_fades: continue import_part, fades_part = line.rsplit(" if "fades" not in fades_part: import_part, fades_part = import_part.rsplit(" fades_part = fades_part.strip() if not fades_part.startswith("fades"): continue if not import_part: import_part = next(content).strip() if import_part.startswith(' continue import_tokens = import_part.split() if import_tokens[0] == 'import': module_path = import_tokens[1] elif import_tokens[0] == 'from' and import_tokens[2] == 'import': module_path = import_tokens[1] else: logger.debug("Not understood import info: %s", import_tokens) continue module = module_path.split(".")[0] if module in PKG_NAMES_DB: module = PKG_NAMES_DB[module] module = module.replace('_', '-') if len(fades_part) == 5 or fades_part[5:].strip()[0] in "<>=!": requirement = module + fades_part[5:] elif fades_part[5] != " ": logger.warning("Not understood fades info: %r", fades_part) continue else: requirement = fades_part[5:] parsed_req = parse_fade_requirement(requirement) if parsed_req is None: continue repo, dependency = parsed_req deps.setdefault(repo, []).append(dependency) return deps
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_docstring'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fh'}, {'id': '5', 'type': 'block', 'children': ['6', '17', '51', '70', '136', '143', '158']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}, {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'find_fades'}, {'id': '9', 'type': 'attribute', 'children': ['10', '16']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}, {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 're'}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'compile'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}, {'id': '15', 'type': 'string', 'children': [], 'value': "r'\\b(fades)\\b:'"}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'search'}, {'id': '17', 'type': 'for_statement', 'children': ['18', '19', '20', '47']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '20', 'type': 'block', 'children': ['21', '34']}, {'id': '21', 'type': 'if_statement', 'children': ['22', '28']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}, {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}, {'id': '27', 'type': 'string', 'children': [], 'value': '"\'"'}; {'id': '28', 'type': 'block', 'children': ['29', '33']}, {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'quote'}; {'id': '32', 'type': 'string', 'children': [], 'value': '"\'"'}, {'id': '33', 'type': 'break_statement', 'children': []}; {'id': '34', 'type': 'if_statement', 'children': ['35', '41']}, {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'startswith'}, {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'string', 'children': [], 'value': '\'"\''}, {'id': '41', 'type': 'block', 'children': ['42', '46']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}, {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'quote'}, {'id': '45', 'type': 'string', 'children': [], 'value': '\'"\''}; {'id': '46', 'type': 'break_statement', 'children': []}, {'id': '47', 'type': 'else_clause', 'children': ['48']}; {'id': '48', 'type': 'block', 'children': ['49']}, {'id': '49', 'type': 'return_statement', 'children': ['50']}; {'id': '50', 'type': 'dictionary', 'children': []}, {'id': '51', 'type': 'if_statement', 'children': ['52', '57', '64']}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '56'], 'value': '=='}, {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '55', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'quote'}, {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}, {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'endquote'}, {'id': '61', 'type': 'binary_operator', 'children': ['62', '63'], 'value': '*'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'quote'}, {'id': '63', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '64', 'type': 'else_clause', 'children': ['65']}, {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}, {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'endquote'}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'quote'}; {'id': '70', 'type': 'if_statement', 'children': ['71', '81', '96']}, {'id': '71', 'type': 'comparison_operator', 'children': ['72', '73'], 'value': 'in'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'endquote'}, {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '75', 'type': 'slice', 'children': ['76', '80']}; {'id': '76', 'type': 'call', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'endquote'}; {'id': '80', 'type': 'colon', 'children': []}, {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}, {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'docstring_lines'}, {'id': '85', 'type': 'list', 'children': ['86'], 'value': '[line[:line.index(endquote)]]'}; {'id': '86', 'type': 'subscript', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '88', 'type': 'slice', 'children': ['89', '90']}, {'id': '89', 'type': 'colon', 'children': []}; {'id': '90', 'type': 'call', 'children': ['91', '94']}, {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'endquote'}; {'id': '96', 'type': 'else_clause', 'children': ['97']}, {'id': '97', 'type': 'block', 'children': ['98', '103']}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}, {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'docstring_lines'}, {'id': '101', 'type': 'list', 'children': ['102'], 'value': '[line]'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '103', 'type': 'for_statement', 'children': ['104', '105', '106']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '106', 'type': 'block', 'children': ['107', '129']}, {'id': '107', 'type': 'if_statement', 'children': ['108', '111']}; {'id': '108', 'type': 'comparison_operator', 'children': ['109', '110'], 'value': 'in'}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'endquote'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '111', 'type': 'block', 'children': ['112', '128']}; {'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': 'docstring_lines'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'subscript', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '120', 'type': 'slice', 'children': ['121', '122']}, {'id': '121', 'type': 'colon', 'children': []}; {'id': '122', 'type': 'call', 'children': ['123', '126']}, {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'endquote'}; {'id': '128', 'type': 'break_statement', 'children': []}, {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'call', 'children': ['131', '134']}, {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'docstring_lines'}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}, {'id': '137', 'type': 'assignment', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'docstring_lines'}, {'id': '139', 'type': 'call', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'iter'}, {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'docstring_lines'}, {'id': '143', 'type': 'for_statement', 'children': ['144', '145', '146', '154']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'doc_line'}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'docstring_lines'}; {'id': '146', 'type': 'block', 'children': ['147']}, {'id': '147', 'type': 'if_statement', 'children': ['148', '152']}; {'id': '148', 'type': 'call', 'children': ['149', '150']}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'find_fades'}; {'id': '150', 'type': 'argument_list', 'children': ['151']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'doc_line'}; {'id': '152', 'type': 'block', 'children': ['153']}, {'id': '153', 'type': 'break_statement', 'children': []}; {'id': '154', 'type': 'else_clause', 'children': ['155']}, {'id': '155', 'type': 'block', 'children': ['156']}; {'id': '156', 'type': 'return_statement', 'children': ['157']}, {'id': '157', 'type': 'dictionary', 'children': []}; {'id': '158', 'type': 'return_statement', 'children': ['159']}, {'id': '159', 'type': 'call', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': '_parse_requirement'}, {'id': '161', 'type': 'argument_list', 'children': ['162']}; {'id': '162', 'type': 'call', 'children': ['163', '164']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '164', 'type': 'argument_list', 'children': ['165']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'docstring_lines'}
def _parse_docstring(fh): find_fades = re.compile(r'\b(fades)\b:').search for line in fh: if line.startswith("'"): quote = "'" break if line.startswith('"'): quote = '"' break else: return {} if line[1] == quote: endquote = quote * 3 else: endquote = quote if endquote in line[len(endquote):]: docstring_lines = [line[:line.index(endquote)]] else: docstring_lines = [line] for line in fh: if endquote in line: docstring_lines.append(line[:line.index(endquote)]) break docstring_lines.append(line) docstring_lines = iter(docstring_lines) for doc_line in docstring_lines: if find_fades(doc_line): break else: return {} return _parse_requirement(list(docstring_lines))
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_venv_match'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'installed'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'requirements'}, {'id': '7', 'type': 'block', 'children': ['8', '17', '21', '133']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '11']}, {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'requirements'}, {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}, {'id': '13', 'type': 'conditional_expression', 'children': ['14', '15', '16'], 'value': 'if'}; {'id': '14', 'type': 'None', 'children': []}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'installed'}; {'id': '16', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'satisfying_deps'}; {'id': '20', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '21', 'type': 'for_statement', 'children': ['22', '25', '30']}; {'id': '22', 'type': 'pattern_list', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'req_deps'}, {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'requirements'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'items'}, {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31', '37', '44', '92', '117']}, {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'useful_inst'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '36', 'type': 'argument_list', 'children': []}, {'id': '37', 'type': 'if_statement', 'children': ['38', '41']}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '40'], 'value': 'not'}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'installed'}, {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'return_statement', 'children': ['43']}, {'id': '43', 'type': 'None', 'children': []}; {'id': '44', 'type': 'if_statement', 'children': ['45', '48', '66']}, {'id': '45', 'type': 'comparison_operator', 'children': ['46', '47'], 'value': '=='}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'repo'}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'REPO_VCS'}; {'id': '48', 'type': 'block', 'children': ['49']}, {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'inst_deps'}; {'id': '52', 'type': 'set_comprehension', 'children': ['53', '57']}, {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'VCSDependency'}, {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'url'}, {'id': '57', 'type': 'for_in_clause', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'url'}, {'id': '59', 'type': 'call', 'children': ['60', '65']}; {'id': '60', 'type': 'attribute', 'children': ['61', '64']}, {'id': '61', 'type': 'subscript', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'installed'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'keys'}, {'id': '65', 'type': 'argument_list', 'children': []}; {'id': '66', 'type': 'else_clause', 'children': ['67']}, {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}, {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'inst_deps'}, {'id': '71', 'type': 'set_comprehension', 'children': ['72', '81']}; {'id': '72', 'type': 'call', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'Distribution'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '78']}, {'id': '75', 'type': 'keyword_argument', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'project_name'}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'dep'}; {'id': '78', 'type': 'keyword_argument', 'children': ['79', '80']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'ver'}, {'id': '81', 'type': 'for_in_clause', 'children': ['82', '85']}; {'id': '82', 'type': 'tuple_pattern', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'dep'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'ver'}, {'id': '85', 'type': 'call', 'children': ['86', '91']}; {'id': '86', 'type': 'attribute', 'children': ['87', '90']}, {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'installed'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'items'}, {'id': '91', 'type': 'argument_list', 'children': []}; {'id': '92', 'type': 'for_statement', 'children': ['93', '94', '95']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'req'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'req_deps'}, {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'for_statement', 'children': ['97', '98', '99', '113']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'inst'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'inst_deps'}, {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'if_statement', 'children': ['101', '104']}, {'id': '101', 'type': 'comparison_operator', 'children': ['102', '103'], 'value': 'in'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'inst'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'req'}; {'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': 'useful_inst'}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'inst'}; {'id': '112', 'type': 'break_statement', 'children': []}, {'id': '113', 'type': 'else_clause', 'children': ['114']}; {'id': '114', 'type': 'block', 'children': ['115']}, {'id': '115', 'type': 'return_statement', 'children': ['116']}; {'id': '116', 'type': 'None', 'children': []}, {'id': '117', 'type': 'if_statement', 'children': ['118', '121', '129']}; {'id': '118', 'type': 'comparison_operator', 'children': ['119', '120'], 'value': '=='}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'useful_inst'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'inst_deps'}, {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}, {'id': '123', 'type': 'call', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'satisfying_deps'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'extend'}, {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'inst_deps'}, {'id': '129', 'type': 'else_clause', 'children': ['130']}; {'id': '130', 'type': 'block', 'children': ['131']}, {'id': '131', 'type': 'return_statement', 'children': ['132']}; {'id': '132', 'type': 'None', 'children': []}, {'id': '133', 'type': 'return_statement', 'children': ['134']}
def _venv_match(self, installed, requirements): if not requirements: return None if installed else [] satisfying_deps = [] for repo, req_deps in requirements.items(): useful_inst = set() if repo not in installed: return None if repo == REPO_VCS: inst_deps = {VCSDependency(url) for url in installed[repo].keys()} else: inst_deps = {Distribution(project_name=dep, version=ver) for (dep, ver) in installed[repo].items()} for req in req_deps: for inst in inst_deps: if inst in req: useful_inst.add(inst) break else: return None if useful_inst == inst_deps: satisfying_deps.extend(inst_deps) else: return None return satisfying_deps
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '32']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encrypt'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26', '29']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'content'}, {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'salt'}, {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '10', 'type': 'None', 'children': []}, {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'private_key'}, {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'dh'}; {'id': '16', 'type': 'None', 'children': []}, {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'auth_secret'}, {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'keyid'}; {'id': '22', 'type': 'None', 'children': []}, {'id': '23', 'type': 'default_parameter', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'keylabel'}, {'id': '25', 'type': 'string', 'children': [], 'value': '"P-256"'}; {'id': '26', 'type': 'default_parameter', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'rs'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '4096'}, {'id': '29', 'type': 'default_parameter', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'version'}, {'id': '31', 'type': 'string', 'children': [], 'value': '"aes128gcm"'}; {'id': '32', 'type': 'block', 'children': ['33', '129', '195', '205', '219', '252', '260', '287', '297', '303', '307', '311', '350', '406']}, {'id': '33', 'type': 'function_definition', 'children': ['34', '35', '41']}; {'id': '34', 'type': 'function_name', 'children': [], 'value': 'encrypt_record'}, {'id': '35', 'type': 'parameters', 'children': ['36', '37', '38', '39', '40']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'nonce'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'counter'}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'last'}, {'id': '41', 'type': 'block', 'children': ['42', '73', '113', '121', '127']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}, {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'encryptor'}, {'id': '45', 'type': 'call', 'children': ['46', '72']}; {'id': '46', 'type': 'attribute', 'children': ['47', '71']}, {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'Cipher'}, {'id': '49', 'type': 'argument_list', 'children': ['50', '56', '66']}; {'id': '50', 'type': 'call', 'children': ['51', '54']}, {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'algorithms'}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'AES'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '56', 'type': 'call', 'children': ['57', '60']}, {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'modes'}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'GCM'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}, {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'iv'}, {'id': '63', 'type': 'argument_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'nonce'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'counter'}; {'id': '66', 'type': 'keyword_argument', 'children': ['67', '68']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'backend'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'default_backend'}; {'id': '70', 'type': 'argument_list', 'children': []}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'encryptor'}; {'id': '72', 'type': 'argument_list', 'children': []}, {'id': '73', 'type': 'if_statement', 'children': ['74', '77', '93']}; {'id': '74', 'type': 'comparison_operator', 'children': ['75', '76'], 'value': '=='}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'aes128gcm'"}, {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}, {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'data'}, {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'encryptor'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'update'}, {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'binary_operator', 'children': ['87', '88'], 'value': '+'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '88', 'type': 'parenthesized_expression', 'children': ['89']}, {'id': '89', 'type': 'conditional_expression', 'children': ['90', '91', '92'], 'value': 'if'}; {'id': '90', 'type': 'string', 'children': [], 'value': "b'\\x02'"}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'last'}; {'id': '92', 'type': 'string', 'children': [], 'value': "b'\\x01'"}, {'id': '93', 'type': 'else_clause', 'children': ['94']}; {'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': 'data'}; {'id': '98', 'type': 'call', 'children': ['99', '102']}, {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'encryptor'}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}, {'id': '103', 'type': 'binary_operator', 'children': ['104', '112'], 'value': '+'}; {'id': '104', 'type': 'parenthesized_expression', 'children': ['105']}, {'id': '105', 'type': 'binary_operator', 'children': ['106', '107'], 'value': '*'}; {'id': '106', 'type': 'string', 'children': [], 'value': 'b"\\x00"'}, {'id': '107', 'type': 'subscript', 'children': ['108', '111']}; {'id': '108', 'type': 'subscript', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'versions'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'version'}, {'id': '111', 'type': 'string', 'children': [], 'value': "'pad'"}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'buf'}, {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'augmented_assignment', 'children': ['115', '116'], 'value': '+='}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '116', 'type': 'call', 'children': ['117', '120']}, {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'encryptor'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'finalize'}; {'id': '120', 'type': 'argument_list', 'children': []}, {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'augmented_assignment', 'children': ['123', '124'], 'value': '+='}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'encryptor'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'tag'}, {'id': '127', 'type': 'return_statement', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'data'}, {'id': '129', 'type': 'function_definition', 'children': ['130', '131', '136']}; {'id': '130', 'type': 'function_name', 'children': [], 'value': 'compose_aes128gcm'}, {'id': '131', 'type': 'parameters', 'children': ['132', '133', '134', '135']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'salt'}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'rs'}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'keyid'}; {'id': '136', 'type': 'block', 'children': ['137', '150', '154', '164', '174', '187', '191']}, {'id': '137', 'type': 'if_statement', 'children': ['138', '144']}; {'id': '138', 'type': 'comparison_operator', 'children': ['139', '143'], 'value': '>'}, {'id': '139', 'type': 'call', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'keyid'}, {'id': '143', 'type': 'integer', 'children': [], 'value': '255'}; {'id': '144', 'type': 'block', 'children': ['145']}, {'id': '145', 'type': 'raise_statement', 'children': ['146']}; {'id': '146', 'type': 'call', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'ECEException'}; {'id': '148', 'type': 'argument_list', 'children': ['149']}, {'id': '149', 'type': 'string', 'children': [], 'value': '"keyid is too long"'}; {'id': '150', 'type': 'expression_statement', 'children': ['151']}, {'id': '151', 'type': 'assignment', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'header'}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '154', 'type': 'if_statement', 'children': ['155', '158']}, {'id': '155', 'type': 'comparison_operator', 'children': ['156', '157'], 'value': '>'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'rs'}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'MAX_RECORD_SIZE'}; {'id': '158', 'type': 'block', 'children': ['159']}, {'id': '159', 'type': 'raise_statement', 'children': ['160']}; {'id': '160', 'type': 'call', 'children': ['161', '162']}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'ECEException'}; {'id': '162', 'type': 'argument_list', 'children': ['163']}, {'id': '163', 'type': 'string', 'children': [], 'value': '"Too much content"'}; {'id': '164', 'type': 'expression_statement', 'children': ['165']}, {'id': '165', 'type': 'augmented_assignment', 'children': ['166', '167'], 'value': '+='}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'header'}, {'id': '167', 'type': 'call', 'children': ['168', '171']}; {'id': '168', 'type': 'attribute', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'pack'}, {'id': '171', 'type': 'argument_list', 'children': ['172', '173']}; {'id': '172', 'type': 'string', 'children': [], 'value': '"!L"'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'rs'}; {'id': '174', 'type': 'expression_statement', 'children': ['175']}, {'id': '175', 'type': 'augmented_assignment', 'children': ['176', '177'], 'value': '+='}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'header'}, {'id': '177', 'type': 'call', 'children': ['178', '181']}; {'id': '178', 'type': 'attribute', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'pack'}, {'id': '181', 'type': 'argument_list', 'children': ['182', '183']}; {'id': '182', 'type': 'string', 'children': [], 'value': '"!B"'}, {'id': '183', 'type': 'call', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '185', 'type': 'argument_list', 'children': ['186']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'keyid'}, {'id': '187', 'type': 'expression_statement', 'children': ['188']}; {'id': '188', 'type': 'augmented_assignment', 'children': ['189', '190'], 'value': '+='}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'keyid'}, {'id': '191', 'type': 'return_statement', 'children': ['192']}; {'id': '192', 'type': 'binary_operator', 'children': ['193', '194'], 'value': '+'}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'content'}, {'id': '195', 'type': 'if_statement', 'children': ['196', '199']}; {'id': '196', 'type': 'comparison_operator', 'children': ['197', '198'], 'value': 'not'}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'versions'}, {'id': '199', 'type': 'block', 'children': ['200']}; {'id': '200', 'type': 'raise_statement', 'children': ['201']}, {'id': '201', 'type': 'call', 'children': ['202', '203']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'ECEException'}, {'id': '203', 'type': 'argument_list', 'children': ['204']}; {'id': '204', 'type': 'string', 'children': [], 'value': 'u"Invalid version"'}, {'id': '205', 'type': 'if_statement', 'children': ['206', '209']}; {'id': '206', 'type': 'comparison_operator', 'children': ['207', '208'], 'value': 'is'}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '208', 'type': 'None', 'children': []}, {'id': '209', 'type': 'block', 'children': ['210']}; {'id': '210', 'type': 'expression_statement', 'children': ['211']}, {'id': '211', 'type': 'assignment', 'children': ['212', '213']}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'salt'}, {'id': '213', 'type': 'call', 'children': ['214', '217']}; {'id': '214', 'type': 'attribute', 'children': ['215', '216']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'urandom'}, {'id': '217', 'type': 'argument_list', 'children': ['218']}; {'id': '218', 'type': 'integer', 'children': [], 'value': '16'}, {'id': '219', 'type': 'expression_statement', 'children': ['220']}; {'id': '220', 'type': 'assignment', 'children': ['221', '224']}, {'id': '221', 'type': 'tuple_pattern', 'children': ['222', '223']}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'key_'}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'nonce_'}; {'id': '224', 'type': 'call', 'children': ['225', '226']}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'derive_key'}; {'id': '226', 'type': 'argument_list', 'children': ['227', '228', '231', '234', '237', '240', '243', '246', '249']}, {'id': '227', 'type': 'string', 'children': [], 'value': '"encrypt"'}; {'id': '228', 'type': 'keyword_argument', 'children': ['229', '230']}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'version'}, {'id': '231', 'type': 'keyword_argument', 'children': ['232', '233']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'salt'}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '234', 'type': 'keyword_argument', 'children': ['235', '236']}, {'id': '235', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '237', 'type': 'keyword_argument', 'children': ['238', '239']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'private_key'}, {'id': '239', 'type': 'identifier', 'children': [], 'value': 'private_key'}; {'id': '240', 'type': 'keyword_argument', 'children': ['241', '242']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'dh'}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'dh'}, {'id': '243', 'type': 'keyword_argument', 'children': ['244', '245']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'auth_secret'}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'auth_secret'}; {'id': '246', 'type': 'keyword_argument', 'children': ['247', '248']}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'keyid'}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 'keyid'}, {'id': '249', 'type': 'keyword_argument', 'children': ['250', '251']}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'keylabel'}, {'id': '251', 'type': 'identifier', 'children': [], 'value': 'keylabel'}; {'id': '252', 'type': 'expression_statement', 'children': ['253']}, {'id': '253', 'type': 'assignment', 'children': ['254', '255']}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'overhead'}, {'id': '255', 'type': 'subscript', 'children': ['256', '259']}; {'id': '256', 'type': 'subscript', 'children': ['257', '258']}, {'id': '257', 'type': 'identifier', 'children': [], 'value': 'versions'}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'version'}, {'id': '259', 'type': 'string', 'children': [], 'value': "'pad'"}; {'id': '260', 'type': 'if_statement', 'children': ['261', '264', '276']}, {'id': '261', 'type': 'comparison_operator', 'children': ['262', '263'], 'value': '=='}; {'id': '262', 'type': 'identifier', 'children': [], 'value': 'version'}, {'id': '263', 'type': 'string', 'children': [], 'value': "'aes128gcm'"}; {'id': '264', 'type': 'block', 'children': ['265', '269']}, {'id': '265', 'type': 'expression_statement', 'children': ['266']}; {'id': '266', 'type': 'augmented_assignment', 'children': ['267', '268'], 'value': '+='}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'overhead'}; {'id': '268', 'type': 'integer', 'children': [], 'value': '16'}, {'id': '269', 'type': 'expression_statement', 'children': ['270']}; {'id': '270', 'type': 'assignment', 'children': ['271', '272']}, {'id': '271', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '272', 'type': 'call', 'children': ['273', '274']}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '274', 'type': 'argument_list', 'children': ['275']}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '276', 'type': 'else_clause', 'children': ['277']}, {'id': '277', 'type': 'block', 'children': ['278']}; {'id': '278', 'type': 'expression_statement', 'children': ['279']}, {'id': '279', 'type': 'assignment', 'children': ['280', '281']}; {'id': '280', 'type': 'identifier', 'children': [], 'value': 'end'}, {'id': '281', 'type': 'binary_operator', 'children': ['282', '286'], 'value': '+'}; {'id': '282', 'type': 'call', 'children': ['283', '284']}, {'id': '283', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '284', 'type': 'argument_list', 'children': ['285']}, {'id': '285', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '286', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '287', 'type': 'if_statement', 'children': ['288', '291']}; {'id': '288', 'type': 'comparison_operator', 'children': ['289', '290'], 'value': '<='}, {'id': '289', 'type': 'identifier', 'children': [], 'value': 'rs'}; {'id': '290', 'type': 'identifier', 'children': [], 'value': 'overhead'}, {'id': '291', 'type': 'block', 'children': ['292']}; {'id': '292', 'type': 'raise_statement', 'children': ['293']}, {'id': '293', 'type': 'call', 'children': ['294', '295']}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'ECEException'}, {'id': '295', 'type': 'argument_list', 'children': ['296']}; {'id': '296', 'type': 'string', 'children': [], 'value': 'u"Record size too small"'}, {'id': '297', 'type': 'expression_statement', 'children': ['298']}; {'id': '298', 'type': 'assignment', 'children': ['299', '300']}, {'id': '299', 'type': 'identifier', 'children': [], 'value': 'chunk_size'}; {'id': '300', 'type': 'binary_operator', 'children': ['301', '302'], 'value': '-'}, {'id': '301', 'type': 'identifier', 'children': [], 'value': 'rs'}; {'id': '302', 'type': 'identifier', 'children': [], 'value': 'overhead'}, {'id': '303', 'type': 'expression_statement', 'children': ['304']}; {'id': '304', 'type': 'assignment', 'children': ['305', '306']}, {'id': '305', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '306', 'type': 'string', 'children': [], 'value': 'b""'}, {'id': '307', 'type': 'expression_statement', 'children': ['308']}; {'id': '308', 'type': 'assignment', 'children': ['309', '310']}, {'id': '309', 'type': 'identifier', 'children': [], 'value': 'counter'}; {'id': '310', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '311', 'type': 'for_statement', 'children': ['312', '313', '322']}; {'id': '312', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '313', 'type': 'call', 'children': ['314', '315']}; {'id': '314', 'type': 'identifier', 'children': [], 'value': 'list'}, {'id': '315', 'type': 'argument_list', 'children': ['316']}; {'id': '316', 'type': 'call', 'children': ['317', '318']}, {'id': '317', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '318', 'type': 'argument_list', 'children': ['319', '320', '321']}, {'id': '319', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '320', 'type': 'identifier', 'children': [], 'value': 'end'}, {'id': '321', 'type': 'identifier', 'children': [], 'value': 'chunk_size'}; {'id': '322', 'type': 'block', 'children': ['323', '346']}, {'id': '323', 'type': 'expression_statement', 'children': ['324']}; {'id': '324', 'type': 'augmented_assignment', 'children': ['325', '326'], 'value': '+='}, {'id': '325', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '326', 'type': 'call', 'children': ['327', '328']}, {'id': '327', 'type': 'identifier', 'children': [], 'value': 'encrypt_record'}; {'id': '328', 'type': 'argument_list', 'children': ['329', '330', '331', '332', '340']}, {'id': '329', 'type': 'identifier', 'children': [], 'value': 'key_'}; {'id': '330', 'type': 'identifier', 'children': [], 'value': 'nonce_'}, {'id': '331', 'type': 'identifier', 'children': [], 'value': 'counter'}; {'id': '332', 'type': 'subscript', 'children': ['333', '334']}, {'id': '333', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '334', 'type': 'slice', 'children': ['335', '336', '337']}, {'id': '335', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '336', 'type': 'colon', 'children': []}, {'id': '337', 'type': 'binary_operator', 'children': ['338', '339'], 'value': '+'}; {'id': '338', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '339', 'type': 'identifier', 'children': [], 'value': 'chunk_size'}; {'id': '340', 'type': 'comparison_operator', 'children': ['341', '345'], 'value': '>='}, {'id': '341', 'type': 'parenthesized_expression', 'children': ['342']}; {'id': '342', 'type': 'binary_operator', 'children': ['343', '344'], 'value': '+'}, {'id': '343', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '344', 'type': 'identifier', 'children': [], 'value': 'chunk_size'}, {'id': '345', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '346', 'type': 'expression_statement', 'children': ['347']}, {'id': '347', 'type': 'augmented_assignment', 'children': ['348', '349'], 'value': '+='}; {'id': '348', 'type': 'identifier', 'children': [], 'value': 'counter'}, {'id': '349', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '350', 'type': 'if_statement', 'children': ['351', '354']}, {'id': '351', 'type': 'comparison_operator', 'children': ['352', '353'], 'value': '=='}; {'id': '352', 'type': 'identifier', 'children': [], 'value': 'version'}, {'id': '353', 'type': 'string', 'children': [], 'value': '"aes128gcm"'}; {'id': '354', 'type': 'block', 'children': ['355', '396']}, {'id': '355', 'type': 'if_statement', 'children': ['356', '363', '382']}; {'id': '356', 'type': 'boolean_operator', 'children': ['357', '360'], 'value': 'and'}, {'id': '357', 'type': 'comparison_operator', 'children': ['358', '359'], 'value': 'is'}; {'id': '358', 'type': 'identifier', 'children': [], 'value': 'keyid'}, {'id': '359', 'type': 'None', 'children': []}; {'id': '360', 'type': 'comparison_operator', 'children': ['361', '362'], 'value': 'is'}, {'id': '361', 'type': 'identifier', 'children': [], 'value': 'private_key'}; {'id': '362', 'type': 'None', 'children': []}, {'id': '363', 'type': 'block', 'children': ['364']}; {'id': '364', 'type': 'expression_statement', 'children': ['365']}, {'id': '365', 'type': 'assignment', 'children': ['366', '367']}; {'id': '366', 'type': 'identifier', 'children': [], 'value': 'kid'}, {'id': '367', 'type': 'call', 'children': ['368', '375']}; {'id': '368', 'type': 'attribute', 'children': ['369', '374']}, {'id': '369', 'type': 'call', 'children': ['370', '373']}; {'id': '370', 'type': 'attribute', 'children': ['371', '372']}, {'id': '371', 'type': 'identifier', 'children': [], 'value': 'private_key'}; {'id': '372', 'type': 'identifier', 'children': [], 'value': 'public_key'}, {'id': '373', 'type': 'argument_list', 'children': []}; {'id': '374', 'type': 'identifier', 'children': [], 'value': 'public_bytes'}, {'id': '375', 'type': 'argument_list', 'children': ['376', '379']}; {'id': '376', 'type': 'attribute', 'children': ['377', '378']}, {'id': '377', 'type': 'identifier', 'children': [], 'value': 'Encoding'}; {'id': '378', 'type': 'identifier', 'children': [], 'value': 'X962'}, {'id': '379', 'type': 'attribute', 'children': ['380', '381']}; {'id': '380', 'type': 'identifier', 'children': [], 'value': 'PublicFormat'}, {'id': '381', 'type': 'identifier', 'children': [], 'value': 'UncompressedPoint'}; {'id': '382', 'type': 'else_clause', 'children': ['383']}, {'id': '383', 'type': 'block', 'children': ['384']}; {'id': '384', 'type': 'expression_statement', 'children': ['385']}, {'id': '385', 'type': 'assignment', 'children': ['386', '387']}; {'id': '386', 'type': 'identifier', 'children': [], 'value': 'kid'}, {'id': '387', 'type': 'call', 'children': ['388', '394']}; {'id': '388', 'type': 'attribute', 'children': ['389', '393']}, {'id': '389', 'type': 'parenthesized_expression', 'children': ['390']}; {'id': '390', 'type': 'boolean_operator', 'children': ['391', '392'], 'value': 'or'}, {'id': '391', 'type': 'identifier', 'children': [], 'value': 'keyid'}; {'id': '392', 'type': 'string', 'children': [], 'value': "''"}, {'id': '393', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '394', 'type': 'argument_list', 'children': ['395']}, {'id': '395', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '396', 'type': 'return_statement', 'children': ['397']}, {'id': '397', 'type': 'call', 'children': ['398', '399']}; {'id': '398', 'type': 'identifier', 'children': [], 'value': 'compose_aes128gcm'}, {'id': '399', 'type': 'argument_list', 'children': ['400', '401', '402', '403']}; {'id': '400', 'type': 'identifier', 'children': [], 'value': 'salt'}, {'id': '401', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '402', 'type': 'identifier', 'children': [], 'value': 'rs'}, {'id': '403', 'type': 'keyword_argument', 'children': ['404', '405']}; {'id': '404', 'type': 'identifier', 'children': [], 'value': 'keyid'}, {'id': '405', 'type': 'identifier', 'children': [], 'value': 'kid'}; {'id': '406', 'type': 'return_statement', 'children': ['407']}, {'id': '407', 'type': 'identifier', 'children': [], 'value': 'result'}
def encrypt(content, salt=None, key=None, private_key=None, dh=None, auth_secret=None, keyid=None, keylabel="P-256", rs=4096, version="aes128gcm"): def encrypt_record(key, nonce, counter, buf, last): encryptor = Cipher( algorithms.AES(key), modes.GCM(iv(nonce, counter)), backend=default_backend() ).encryptor() if version == 'aes128gcm': data = encryptor.update(buf + (b'\x02' if last else b'\x01')) else: data = encryptor.update((b"\x00" * versions[version]['pad']) + buf) data += encryptor.finalize() data += encryptor.tag return data def compose_aes128gcm(salt, content, rs, keyid): if len(keyid) > 255: raise ECEException("keyid is too long") header = salt if rs > MAX_RECORD_SIZE: raise ECEException("Too much content") header += struct.pack("!L", rs) header += struct.pack("!B", len(keyid)) header += keyid return header + content if version not in versions: raise ECEException(u"Invalid version") if salt is None: salt = os.urandom(16) (key_, nonce_) = derive_key("encrypt", version=version, salt=salt, key=key, private_key=private_key, dh=dh, auth_secret=auth_secret, keyid=keyid, keylabel=keylabel) overhead = versions[version]['pad'] if version == 'aes128gcm': overhead += 16 end = len(content) else: end = len(content) + 1 if rs <= overhead: raise ECEException(u"Record size too small") chunk_size = rs - overhead result = b"" counter = 0 for i in list(range(0, end, chunk_size)): result += encrypt_record(key_, nonce_, counter, content[i:i + chunk_size], (i + chunk_size) >= end) counter += 1 if version == "aes128gcm": if keyid is None and private_key is not None: kid = private_key.public_key().public_bytes( Encoding.X962, PublicFormat.UncompressedPoint) else: kid = (keyid or '').encode('utf-8') return compose_aes128gcm(salt, result, rs, keyid=kid) return result
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_format_ase2clusgeo'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj'}, {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'all_atomtypes'}, {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '16', '41', '53', '57', '61', '107', '111', '118', '120', '133']}, {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'totalAN'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '20', '28']}, {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': 'is'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'all_atomtypes'}, {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21']}, {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'atomtype_set'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'all_atomtypes'}; {'id': '28', 'type': 'else_clause', 'children': ['29']}, {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}, {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'atomtype_set'}, {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'set'}, {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}, {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'obj'}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'get_atomic_numbers'}; {'id': '40', 'type': 'argument_list', 'children': []}, {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'atomtype_lst'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}, {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}, {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'list'}, {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'atomtype_set'}, {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'n_atoms_per_type_lst'}; {'id': '56', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'pos_lst'}; {'id': '60', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '61', 'type': 'for_statement', 'children': ['62', '63', '64']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'atomtype'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'atomtype_lst'}; {'id': '64', 'type': 'block', 'children': ['65', '75', '85', '93', '100']}, {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'condition'}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '74'], 'value': '=='}, {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'get_atomic_numbers'}, {'id': '73', 'type': 'argument_list', 'children': []}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'atomtype'}, {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'pos_onetype'}; {'id': '78', 'type': 'subscript', 'children': ['79', '84']}, {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'get_positions'}, {'id': '83', 'type': 'argument_list', 'children': []}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'condition'}, {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'n_onetype'}; {'id': '88', 'type': 'subscript', 'children': ['89', '92']}, {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'pos_onetype'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '92', 'type': 'integer', 'children': [], 'value': '0'}, {'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': 'pos_lst'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'pos_onetype'}; {'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': 'n_atoms_per_type_lst'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'n_onetype'}, {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'typeNs'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'n_atoms_per_type_lst'}, {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'assignment', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'Ntypes'}; {'id': '114', 'type': 'call', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'n_atoms_per_type_lst'}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'atomtype_lst'}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}, {'id': '121', 'type': 'assignment', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'Apos'}, {'id': '123', 'type': 'call', 'children': ['124', '132']}; {'id': '124', 'type': 'attribute', 'children': ['125', '131']}, {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'concatenate'}, {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'pos_lst'}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'ravel'}; {'id': '132', 'type': 'argument_list', 'children': []}, {'id': '133', 'type': 'return_statement', 'children': ['134']}; {'id': '134', 'type': 'expression_list', 'children': ['135', '136', '137', '138', '139']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'Apos'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'typeNs'}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'Ntypes'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'atomtype_lst'}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'totalAN'}
def _format_ase2clusgeo(obj, all_atomtypes=None): totalAN = len(obj) if all_atomtypes is not None: atomtype_set = set(all_atomtypes) else: atomtype_set = set(obj.get_atomic_numbers()) atomtype_lst = np.sort(list(atomtype_set)) n_atoms_per_type_lst = [] pos_lst = [] for atomtype in atomtype_lst: condition = obj.get_atomic_numbers() == atomtype pos_onetype = obj.get_positions()[condition] n_onetype = pos_onetype.shape[0] pos_lst.append(pos_onetype) n_atoms_per_type_lst.append(n_onetype) typeNs = n_atoms_per_type_lst Ntypes = len(n_atoms_per_type_lst) atomtype_lst Apos = np.concatenate(pos_lst).ravel() return Apos, typeNs, Ntypes, atomtype_lst, totalAN
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zmax'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '13', '16', '19']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'return_times'}, {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'mean'}, {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'interp_kwargs'}, {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'default_parameter', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'minimize_kwargs'}; {'id': '18', 'type': 'None', 'children': []}, {'id': '19', 'type': 'default_parameter', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'approximate'}, {'id': '21', 'type': 'False', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23', '39', '61', '85', '89', '93', '147']}, {'id': '23', 'type': 'if_statement', 'children': ['24', '29']}; {'id': '24', 'type': 'boolean_operator', 'children': ['25', '26'], 'value': 'and'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'return_times'}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'is'}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '28', 'type': 'None', 'children': []}, {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'raise_statement', 'children': ['31']}, {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'concatenated_string', 'children': ['35', '36', '37', '38']}, {'id': '35', 'type': 'string', 'children': [], 'value': '"Cannot return times if reducing "'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"using an input function. Pass `func=None` if "'}, {'id': '37', 'type': 'string', 'children': [], 'value': '"you want to return all individual values "'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"and times."'}, {'id': '39', 'type': 'if_statement', 'children': ['40', '43', '55']}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '42'], 'value': 'is'}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '42', 'type': 'None', 'children': []}, {'id': '43', 'type': 'block', 'children': ['44', '48']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}, {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'reduce'}, {'id': '47', 'type': 'False', 'children': []}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}, {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'func'}, {'id': '51', 'type': 'lambda', 'children': ['52', '54']}; {'id': '52', 'type': 'lambda_parameters', 'children': ['53']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '55', 'type': 'else_clause', 'children': ['56']}; {'id': '56', 'type': 'block', 'children': ['57']}, {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'reduce'}; {'id': '60', 'type': 'True', 'children': []}, {'id': '61', 'type': 'if_statement', 'children': ['62', '74']}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '69'], 'value': '<'}, {'id': '63', 'type': 'subscript', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '67', 'type': 'unary_operator', 'children': ['68'], 'value': '-'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '69', 'type': 'subscript', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '73', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '74', 'type': 'block', 'children': ['75']}, {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'subscript', 'children': ['79', '80']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'slice', 'children': ['81', '82', '83']}, {'id': '81', 'type': 'colon', 'children': []}; {'id': '82', 'type': 'colon', 'children': []}, {'id': '83', 'type': 'unary_operator', 'children': ['84'], 'value': '-'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '88', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'times'}; {'id': '92', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '93', 'type': 'for_statement', 'children': ['94', '95', '100']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'orbit'}, {'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': 'orbit_gen'}, {'id': '99', 'type': 'argument_list', 'children': []}; {'id': '100', 'type': 'block', 'children': ['101', '130', '140']}, {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '106']}, {'id': '103', 'type': 'pattern_list', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '106', 'type': 'call', 'children': ['107', '110']}, {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'orbit'}, {'id': '109', 'type': 'identifier', 'children': [], 'value': '_max_helper'}; {'id': '110', 'type': 'argument_list', 'children': ['111', '121', '124', '127']}, {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'abs'}, {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'attribute', 'children': ['117', '120']}, {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'orbit'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'cylindrical'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'z'}, {'id': '121', 'type': 'keyword_argument', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'interp_kwargs'}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'interp_kwargs'}; {'id': '124', 'type': 'keyword_argument', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'minimize_kwargs'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'minimize_kwargs'}, {'id': '127', 'type': 'keyword_argument', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'approximate'}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'approximate'}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}, {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'call', 'children': ['137', '138']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '138', 'type': 'argument_list', 'children': ['139']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '140', 'type': 'expression_statement', 'children': ['141']}, {'id': '141', 'type': 'call', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'times'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '147', 'type': 'return_statement', 'children': ['148']}; {'id': '148', 'type': 'call', 'children': ['149', '152']}, {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': '_max_return_helper'}; {'id': '152', 'type': 'argument_list', 'children': ['153', '154', '155', '156']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'times'}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'return_times'}
def zmax(self, return_times=False, func=np.mean, interp_kwargs=None, minimize_kwargs=None, approximate=False): if return_times and func is not None: raise ValueError("Cannot return times if reducing " "using an input function. Pass `func=None` if " "you want to return all individual values " "and times.") if func is None: reduce = False func = lambda x: x else: reduce = True if self.t[-1] < self.t[0]: self = self[::-1] vals = [] times = [] for orbit in self.orbit_gen(): v, t = orbit._max_helper(np.abs(orbit.cylindrical.z), interp_kwargs=interp_kwargs, minimize_kwargs=minimize_kwargs, approximate=approximate) vals.append(func(v)) times.append(t) return self._max_return_helper(vals, times, return_times, reduce)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'align_circulation_with_z'}, {'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': 'circulation'}, {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '22', '32', '38', '44', '80', '105', '137', '145', '153', '294']}, {'id': '9', 'type': 'if_statement', 'children': ['10', '13']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'is'}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'circulation'}; {'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': 'circulation'}, {'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': 'circulation'}, {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}, {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'circulation'}, {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'atleast_2d'}, {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'circulation'}, {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'insert_axis'}, {'id': '31', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}, {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'cart'}, {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'cartesian'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}, {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'pos'}, {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'cart'}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'xyz'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}, {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'vel'}, {'id': '47', 'type': 'binary_operator', 'children': ['48', '75'], 'value': '*'}; {'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': 'vstack'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}, {'id': '53', 'type': 'tuple', 'children': ['54', '61', '68']}; {'id': '54', 'type': 'subscript', 'children': ['55', '60']}, {'id': '55', 'type': 'attribute', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'cart'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'v_x'}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '60', 'type': 'None', 'children': []}, {'id': '61', 'type': 'subscript', 'children': ['62', '67']}; {'id': '62', 'type': 'attribute', 'children': ['63', '66']}, {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'cart'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'v_y'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '67', 'type': 'None', 'children': []}; {'id': '68', 'type': 'subscript', 'children': ['69', '74']}, {'id': '69', 'type': 'attribute', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'cart'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'v_z'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '74', 'type': 'None', 'children': []}, {'id': '75', 'type': 'attribute', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'cart'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'v_x'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '80', 'type': 'if_statement', 'children': ['81', '86']}, {'id': '81', 'type': 'comparison_operator', 'children': ['82', '85'], 'value': '<'}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'ndim'}, {'id': '85', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '86', 'type': 'block', 'children': ['87', '96']}, {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '90', 'type': 'subscript', 'children': ['91', '92', '93']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '92', 'type': 'ellipsis', 'children': [], 'value': '...'}, {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'newaxis'}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}, {'id': '97', 'type': 'assignment', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'vel'}, {'id': '99', 'type': 'subscript', 'children': ['100', '101', '102']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'vel'}, {'id': '101', 'type': 'ellipsis', 'children': [], 'value': '...'}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'newaxis'}, {'id': '105', 'type': 'if_statement', 'children': ['106', '128']}; {'id': '106', 'type': 'parenthesized_expression', 'children': ['107']}, {'id': '107', 'type': 'boolean_operator', 'children': ['108', '117'], 'value': 'or'}; {'id': '108', 'type': 'comparison_operator', 'children': ['109', '114'], 'value': '!='}, {'id': '109', 'type': 'subscript', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'circulation'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'shape'}, {'id': '113', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'ndim'}, {'id': '117', 'type': 'comparison_operator', 'children': ['118', '123'], 'value': '!='}; {'id': '118', 'type': 'subscript', 'children': ['119', '122']}, {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'circulation'}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '122', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '123', 'type': 'subscript', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'shape'}, {'id': '127', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '128', 'type': 'block', 'children': ['129']}, {'id': '129', 'type': 'raise_statement', 'children': ['130']}; {'id': '130', 'type': 'call', 'children': ['131', '132']}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '132', 'type': 'argument_list', 'children': ['133']}, {'id': '133', 'type': 'concatenated_string', 'children': ['134', '135', '136']}; {'id': '134', 'type': 'string', 'children': [], 'value': '"Shape of \'circulation\' array should match the "'}, {'id': '135', 'type': 'string', 'children': [], 'value': '"shape of the position/velocity (minus the time "'}; {'id': '136', 'type': 'string', 'children': [], 'value': '"axis)."'}, {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'assignment', 'children': ['139', '140']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'new_pos'}; {'id': '140', 'type': 'call', 'children': ['141', '144']}, {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'pos'}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '144', 'type': 'argument_list', 'children': []}, {'id': '145', 'type': 'expression_statement', 'children': ['146']}; {'id': '146', 'type': 'assignment', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'new_vel'}; {'id': '148', 'type': 'call', 'children': ['149', '152']}, {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'vel'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '152', 'type': 'argument_list', 'children': []}, {'id': '153', 'type': 'for_statement', 'children': ['154', '155', '163']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '155', 'type': 'call', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'range'}, {'id': '157', 'type': 'argument_list', 'children': ['158']}; {'id': '158', 'type': 'subscript', 'children': ['159', '162']}, {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'pos'}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '162', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '163', 'type': 'block', 'children': ['164', '186', '207', '238', '252', '266', '280']}; {'id': '164', 'type': 'if_statement', 'children': ['165', '184']}, {'id': '165', 'type': 'boolean_operator', 'children': ['166', '172'], 'value': 'or'}; {'id': '166', 'type': 'comparison_operator', 'children': ['167', '171'], 'value': '=='}, {'id': '167', 'type': 'subscript', 'children': ['168', '169', '170']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'circulation'}, {'id': '169', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '171', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '172', 'type': 'call', 'children': ['173', '176']}, {'id': '173', 'type': 'attribute', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '176', 'type': 'argument_list', 'children': ['177']}, {'id': '177', 'type': 'comparison_operator', 'children': ['178', '183'], 'value': '=='}; {'id': '178', 'type': 'subscript', 'children': ['179', '180', '182']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'circulation'}; {'id': '180', 'type': 'slice', 'children': ['181']}, {'id': '181', 'type': 'colon', 'children': []}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '183', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '184', 'type': 'block', 'children': ['185']}, {'id': '185', 'type': 'continue_statement', 'children': []}; {'id': '186', 'type': 'if_statement', 'children': ['187', '197']}, {'id': '187', 'type': 'comparison_operator', 'children': ['188', '196'], 'value': '>'}; {'id': '188', 'type': 'call', 'children': ['189', '190']}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '190', 'type': 'argument_list', 'children': ['191']}, {'id': '191', 'type': 'subscript', 'children': ['192', '193', '195']}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'circulation'}, {'id': '193', 'type': 'slice', 'children': ['194']}; {'id': '194', 'type': 'colon', 'children': []}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '196', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '197', 'type': 'block', 'children': ['198']}; {'id': '198', 'type': 'expression_statement', 'children': ['199']}, {'id': '199', 'type': 'call', 'children': ['200', '203']}; {'id': '200', 'type': 'attribute', 'children': ['201', '202']}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'warning'}, {'id': '203', 'type': 'argument_list', 'children': ['204']}; {'id': '204', 'type': 'concatenated_string', 'children': ['205', '206']}, {'id': '205', 'type': 'string', 'children': [], 'value': '"Circulation about multiple axes - are you sure "'}; {'id': '206', 'type': 'string', 'children': [], 'value': '"the orbit has been integrated for long enough?"'}, {'id': '207', 'type': 'if_statement', 'children': ['208', '214', '219', '231']}; {'id': '208', 'type': 'comparison_operator', 'children': ['209', '213'], 'value': '=='}, {'id': '209', 'type': 'subscript', 'children': ['210', '211', '212']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'circulation'}, {'id': '211', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '213', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '214', 'type': 'block', 'children': ['215']}, {'id': '215', 'type': 'expression_statement', 'children': ['216']}; {'id': '216', 'type': 'assignment', 'children': ['217', '218']}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'circ'}; {'id': '218', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '219', 'type': 'elif_clause', 'children': ['220', '226']}; {'id': '220', 'type': 'comparison_operator', 'children': ['221', '225'], 'value': '=='}, {'id': '221', 'type': 'subscript', 'children': ['222', '223', '224']}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'circulation'}, {'id': '223', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '225', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '226', 'type': 'block', 'children': ['227']}, {'id': '227', 'type': 'expression_statement', 'children': ['228']}; {'id': '228', 'type': 'assignment', 'children': ['229', '230']}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'circ'}; {'id': '230', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '231', 'type': 'else_clause', 'children': ['232']}; {'id': '232', 'type': 'block', 'children': ['233']}, {'id': '233', 'type': 'raise_statement', 'children': ['234']}; {'id': '234', 'type': 'call', 'children': ['235', '236']}, {'id': '235', 'type': 'identifier', 'children': [], 'value': 'RuntimeError'}; {'id': '236', 'type': 'argument_list', 'children': ['237']}, {'id': '237', 'type': 'string', 'children': [], 'value': '"Should never get here..."'}; {'id': '238', 'type': 'expression_statement', 'children': ['239']}, {'id': '239', 'type': 'assignment', 'children': ['240', '246']}; {'id': '240', 'type': 'subscript', 'children': ['241', '242', '243', '245']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'new_pos'}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'circ'}, {'id': '243', 'type': 'slice', 'children': ['244']}; {'id': '244', 'type': 'colon', 'children': []}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '246', 'type': 'subscript', 'children': ['247', '248', '249', '251']}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '248', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '249', 'type': 'slice', 'children': ['250']}; {'id': '250', 'type': 'colon', 'children': []}, {'id': '251', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '252', 'type': 'expression_statement', 'children': ['253']}, {'id': '253', 'type': 'assignment', 'children': ['254', '260']}; {'id': '254', 'type': 'subscript', 'children': ['255', '256', '257', '259']}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'new_pos'}; {'id': '256', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '257', 'type': 'slice', 'children': ['258']}; {'id': '258', 'type': 'colon', 'children': []}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '260', 'type': 'subscript', 'children': ['261', '262', '263', '265']}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '262', 'type': 'identifier', 'children': [], 'value': 'circ'}, {'id': '263', 'type': 'slice', 'children': ['264']}; {'id': '264', 'type': 'colon', 'children': []}, {'id': '265', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '266', 'type': 'expression_statement', 'children': ['267']}, {'id': '267', 'type': 'assignment', 'children': ['268', '274']}; {'id': '268', 'type': 'subscript', 'children': ['269', '270', '271', '273']}, {'id': '269', 'type': 'identifier', 'children': [], 'value': 'new_vel'}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'circ'}, {'id': '271', 'type': 'slice', 'children': ['272']}; {'id': '272', 'type': 'colon', 'children': []}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '274', 'type': 'subscript', 'children': ['275', '276', '277', '279']}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 'vel'}; {'id': '276', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '277', 'type': 'slice', 'children': ['278']}; {'id': '278', 'type': 'colon', 'children': []}, {'id': '279', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '280', 'type': 'expression_statement', 'children': ['281']}, {'id': '281', 'type': 'assignment', 'children': ['282', '288']}; {'id': '282', 'type': 'subscript', 'children': ['283', '284', '285', '287']}, {'id': '283', 'type': 'identifier', 'children': [], 'value': 'new_vel'}; {'id': '284', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '285', 'type': 'slice', 'children': ['286']}; {'id': '286', 'type': 'colon', 'children': []}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '288', 'type': 'subscript', 'children': ['289', '290', '291', '293']}, {'id': '289', 'type': 'identifier', 'children': [], 'value': 'vel'}; {'id': '290', 'type': 'identifier', 'children': [], 'value': 'circ'}, {'id': '291', 'type': 'slice', 'children': ['292']}; {'id': '292', 'type': 'colon', 'children': []}, {'id': '293', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '294', 'type': 'return_statement', 'children': ['295']}, {'id': '295', 'type': 'call', 'children': ['296', '299']}; {'id': '296', 'type': 'attribute', 'children': ['297', '298']}, {'id': '297', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '298', 'type': 'identifier', 'children': [], 'value': '__class__'}, {'id': '299', 'type': 'argument_list', 'children': ['300', '312', '324', '329']}; {'id': '300', 'type': 'keyword_argument', 'children': ['301', '302']}, {'id': '301', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '302', 'type': 'call', 'children': ['303', '306']}, {'id': '303', 'type': 'attribute', 'children': ['304', '305']}; {'id': '304', 'type': 'identifier', 'children': [], 'value': 'new_pos'}, {'id': '305', 'type': 'identifier', 'children': [], 'value': 'reshape'}; {'id': '306', 'type': 'argument_list', 'children': ['307']}, {'id': '307', 'type': 'attribute', 'children': ['308', '311']}; {'id': '308', 'type': 'attribute', 'children': ['309', '310']}, {'id': '309', 'type': 'identifier', 'children': [], 'value': 'cart'}; {'id': '310', 'type': 'identifier', 'children': [], 'value': 'xyz'}, {'id': '311', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '312', 'type': 'keyword_argument', 'children': ['313', '314']}, {'id': '313', 'type': 'identifier', 'children': [], 'value': 'vel'}; {'id': '314', 'type': 'call', 'children': ['315', '318']}, {'id': '315', 'type': 'attribute', 'children': ['316', '317']}; {'id': '316', 'type': 'identifier', 'children': [], 'value': 'new_vel'}, {'id': '317', 'type': 'identifier', 'children': [], 'value': 'reshape'}; {'id': '318', 'type': 'argument_list', 'children': ['319']}, {'id': '319', 'type': 'attribute', 'children': ['320', '323']}; {'id': '320', 'type': 'attribute', 'children': ['321', '322']}, {'id': '321', 'type': 'identifier', 'children': [], 'value': 'cart'}; {'id': '322', 'type': 'identifier', 'children': [], 'value': 'xyz'}, {'id': '323', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '324', 'type': 'keyword_argument', 'children': ['325', '326']}, {'id': '325', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '326', 'type': 'attribute', 'children': ['327', '328']}, {'id': '327', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '328', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '329', 'type': 'keyword_argument', 'children': ['330', '331']}; {'id': '330', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}, {'id': '331', 'type': 'attribute', 'children': ['332', '333']}; {'id': '332', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '333', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}
def align_circulation_with_z(self, circulation=None): if circulation is None: circulation = self.circulation() circulation = atleast_2d(circulation, insert_axis=1) cart = self.cartesian pos = cart.xyz vel = np.vstack((cart.v_x.value[None], cart.v_y.value[None], cart.v_z.value[None])) * cart.v_x.unit if pos.ndim < 3: pos = pos[...,np.newaxis] vel = vel[...,np.newaxis] if (circulation.shape[0] != self.ndim or circulation.shape[1] != pos.shape[2]): raise ValueError("Shape of 'circulation' array should match the " "shape of the position/velocity (minus the time " "axis).") new_pos = pos.copy() new_vel = vel.copy() for n in range(pos.shape[2]): if circulation[2,n] == 1 or np.all(circulation[:,n] == 0): continue if sum(circulation[:,n]) > 1: logger.warning("Circulation about multiple axes - are you sure " "the orbit has been integrated for long enough?") if circulation[0,n] == 1: circ = 0 elif circulation[1,n] == 1: circ = 1 else: raise RuntimeError("Should never get here...") new_pos[circ,:,n] = pos[2,:,n] new_pos[2,:,n] = pos[circ,:,n] new_vel[circ,:,n] = vel[2,:,n] new_vel[2,:,n] = vel[circ,:,n] return self.__class__(pos=new_pos.reshape(cart.xyz.shape), vel=new_vel.reshape(cart.xyz.shape), t=self.t, hamiltonian=self.hamiltonian)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '32']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fast_lyapunov_max'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11', '14', '17', '20', '23', '26', '29']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'w0'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'dt'}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'n_steps'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'd0'}; {'id': '10', 'type': 'float', 'children': [], 'value': '1e-5'}, {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'n_steps_per_pullback'}, {'id': '13', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'noffset_orbits'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 't1'}, {'id': '19', 'type': 'float', 'children': [], 'value': '0.'}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'atol'}; {'id': '22', 'type': 'float', 'children': [], 'value': '1E-10'}, {'id': '23', 'type': 'default_parameter', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'rtol'}, {'id': '25', 'type': 'float', 'children': [], 'value': '1E-10'}; {'id': '26', 'type': 'default_parameter', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'nmax'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '29', 'type': 'default_parameter', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'return_orbit'}, {'id': '31', 'type': 'True', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33', '42', '63', '76', '123', '139', '151']}, {'id': '33', 'type': 'import_from_statement', 'children': ['34', '38', '40']}; {'id': '34', 'type': 'relative_import', 'children': ['35', '36']}, {'id': '35', 'type': 'import_prefix', 'children': []}; {'id': '36', 'type': 'dotted_name', 'children': ['37']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'lyapunov'}; {'id': '38', 'type': 'dotted_name', 'children': ['39']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'dop853_lyapunov_max'}; {'id': '40', 'type': 'dotted_name', 'children': ['41']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'dop853_lyapunov_max_dont_save'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '48']}, {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'isinstance'}, {'id': '45', 'type': 'argument_list', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'PotentialBase'}; {'id': '48', 'type': 'block', 'children': ['49', '56']}, {'id': '49', 'type': 'import_from_statement', 'children': ['50', '54']}; {'id': '50', 'type': 'relative_import', 'children': ['51', '52']}, {'id': '51', 'type': 'import_prefix', 'children': []}; {'id': '52', 'type': 'dotted_name', 'children': ['53']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'potential'}; {'id': '54', 'type': 'dotted_name', 'children': ['55']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'Hamiltonian'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}, {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}, {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'Hamiltonian'}, {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}, {'id': '63', 'type': 'if_statement', 'children': ['64', '68']}; {'id': '64', 'type': 'not_operator', 'children': ['65']}, {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'c_enabled'}; {'id': '68', 'type': 'block', 'children': ['69']}, {'id': '69', 'type': 'raise_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}, {'id': '73', 'type': 'concatenated_string', 'children': ['74', '75']}; {'id': '74', 'type': 'string', 'children': [], 'value': '"Input Hamiltonian must contain a C-implemented "'}, {'id': '75', 'type': 'string', 'children': [], 'value': '"potential and frame."'}; {'id': '76', 'type': 'if_statement', 'children': ['77', '83']}, {'id': '77', 'type': 'not_operator', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '80']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'w0'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'PhaseSpacePosition'}, {'id': '83', 'type': 'block', 'children': ['84', '93', '103']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}, {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'w0'}, {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'asarray'}, {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'w0'}, {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'ndim'}; {'id': '96', 'type': 'binary_operator', 'children': ['97', '102'], 'value': '//'}, {'id': '97', 'type': 'subscript', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'w0'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'shape'}, {'id': '101', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '102', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'assignment', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'w0'}; {'id': '106', 'type': 'call', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'PhaseSpacePosition'}; {'id': '108', 'type': 'argument_list', 'children': ['109', '116']}, {'id': '109', 'type': 'keyword_argument', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'pos'}, {'id': '111', 'type': 'subscript', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'w0'}, {'id': '113', 'type': 'slice', 'children': ['114', '115']}; {'id': '114', 'type': 'colon', 'children': []}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'ndim'}; {'id': '116', 'type': 'keyword_argument', 'children': ['117', '118']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'vel'}; {'id': '118', 'type': 'subscript', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'w0'}; {'id': '120', 'type': 'slice', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'ndim'}; {'id': '122', 'type': 'colon', 'children': []}, {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': '_w0'}; {'id': '126', 'type': 'call', 'children': ['127', '130']}, {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'squeeze'}; {'id': '130', 'type': 'argument_list', 'children': ['131']}, {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'w0'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'w'}, {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'units'}, {'id': '139', 'type': 'if_statement', 'children': ['140', '145']}; {'id': '140', 'type': 'comparison_operator', 'children': ['141', '144'], 'value': '>'}, {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': '_w0'}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'ndim'}; {'id': '144', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '145', 'type': 'block', 'children': ['146']}; {'id': '146', 'type': 'raise_statement', 'children': ['147']}, {'id': '147', 'type': 'call', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'string', 'children': [], 'value': '"Can only compute fast Lyapunov exponent for a single orbit."'}, {'id': '151', 'type': 'if_statement', 'children': ['152', '153', '238']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'return_orbit'}, {'id': '153', 'type': 'block', 'children': ['154', '176', '187', '208', '232']}; {'id': '154', 'type': 'expression_statement', 'children': ['155']}, {'id': '155', 'type': 'assignment', 'children': ['156', '160']}; {'id': '156', 'type': 'pattern_list', 'children': ['157', '158', '159']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'w'}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '160', 'type': 'call', 'children': ['161', '162']}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'dop853_lyapunov_max'}; {'id': '162', 'type': 'argument_list', 'children': ['163', '164', '165', '166', '169', '170', '171', '172', '173', '174', '175']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': '_w0'}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '166', 'type': 'binary_operator', 'children': ['167', '168'], 'value': '+'}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'n_steps'}; {'id': '168', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 't1'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'd0'}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'n_steps_per_pullback'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'noffset_orbits'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'atol'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'rtol'}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'nmax'}; {'id': '176', 'type': 'expression_statement', 'children': ['177']}, {'id': '177', 'type': 'assignment', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'w'}, {'id': '179', 'type': 'call', 'children': ['180', '183']}; {'id': '180', 'type': 'attribute', 'children': ['181', '182']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'rollaxis'}, {'id': '183', 'type': 'argument_list', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'w'}, {'id': '185', 'type': 'unary_operator', 'children': ['186'], 'value': '-'}; {'id': '186', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '187', 'type': 'try_statement', 'children': ['188', '197']}; {'id': '188', 'type': 'block', 'children': ['189']}, {'id': '189', 'type': 'expression_statement', 'children': ['190']}; {'id': '190', 'type': 'assignment', 'children': ['191', '192']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'tunit'}; {'id': '192', 'type': 'subscript', 'children': ['193', '196']}, {'id': '193', 'type': 'attribute', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '196', 'type': 'string', 'children': [], 'value': "'time'"}, {'id': '197', 'type': 'except_clause', 'children': ['198', '201']}; {'id': '198', 'type': 'tuple', 'children': ['199', '200']}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}, {'id': '201', 'type': 'block', 'children': ['202']}; {'id': '202', 'type': 'expression_statement', 'children': ['203']}, {'id': '203', 'type': 'assignment', 'children': ['204', '205']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'tunit'}, {'id': '205', 'type': 'attribute', 'children': ['206', '207']}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'u'}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'dimensionless_unscaled'}; {'id': '208', 'type': 'expression_statement', 'children': ['209']}, {'id': '209', 'type': 'assignment', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'orbit'}, {'id': '211', 'type': 'call', 'children': ['212', '215']}; {'id': '212', 'type': 'attribute', 'children': ['213', '214']}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'Orbit'}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'from_w'}, {'id': '215', 'type': 'argument_list', 'children': ['216', '219', '224', '229']}; {'id': '216', 'type': 'keyword_argument', 'children': ['217', '218']}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'w'}, {'id': '219', 'type': 'keyword_argument', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'units'}, {'id': '221', 'type': 'attribute', 'children': ['222', '223']}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '224', 'type': 'keyword_argument', 'children': ['225', '226']}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '226', 'type': 'binary_operator', 'children': ['227', '228'], 'value': '*'}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'tunit'}, {'id': '229', 'type': 'keyword_argument', 'children': ['230', '231']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}; {'id': '232', 'type': 'return_statement', 'children': ['233']}, {'id': '233', 'type': 'expression_list', 'children': ['234', '237']}; {'id': '234', 'type': 'binary_operator', 'children': ['235', '236'], 'value': '/'}, {'id': '235', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'tunit'}, {'id': '237', 'type': 'identifier', 'children': [], 'value': 'orbit'}; {'id': '238', 'type': 'else_clause', 'children': ['239']}, {'id': '239', 'type': 'block', 'children': ['240', '259', '280']}; {'id': '240', 'type': 'expression_statement', 'children': ['241']}, {'id': '241', 'type': 'assignment', 'children': ['242', '243']}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'l'}, {'id': '243', 'type': 'call', 'children': ['244', '245']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'dop853_lyapunov_max_dont_save'}, {'id': '245', 'type': 'argument_list', 'children': ['246', '247', '248', '249', '252', '253', '254', '255', '256', '257', '258']}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}, {'id': '247', 'type': 'identifier', 'children': [], 'value': '_w0'}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 'dt'}, {'id': '249', 'type': 'binary_operator', 'children': ['250', '251'], 'value': '+'}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'n_steps'}, {'id': '251', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 't1'}, {'id': '253', 'type': 'identifier', 'children': [], 'value': 'd0'}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'n_steps_per_pullback'}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'noffset_orbits'}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'atol'}, {'id': '257', 'type': 'identifier', 'children': [], 'value': 'rtol'}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'nmax'}, {'id': '259', 'type': 'try_statement', 'children': ['260', '269']}; {'id': '260', 'type': 'block', 'children': ['261']}, {'id': '261', 'type': 'expression_statement', 'children': ['262']}; {'id': '262', 'type': 'assignment', 'children': ['263', '264']}, {'id': '263', 'type': 'identifier', 'children': [], 'value': 'tunit'}; {'id': '264', 'type': 'subscript', 'children': ['265', '268']}, {'id': '265', 'type': 'attribute', 'children': ['266', '267']}; {'id': '266', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '268', 'type': 'string', 'children': [], 'value': "'time'"}, {'id': '269', 'type': 'except_clause', 'children': ['270', '273']}; {'id': '270', 'type': 'tuple', 'children': ['271', '272']}, {'id': '271', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '272', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}, {'id': '273', 'type': 'block', 'children': ['274']}; {'id': '274', 'type': 'expression_statement', 'children': ['275']}, {'id': '275', 'type': 'assignment', 'children': ['276', '277']}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'tunit'}, {'id': '277', 'type': 'attribute', 'children': ['278', '279']}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'u'}, {'id': '279', 'type': 'identifier', 'children': [], 'value': 'dimensionless_unscaled'}; {'id': '280', 'type': 'return_statement', 'children': ['281']}, {'id': '281', 'type': 'binary_operator', 'children': ['282', '283'], 'value': '/'}; {'id': '282', 'type': 'identifier', 'children': [], 'value': 'l'}, {'id': '283', 'type': 'identifier', 'children': [], 'value': 'tunit'}
def fast_lyapunov_max(w0, hamiltonian, dt, n_steps, d0=1e-5, n_steps_per_pullback=10, noffset_orbits=2, t1=0., atol=1E-10, rtol=1E-10, nmax=0, return_orbit=True): from .lyapunov import dop853_lyapunov_max, dop853_lyapunov_max_dont_save if isinstance(hamiltonian, PotentialBase): from ..potential import Hamiltonian hamiltonian = Hamiltonian(hamiltonian) if not hamiltonian.c_enabled: raise TypeError("Input Hamiltonian must contain a C-implemented " "potential and frame.") if not isinstance(w0, PhaseSpacePosition): w0 = np.asarray(w0) ndim = w0.shape[0]//2 w0 = PhaseSpacePosition(pos=w0[:ndim], vel=w0[ndim:]) _w0 = np.squeeze(w0.w(hamiltonian.units)) if _w0.ndim > 1: raise ValueError("Can only compute fast Lyapunov exponent for a single orbit.") if return_orbit: t,w,l = dop853_lyapunov_max(hamiltonian, _w0, dt, n_steps+1, t1, d0, n_steps_per_pullback, noffset_orbits, atol, rtol, nmax) w = np.rollaxis(w, -1) try: tunit = hamiltonian.units['time'] except (TypeError, AttributeError): tunit = u.dimensionless_unscaled orbit = Orbit.from_w(w=w, units=hamiltonian.units, t=t*tunit, hamiltonian=hamiltonian) return l/tunit, orbit else: l = dop853_lyapunov_max_dont_save(hamiltonian, _w0, dt, n_steps+1, t1, d0, n_steps_per_pullback, noffset_orbits, atol, rtol, nmax) try: tunit = hamiltonian.units['time'] except (TypeError, AttributeError): tunit = u.dimensionless_unscaled return l/tunit
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'estimate_dt_n_steps'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11', '16']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'w0'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'n_periods'}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'n_steps_per_period'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'dE_threshold'}; {'id': '10', 'type': 'float', 'children': [], 'value': '1E-9'}, {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'func'}, {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'nanmax'}; {'id': '16', 'type': 'dictionary_splat_pattern', 'children': ['17']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'integrate_kwargs'}; {'id': '18', 'type': 'block', 'children': ['19', '50', '63', '75', '92', '100', '215', '222', '235', '248', '257', '271', '285']}, {'id': '19', 'type': 'if_statement', 'children': ['20', '26']}; {'id': '20', 'type': 'not_operator', 'children': ['21']}, {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'isinstance'}, {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'w0'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'PhaseSpacePosition'}; {'id': '26', 'type': 'block', 'children': ['27', '36']}, {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'w0'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}, {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'w0'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}, {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'w0'}, {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'PhaseSpacePosition'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'from_w'}, {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'w0'}, {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'units'}, {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}, {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'dt'}, {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_autodetermine_initial_dt'}, {'id': '55', 'type': 'argument_list', 'children': ['56', '57', '58', '61']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'w0'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'dE_threshold'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'dE_threshold'}, {'id': '61', 'type': 'dictionary_splat', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'integrate_kwargs'}, {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'n_steps'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}, {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'round'}, {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'binary_operator', 'children': ['73', '74'], 'value': '/'}, {'id': '73', 'type': 'integer', 'children': [], 'value': '10000'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'dt'}, {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'orbit'}; {'id': '78', 'type': 'call', 'children': ['79', '82']}, {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'integrate_orbit'}; {'id': '82', 'type': 'argument_list', 'children': ['83', '84', '87', '90']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'w0'}; {'id': '84', 'type': 'keyword_argument', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'dt'}, {'id': '87', 'type': 'keyword_argument', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'n_steps'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'n_steps'}; {'id': '90', 'type': 'dictionary_splat', 'children': ['91']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'integrate_kwargs'}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}, {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'circ'}, {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'orbit'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'circulation'}, {'id': '99', 'type': 'argument_list', 'children': []}; {'id': '100', 'type': 'if_statement', 'children': ['101', '107', '184']}, {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'any'}, {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'circ'}, {'id': '107', 'type': 'block', 'children': ['108', '119', '130', '138', '146', '154']}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}, {'id': '109', 'type': 'assignment', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'orbit'}, {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'orbit'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'align_circulation_with_z'}, {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'keyword_argument', 'children': ['117', '118']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'circulation'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'circ'}, {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'assignment', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'cyl'}; {'id': '122', 'type': 'call', 'children': ['123', '126']}, {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'orbit'}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'represent_as'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}, {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'coord'}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'CylindricalRepresentation'}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}, {'id': '131', 'type': 'assignment', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'R'}, {'id': '133', 'type': 'attribute', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'cyl'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'rho'}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}, {'id': '139', 'type': 'assignment', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'phi'}, {'id': '141', 'type': 'attribute', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'cyl'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'phi'}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}, {'id': '147', 'type': 'assignment', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'z'}, {'id': '149', 'type': 'attribute', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'cyl'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'z'}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '154', 'type': 'expression_statement', 'children': ['155']}, {'id': '155', 'type': 'assignment', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'T'}, {'id': '157', 'type': 'binary_operator', 'children': ['158', '179'], 'value': '*'}; {'id': '158', 'type': 'call', 'children': ['159', '162']}, {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '162', 'type': 'argument_list', 'children': ['163']}, {'id': '163', 'type': 'list_comprehension', 'children': ['164', '173']}; {'id': '164', 'type': 'attribute', 'children': ['165', '172']}, {'id': '165', 'type': 'call', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'peak_to_peak_period'}, {'id': '167', 'type': 'argument_list', 'children': ['168', '171']}; {'id': '168', 'type': 'attribute', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'orbit'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '173', 'type': 'for_in_clause', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '175', 'type': 'list', 'children': ['176', '177', '178'], 'value': '[R, phi, z]'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'R'}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'phi'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'z'}, {'id': '179', 'type': 'attribute', 'children': ['180', '183']}; {'id': '180', 'type': 'attribute', 'children': ['181', '182']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'orbit'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '183', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '184', 'type': 'else_clause', 'children': ['185']}, {'id': '185', 'type': 'block', 'children': ['186']}; {'id': '186', 'type': 'expression_statement', 'children': ['187']}, {'id': '187', 'type': 'assignment', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'T'}, {'id': '189', 'type': 'binary_operator', 'children': ['190', '210'], 'value': '*'}; {'id': '190', 'type': 'call', 'children': ['191', '194']}, {'id': '191', 'type': 'attribute', 'children': ['192', '193']}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '194', 'type': 'argument_list', 'children': ['195']}, {'id': '195', 'type': 'list_comprehension', 'children': ['196', '205']}; {'id': '196', 'type': 'attribute', 'children': ['197', '204']}, {'id': '197', 'type': 'call', 'children': ['198', '199']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'peak_to_peak_period'}, {'id': '199', 'type': 'argument_list', 'children': ['200', '203']}; {'id': '200', 'type': 'attribute', 'children': ['201', '202']}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'orbit'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '205', 'type': 'for_in_clause', 'children': ['206', '207']}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '207', 'type': 'attribute', 'children': ['208', '209']}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'orbit'}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '210', 'type': 'attribute', 'children': ['211', '214']}, {'id': '211', 'type': 'attribute', 'children': ['212', '213']}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'orbit'}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'unit'}, {'id': '215', 'type': 'expression_statement', 'children': ['216']}; {'id': '216', 'type': 'assignment', 'children': ['217', '218']}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '218', 'type': 'call', 'children': ['219', '220']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '220', 'type': 'argument_list', 'children': ['221']}, {'id': '221', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '222', 'type': 'if_statement', 'children': ['223', '229']}, {'id': '223', 'type': 'call', 'children': ['224', '227']}; {'id': '224', 'type': 'attribute', 'children': ['225', '226']}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'isnan'}, {'id': '227', 'type': 'argument_list', 'children': ['228']}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'T'}, {'id': '229', 'type': 'block', 'children': ['230']}; {'id': '230', 'type': 'raise_statement', 'children': ['231']}, {'id': '231', 'type': 'call', 'children': ['232', '233']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'RuntimeError'}, {'id': '233', 'type': 'argument_list', 'children': ['234']}; {'id': '234', 'type': 'string', 'children': [], 'value': '"Failed to find period."'}, {'id': '235', 'type': 'expression_statement', 'children': ['236']}; {'id': '236', 'type': 'assignment', 'children': ['237', '238']}, {'id': '237', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '238', 'type': 'attribute', 'children': ['239', '247']}, {'id': '239', 'type': 'call', 'children': ['240', '243']}; {'id': '240', 'type': 'attribute', 'children': ['241', '242']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'decompose'}, {'id': '243', 'type': 'argument_list', 'children': ['244']}; {'id': '244', 'type': 'attribute', 'children': ['245', '246']}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'hamiltonian'}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'units'}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '248', 'type': 'expression_statement', 'children': ['249']}, {'id': '249', 'type': 'assignment', 'children': ['250', '251']}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'dt'}, {'id': '251', 'type': 'binary_operator', 'children': ['252', '253'], 'value': '/'}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'T'}, {'id': '253', 'type': 'call', 'children': ['254', '255']}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'float'}, {'id': '255', 'type': 'argument_list', 'children': ['256']}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'n_steps_per_period'}, {'id': '257', 'type': 'expression_statement', 'children': ['258']}; {'id': '258', 'type': 'assignment', 'children': ['259', '260']}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'n_steps'}; {'id': '260', 'type': 'call', 'children': ['261', '262']}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '262', 'type': 'argument_list', 'children': ['263']}, {'id': '263', 'type': 'call', 'children': ['264', '265']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'round'}, {'id': '265', 'type': 'argument_list', 'children': ['266']}; {'id': '266', 'type': 'binary_operator', 'children': ['267', '270'], 'value': '/'}, {'id': '267', 'type': 'binary_operator', 'children': ['268', '269'], 'value': '*'}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'n_periods'}, {'id': '269', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'dt'}, {'id': '271', 'type': 'if_statement', 'children': ['272', '279']}; {'id': '272', 'type': 'boolean_operator', 'children': ['273', '276'], 'value': 'or'}, {'id': '273', 'type': 'comparison_operator', 'children': ['274', '275'], 'value': '=='}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'dt'}, {'id': '275', 'type': 'float', 'children': [], 'value': '0.'}; {'id': '276', 'type': 'comparison_operator', 'children': ['277', '278'], 'value': '<'}, {'id': '277', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '278', 'type': 'float', 'children': [], 'value': '1E-13'}, {'id': '279', 'type': 'block', 'children': ['280']}; {'id': '280', 'type': 'raise_statement', 'children': ['281']}, {'id': '281', 'type': 'call', 'children': ['282', '283']}; {'id': '282', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '283', 'type': 'argument_list', 'children': ['284']}; {'id': '284', 'type': 'string', 'children': [], 'value': '"Timestep is zero or very small!"'}, {'id': '285', 'type': 'return_statement', 'children': ['286']}; {'id': '286', 'type': 'expression_list', 'children': ['287', '288']}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'dt'}
def estimate_dt_n_steps(w0, hamiltonian, n_periods, n_steps_per_period, dE_threshold=1E-9, func=np.nanmax, **integrate_kwargs): if not isinstance(w0, PhaseSpacePosition): w0 = np.asarray(w0) w0 = PhaseSpacePosition.from_w(w0, units=hamiltonian.units) dt = _autodetermine_initial_dt(w0, hamiltonian, dE_threshold=dE_threshold, **integrate_kwargs) n_steps = int(round(10000 / dt)) orbit = hamiltonian.integrate_orbit(w0, dt=dt, n_steps=n_steps, **integrate_kwargs) circ = orbit.circulation() if np.any(circ): orbit = orbit.align_circulation_with_z(circulation=circ) cyl = orbit.represent_as(coord.CylindricalRepresentation) R = cyl.rho.value phi = cyl.phi.value z = cyl.z.value T = np.array([peak_to_peak_period(orbit.t, f).value for f in [R, phi, z]])*orbit.t.unit else: T = np.array([peak_to_peak_period(orbit.t, f).value for f in orbit.pos])*orbit.t.unit T = func(T) if np.isnan(T): raise RuntimeError("Failed to find period.") T = T.decompose(hamiltonian.units).value dt = T / float(n_steps_per_period) n_steps = int(round(n_periods * T / dt)) if dt == 0. or dt < 1E-13: raise ValueError("Timestep is zero or very small!") return dt, n_steps
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '27']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plot_projections'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '19', '22', '25']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'relative_to'}, {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'autolim'}; {'id': '10', 'type': 'True', 'children': []}, {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'axes'}, {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'subplots_kwargs'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '18', 'type': 'argument_list', 'children': []}, {'id': '19', 'type': 'default_parameter', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'labels'}, {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'default_parameter', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'plot_function'}; {'id': '24', 'type': 'None', 'children': []}, {'id': '25', 'type': 'dictionary_splat_pattern', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'kwargs'}, {'id': '27', 'type': 'block', 'children': ['28', '40', '48', '65', '74', '80', '148', '152', '250', '260']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}, {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'array'}, {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'copy'}, {'id': '39', 'type': 'True', 'children': []}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}, {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'ndim'}, {'id': '43', 'type': 'subscript', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'shape'}, {'id': '47', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '52']}, {'id': '49', 'type': 'comparison_operator', 'children': ['50', '51'], 'value': 'is'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'axes'}, {'id': '51', 'type': 'None', 'children': []}; {'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': 'axes'}; {'id': '56', 'type': 'call', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': '_get_axes'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '62']}, {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'dim'}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'ndim'}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'subplots_kwargs'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'subplots_kwargs'}, {'id': '65', 'type': 'if_statement', 'children': ['66', '69']}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '68'], 'value': 'is'}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'relative_to'}; {'id': '68', 'type': 'None', 'children': []}, {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}, {'id': '71', 'type': 'augmented_assignment', 'children': ['72', '73'], 'value': '-='}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'relative_to'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}, {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'plot_fn_name'}, {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'plot_function'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '80', 'type': 'if_statement', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'autolim'}; {'id': '82', 'type': 'block', 'children': ['83', '87']}, {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'lims'}; {'id': '86', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '87', 'type': 'for_statement', 'children': ['88', '89', '93']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'range'}, {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'ndim'}, {'id': '93', 'type': 'block', 'children': ['94', '116', '122', '131']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}, {'id': '95', 'type': 'assignment', 'children': ['96', '99']}; {'id': '96', 'type': 'pattern_list', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'max_'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'min_'}, {'id': '99', 'type': 'expression_list', 'children': ['100', '108']}; {'id': '100', 'type': 'call', 'children': ['101', '104']}, {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}, {'id': '105', 'type': 'subscript', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '108', 'type': 'call', 'children': ['109', '112']}, {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}, {'id': '113', 'type': 'subscript', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}, {'id': '117', 'type': 'assignment', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'delta'}, {'id': '119', 'type': 'binary_operator', 'children': ['120', '121'], 'value': '-'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'max_'}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'min_'}; {'id': '122', 'type': 'if_statement', 'children': ['123', '126']}, {'id': '123', 'type': 'comparison_operator', 'children': ['124', '125'], 'value': '=='}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'delta'}, {'id': '125', 'type': 'float', 'children': [], 'value': '0.'}; {'id': '126', 'type': 'block', 'children': ['127']}, {'id': '127', 'type': 'expression_statement', 'children': ['128']}; {'id': '128', 'type': 'assignment', 'children': ['129', '130']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'delta'}; {'id': '130', 'type': 'float', 'children': [], 'value': '1.'}, {'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': 'lims'}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}, {'id': '137', 'type': 'list', 'children': ['138', '143'], 'value': '[min_ - delta*0.02, max_ + delta*0.02]'}; {'id': '138', 'type': 'binary_operator', 'children': ['139', '140'], 'value': '-'}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'min_'}; {'id': '140', 'type': 'binary_operator', 'children': ['141', '142'], 'value': '*'}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'delta'}; {'id': '142', 'type': 'float', 'children': [], 'value': '0.02'}, {'id': '143', 'type': 'binary_operator', 'children': ['144', '145'], 'value': '+'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'max_'}, {'id': '145', 'type': 'binary_operator', 'children': ['146', '147'], 'value': '*'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'delta'}, {'id': '147', 'type': 'float', 'children': [], 'value': '0.02'}; {'id': '148', 'type': 'expression_statement', 'children': ['149']}, {'id': '149', 'type': 'assignment', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'k'}, {'id': '151', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '152', 'type': 'for_statement', 'children': ['153', '154', '158']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '154', 'type': 'call', 'children': ['155', '156']}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'ndim'}; {'id': '158', 'type': 'block', 'children': ['159']}, {'id': '159', 'type': 'for_statement', 'children': ['160', '161', '165']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'j'}, {'id': '161', 'type': 'call', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'range'}, {'id': '163', 'type': 'argument_list', 'children': ['164']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'ndim'}, {'id': '165', 'type': 'block', 'children': ['166', '172', '182', '194', '221', '246']}; {'id': '166', 'type': 'if_statement', 'children': ['167', '170']}, {'id': '167', 'type': 'comparison_operator', 'children': ['168', '169'], 'value': '>='}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '170', 'type': 'block', 'children': ['171']}, {'id': '171', 'type': 'continue_statement', 'children': []}; {'id': '172', 'type': 'expression_statement', 'children': ['173']}, {'id': '173', 'type': 'assignment', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'plot_func'}, {'id': '175', 'type': 'call', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'getattr'}, {'id': '177', 'type': 'argument_list', 'children': ['178', '181']}; {'id': '178', 'type': 'subscript', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'axes'}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'k'}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'plot_fn_name'}; {'id': '182', 'type': 'expression_statement', 'children': ['183']}, {'id': '183', 'type': 'call', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'plot_func'}, {'id': '185', 'type': 'argument_list', 'children': ['186', '189', '192']}; {'id': '186', 'type': 'subscript', 'children': ['187', '188']}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '189', 'type': 'subscript', 'children': ['190', '191']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '192', 'type': 'dictionary_splat', 'children': ['193']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '194', 'type': 'if_statement', 'children': ['195', '198']}, {'id': '195', 'type': 'comparison_operator', 'children': ['196', '197'], 'value': 'is'}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'labels'}, {'id': '197', 'type': 'None', 'children': []}; {'id': '198', 'type': 'block', 'children': ['199', '210']}, {'id': '199', 'type': 'expression_statement', 'children': ['200']}; {'id': '200', 'type': 'call', 'children': ['201', '206']}, {'id': '201', 'type': 'attribute', 'children': ['202', '205']}; {'id': '202', 'type': 'subscript', 'children': ['203', '204']}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'axes'}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'k'}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'set_xlabel'}; {'id': '206', 'type': 'argument_list', 'children': ['207']}, {'id': '207', 'type': 'subscript', 'children': ['208', '209']}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'labels'}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '210', 'type': 'expression_statement', 'children': ['211']}, {'id': '211', 'type': 'call', 'children': ['212', '217']}; {'id': '212', 'type': 'attribute', 'children': ['213', '216']}, {'id': '213', 'type': 'subscript', 'children': ['214', '215']}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'axes'}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'set_ylabel'}, {'id': '217', 'type': 'argument_list', 'children': ['218']}; {'id': '218', 'type': 'subscript', 'children': ['219', '220']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'j'}, {'id': '221', 'type': 'if_statement', 'children': ['222', '223']}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'autolim'}, {'id': '223', 'type': 'block', 'children': ['224', '235']}; {'id': '224', 'type': 'expression_statement', 'children': ['225']}, {'id': '225', 'type': 'call', 'children': ['226', '231']}; {'id': '226', 'type': 'attribute', 'children': ['227', '230']}, {'id': '227', 'type': 'subscript', 'children': ['228', '229']}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'axes'}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'set_xlim'}, {'id': '231', 'type': 'argument_list', 'children': ['232']}; {'id': '232', 'type': 'subscript', 'children': ['233', '234']}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'lims'}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '235', 'type': 'expression_statement', 'children': ['236']}; {'id': '236', 'type': 'call', 'children': ['237', '242']}, {'id': '237', 'type': 'attribute', 'children': ['238', '241']}; {'id': '238', 'type': 'subscript', 'children': ['239', '240']}, {'id': '239', 'type': 'identifier', 'children': [], 'value': 'axes'}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'k'}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'set_ylim'}; {'id': '242', 'type': 'argument_list', 'children': ['243']}, {'id': '243', 'type': 'subscript', 'children': ['244', '245']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'lims'}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '246', 'type': 'expression_statement', 'children': ['247']}, {'id': '247', 'type': 'augmented_assignment', 'children': ['248', '249'], 'value': '+='}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 'k'}, {'id': '249', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '250', 'type': 'expression_statement', 'children': ['251']}, {'id': '251', 'type': 'call', 'children': ['252', '259']}; {'id': '252', 'type': 'attribute', 'children': ['253', '258']}, {'id': '253', 'type': 'attribute', 'children': ['254', '257']}; {'id': '254', 'type': 'subscript', 'children': ['255', '256']}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'axes'}; {'id': '256', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '257', 'type': 'identifier', 'children': [], 'value': 'figure'}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'tight_layout'}, {'id': '259', 'type': 'argument_list', 'children': []}; {'id': '260', 'type': 'return_statement', 'children': ['261']}, {'id': '261', 'type': 'attribute', 'children': ['262', '265']}; {'id': '262', 'type': 'subscript', 'children': ['263', '264']}, {'id': '263', 'type': 'identifier', 'children': [], 'value': 'axes'}; {'id': '264', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '265', 'type': 'identifier', 'children': [], 'value': 'figure'}
def plot_projections(x, relative_to=None, autolim=True, axes=None, subplots_kwargs=dict(), labels=None, plot_function=None, **kwargs): x = np.array(x, copy=True) ndim = x.shape[0] if axes is None: axes = _get_axes(dim=ndim, subplots_kwargs=subplots_kwargs) if relative_to is not None: x -= relative_to plot_fn_name = plot_function.__name__ if autolim: lims = [] for i in range(ndim): max_,min_ = np.max(x[i]), np.min(x[i]) delta = max_ - min_ if delta == 0.: delta = 1. lims.append([min_ - delta*0.02, max_ + delta*0.02]) k = 0 for i in range(ndim): for j in range(ndim): if i >= j: continue plot_func = getattr(axes[k], plot_fn_name) plot_func(x[i], x[j], **kwargs) if labels is not None: axes[k].set_xlabel(labels[i]) axes[k].set_ylabel(labels[j]) if autolim: axes[k].set_xlim(lims[i]) axes[k].set_ylim(lims[j]) k += 1 axes[0].figure.tight_layout() return axes[0].figure
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '29']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_coeffs'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '12', '15', '18', '21', '24', '27']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'density_func'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'nmax'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'lmax'}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'M'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'r_s'}, {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '11', 'type': 'tuple', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'skip_odd'}; {'id': '14', 'type': 'False', 'children': []}, {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'skip_even'}, {'id': '17', 'type': 'False', 'children': []}; {'id': '18', 'type': 'default_parameter', 'children': ['19', '20']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'skip_m'}; {'id': '20', 'type': 'False', 'children': []}, {'id': '21', 'type': 'default_parameter', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'S_only'}, {'id': '23', 'type': 'False', 'children': []}; {'id': '24', 'type': 'default_parameter', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'progress'}; {'id': '26', 'type': 'False', 'children': []}, {'id': '27', 'type': 'dictionary_splat_pattern', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'nquad_opts'}, {'id': '29', 'type': 'block', 'children': ['30', '36', '49', '53', '57', '66', '73', '91', '109', '127', '145', '153', '161', '180', '184', '231', '272', '356']}; {'id': '30', 'type': 'import_from_statement', 'children': ['31', '34']}, {'id': '31', 'type': 'dotted_name', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'gala'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': '_cconfig'}; {'id': '34', 'type': 'dotted_name', 'children': ['35']}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'GSL_ENABLED'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '39']}, {'id': '37', 'type': 'not_operator', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'GSL_ENABLED'}, {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'raise_statement', 'children': ['41']}, {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'concatenated_string', 'children': ['45', '46', '47', '48']}, {'id': '45', 'type': 'string', 'children': [], 'value': '"Gala was compiled without GSL and so this function "'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"will not work. See the gala documentation for more "'}, {'id': '47', 'type': 'string', 'children': [], 'value': '"information about installing and using GSL with "'}; {'id': '48', 'type': 'string', 'children': [], 'value': '"gala: http://gala.adrian.pw/en/latest/install.html"'}, {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'lmin'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'lstride'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '57', 'type': 'if_statement', 'children': ['58', '61']}; {'id': '58', 'type': 'boolean_operator', 'children': ['59', '60'], 'value': 'or'}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'skip_odd'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'skip_even'}, {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}, {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'lstride'}, {'id': '65', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '66', 'type': 'if_statement', 'children': ['67', '68']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'skip_even'}; {'id': '68', 'type': 'block', 'children': ['69']}, {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'lmin'}; {'id': '72', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'Snlm'}; {'id': '76', 'type': 'call', 'children': ['77', '80']}, {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}, {'id': '81', 'type': 'tuple', 'children': ['82', '85', '88']}; {'id': '82', 'type': 'binary_operator', 'children': ['83', '84'], 'value': '+'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'nmax'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '85', 'type': 'binary_operator', 'children': ['86', '87'], 'value': '+'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'lmax'}, {'id': '87', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '88', 'type': 'binary_operator', 'children': ['89', '90'], 'value': '+'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'lmax'}; {'id': '90', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'Snlm_e'}; {'id': '94', 'type': 'call', 'children': ['95', '98']}, {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}, {'id': '99', 'type': 'tuple', 'children': ['100', '103', '106']}; {'id': '100', 'type': 'binary_operator', 'children': ['101', '102'], 'value': '+'}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'nmax'}; {'id': '102', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '103', 'type': 'binary_operator', 'children': ['104', '105'], 'value': '+'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'lmax'}, {'id': '105', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '106', 'type': 'binary_operator', 'children': ['107', '108'], 'value': '+'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'lmax'}; {'id': '108', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'Tnlm'}; {'id': '112', 'type': 'call', 'children': ['113', '116']}, {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}, {'id': '117', 'type': 'tuple', 'children': ['118', '121', '124']}; {'id': '118', 'type': 'binary_operator', 'children': ['119', '120'], 'value': '+'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'nmax'}; {'id': '120', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '121', 'type': 'binary_operator', 'children': ['122', '123'], 'value': '+'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'lmax'}, {'id': '123', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '124', 'type': 'binary_operator', 'children': ['125', '126'], 'value': '+'}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'lmax'}; {'id': '126', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '127', 'type': 'expression_statement', 'children': ['128']}; {'id': '128', 'type': 'assignment', 'children': ['129', '130']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'Tnlm_e'}; {'id': '130', 'type': 'call', 'children': ['131', '134']}, {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}, {'id': '135', 'type': 'tuple', 'children': ['136', '139', '142']}; {'id': '136', 'type': 'binary_operator', 'children': ['137', '138'], 'value': '+'}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'nmax'}; {'id': '138', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '139', 'type': 'binary_operator', 'children': ['140', '141'], 'value': '+'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'lmax'}, {'id': '141', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '142', 'type': 'binary_operator', 'children': ['143', '144'], 'value': '+'}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'lmax'}; {'id': '144', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '145', 'type': 'expression_statement', 'children': ['146']}; {'id': '146', 'type': 'call', 'children': ['147', '150']}, {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'nquad_opts'}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'setdefault'}; {'id': '150', 'type': 'argument_list', 'children': ['151', '152']}, {'id': '151', 'type': 'string', 'children': [], 'value': "'limit'"}; {'id': '152', 'type': 'integer', 'children': [], 'value': '256'}, {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'call', 'children': ['155', '158']}, {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'nquad_opts'}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'setdefault'}; {'id': '158', 'type': 'argument_list', 'children': ['159', '160']}, {'id': '159', 'type': 'string', 'children': [], 'value': "'epsrel'"}; {'id': '160', 'type': 'float', 'children': [], 'value': '1E-10'}, {'id': '161', 'type': 'expression_statement', 'children': ['162']}; {'id': '162', 'type': 'assignment', 'children': ['163', '164']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'limits'}; {'id': '164', 'type': 'list', 'children': ['165', '172', '176'], 'value': '[[0, 2*np.pi],\n [-1, 1.],\n [-1, 1.]]'}, {'id': '165', 'type': 'list', 'children': ['166', '167'], 'value': '[0, 2*np.pi]'}; {'id': '166', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '167', 'type': 'binary_operator', 'children': ['168', '169'], 'value': '*'}; {'id': '168', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '169', 'type': 'attribute', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'pi'}; {'id': '172', 'type': 'list', 'children': ['173', '175'], 'value': '[-1, 1.]'}, {'id': '173', 'type': 'unary_operator', 'children': ['174'], 'value': '-'}; {'id': '174', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '175', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '176', 'type': 'list', 'children': ['177', '179'], 'value': '[-1, 1.]'}, {'id': '177', 'type': 'unary_operator', 'children': ['178'], 'value': '-'}; {'id': '178', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '179', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '180', 'type': 'expression_statement', 'children': ['181']}, {'id': '181', 'type': 'assignment', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'nlms'}, {'id': '183', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '184', 'type': 'for_statement', 'children': ['185', '186', '192']}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '186', 'type': 'call', 'children': ['187', '188']}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '188', 'type': 'argument_list', 'children': ['189']}, {'id': '189', 'type': 'binary_operator', 'children': ['190', '191'], 'value': '+'}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'nmax'}, {'id': '191', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '192', 'type': 'block', 'children': ['193']}, {'id': '193', 'type': 'for_statement', 'children': ['194', '195', '203']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'l'}, {'id': '195', 'type': 'call', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'range'}, {'id': '197', 'type': 'argument_list', 'children': ['198', '199', '202']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'lmin'}, {'id': '199', 'type': 'binary_operator', 'children': ['200', '201'], 'value': '+'}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'lmax'}, {'id': '201', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'lstride'}, {'id': '203', 'type': 'block', 'children': ['204']}; {'id': '204', 'type': 'for_statement', 'children': ['205', '206', '212']}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '206', 'type': 'call', 'children': ['207', '208']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '208', 'type': 'argument_list', 'children': ['209']}, {'id': '209', 'type': 'binary_operator', 'children': ['210', '211'], 'value': '+'}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'l'}, {'id': '211', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '212', 'type': 'block', 'children': ['213', '221']}, {'id': '213', 'type': 'if_statement', 'children': ['214', '219']}; {'id': '214', 'type': 'boolean_operator', 'children': ['215', '216'], 'value': 'and'}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'skip_m'}; {'id': '216', 'type': 'comparison_operator', 'children': ['217', '218'], 'value': '>'}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '218', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '219', 'type': 'block', 'children': ['220']}; {'id': '220', 'type': 'continue_statement', 'children': []}, {'id': '221', 'type': 'expression_statement', 'children': ['222']}; {'id': '222', 'type': 'call', 'children': ['223', '226']}, {'id': '223', 'type': 'attribute', 'children': ['224', '225']}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'nlms'}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '226', 'type': 'argument_list', 'children': ['227']}, {'id': '227', 'type': 'tuple', 'children': ['228', '229', '230']}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '231', 'type': 'if_statement', 'children': ['232', '233', '263']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'progress'}, {'id': '233', 'type': 'block', 'children': ['234', '259']}; {'id': '234', 'type': 'try_statement', 'children': ['235', '241']}, {'id': '235', 'type': 'block', 'children': ['236']}; {'id': '236', 'type': 'import_from_statement', 'children': ['237', '239']}, {'id': '237', 'type': 'dotted_name', 'children': ['238']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'tqdm'}, {'id': '239', 'type': 'dotted_name', 'children': ['240']}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'tqdm'}, {'id': '241', 'type': 'except_clause', 'children': ['242', '246']}; {'id': '242', 'type': 'as_pattern', 'children': ['243', '244']}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'ImportError'}; {'id': '244', 'type': 'as_pattern_target', 'children': ['245']}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '246', 'type': 'block', 'children': ['247']}, {'id': '247', 'type': 'raise_statement', 'children': ['248']}; {'id': '248', 'type': 'call', 'children': ['249', '250']}, {'id': '249', 'type': 'identifier', 'children': [], 'value': 'ImportError'}; {'id': '250', 'type': 'argument_list', 'children': ['251']}, {'id': '251', 'type': 'binary_operator', 'children': ['252', '255'], 'value': '+'}; {'id': '252', 'type': 'concatenated_string', 'children': ['253', '254']}, {'id': '253', 'type': 'string', 'children': [], 'value': "'tqdm is not installed - you can install it '"}; {'id': '254', 'type': 'string', 'children': [], 'value': "'with `pip install tqdm`.\\n'"}, {'id': '255', 'type': 'call', 'children': ['256', '257']}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '257', 'type': 'argument_list', 'children': ['258']}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'e'}, {'id': '259', 'type': 'expression_statement', 'children': ['260']}; {'id': '260', 'type': 'assignment', 'children': ['261', '262']}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'iterfunc'}; {'id': '262', 'type': 'identifier', 'children': [], 'value': 'tqdm'}, {'id': '263', 'type': 'else_clause', 'children': ['264']}; {'id': '264', 'type': 'block', 'children': ['265']}, {'id': '265', 'type': 'expression_statement', 'children': ['266']}; {'id': '266', 'type': 'assignment', 'children': ['267', '268']}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'iterfunc'}; {'id': '268', 'type': 'lambda', 'children': ['269', '271']}, {'id': '269', 'type': 'lambda_parameters', 'children': ['270']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '271', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '272', 'type': 'for_statement', 'children': ['273', '277', '281']}, {'id': '273', 'type': 'pattern_list', 'children': ['274', '275', '276']}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '277', 'type': 'call', 'children': ['278', '279']}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'iterfunc'}, {'id': '279', 'type': 'argument_list', 'children': ['280']}; {'id': '280', 'type': 'identifier', 'children': [], 'value': 'nlms'}, {'id': '281', 'type': 'block', 'children': ['282', '317']}; {'id': '282', 'type': 'expression_statement', 'children': ['283']}, {'id': '283', 'type': 'assignment', 'children': ['284', '295']}; {'id': '284', 'type': 'pattern_list', 'children': ['285', '290']}, {'id': '285', 'type': 'subscript', 'children': ['286', '287', '288', '289']}; {'id': '286', 'type': 'identifier', 'children': [], 'value': 'Snlm'}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'l'}, {'id': '289', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '290', 'type': 'subscript', 'children': ['291', '292', '293', '294']}, {'id': '291', 'type': 'identifier', 'children': [], 'value': 'Snlm_e'}; {'id': '292', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '293', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '295', 'type': 'call', 'children': ['296', '299']}; {'id': '296', 'type': 'attribute', 'children': ['297', '298']}, {'id': '297', 'type': 'identifier', 'children': [], 'value': 'si'}; {'id': '298', 'type': 'identifier', 'children': [], 'value': 'nquad'}, {'id': '299', 'type': 'argument_list', 'children': ['300', '301', '304', '314']}; {'id': '300', 'type': 'identifier', 'children': [], 'value': 'Snlm_integrand'}, {'id': '301', 'type': 'keyword_argument', 'children': ['302', '303']}; {'id': '302', 'type': 'identifier', 'children': [], 'value': 'ranges'}, {'id': '303', 'type': 'identifier', 'children': [], 'value': 'limits'}; {'id': '304', 'type': 'keyword_argument', 'children': ['305', '306']}, {'id': '305', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '306', 'type': 'tuple', 'children': ['307', '308', '309', '310', '311', '312', '313']}, {'id': '307', 'type': 'identifier', 'children': [], 'value': 'density_func'}; {'id': '308', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '309', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '310', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '311', 'type': 'identifier', 'children': [], 'value': 'M'}; {'id': '312', 'type': 'identifier', 'children': [], 'value': 'r_s'}, {'id': '313', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '314', 'type': 'keyword_argument', 'children': ['315', '316']}, {'id': '315', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '316', 'type': 'identifier', 'children': [], 'value': 'nquad_opts'}, {'id': '317', 'type': 'if_statement', 'children': ['318', '320']}; {'id': '318', 'type': 'not_operator', 'children': ['319']}, {'id': '319', 'type': 'identifier', 'children': [], 'value': 'S_only'}; {'id': '320', 'type': 'block', 'children': ['321']}, {'id': '321', 'type': 'expression_statement', 'children': ['322']}; {'id': '322', 'type': 'assignment', 'children': ['323', '334']}, {'id': '323', 'type': 'pattern_list', 'children': ['324', '329']}; {'id': '324', 'type': 'subscript', 'children': ['325', '326', '327', '328']}, {'id': '325', 'type': 'identifier', 'children': [], 'value': 'Tnlm'}; {'id': '326', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '327', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '328', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '329', 'type': 'subscript', 'children': ['330', '331', '332', '333']}; {'id': '330', 'type': 'identifier', 'children': [], 'value': 'Tnlm_e'}, {'id': '331', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '332', 'type': 'identifier', 'children': [], 'value': 'l'}, {'id': '333', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '334', 'type': 'call', 'children': ['335', '338']}, {'id': '335', 'type': 'attribute', 'children': ['336', '337']}; {'id': '336', 'type': 'identifier', 'children': [], 'value': 'si'}, {'id': '337', 'type': 'identifier', 'children': [], 'value': 'nquad'}; {'id': '338', 'type': 'argument_list', 'children': ['339', '340', '343', '353']}, {'id': '339', 'type': 'identifier', 'children': [], 'value': 'Tnlm_integrand'}; {'id': '340', 'type': 'keyword_argument', 'children': ['341', '342']}, {'id': '341', 'type': 'identifier', 'children': [], 'value': 'ranges'}; {'id': '342', 'type': 'identifier', 'children': [], 'value': 'limits'}, {'id': '343', 'type': 'keyword_argument', 'children': ['344', '345']}; {'id': '344', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '345', 'type': 'tuple', 'children': ['346', '347', '348', '349', '350', '351', '352']}; {'id': '346', 'type': 'identifier', 'children': [], 'value': 'density_func'}, {'id': '347', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '348', 'type': 'identifier', 'children': [], 'value': 'l'}, {'id': '349', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '350', 'type': 'identifier', 'children': [], 'value': 'M'}, {'id': '351', 'type': 'identifier', 'children': [], 'value': 'r_s'}; {'id': '352', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '353', 'type': 'keyword_argument', 'children': ['354', '355']}; {'id': '354', 'type': 'identifier', 'children': [], 'value': 'opts'}, {'id': '355', 'type': 'identifier', 'children': [], 'value': 'nquad_opts'}; {'id': '356', 'type': 'return_statement', 'children': ['357']}, {'id': '357', 'type': 'expression_list', 'children': ['358', '361']}; {'id': '358', 'type': 'tuple', 'children': ['359', '360']}, {'id': '359', 'type': 'identifier', 'children': [], 'value': 'Snlm'}; {'id': '360', 'type': 'identifier', 'children': [], 'value': 'Snlm_e'}, {'id': '361', 'type': 'tuple', 'children': ['362', '363']}; {'id': '362', 'type': 'identifier', 'children': [], 'value': 'Tnlm'}, {'id': '363', 'type': 'identifier', 'children': [], 'value': 'Tnlm_e'}
def compute_coeffs(density_func, nmax, lmax, M, r_s, args=(), skip_odd=False, skip_even=False, skip_m=False, S_only=False, progress=False, **nquad_opts): from gala._cconfig import GSL_ENABLED if not GSL_ENABLED: raise ValueError("Gala was compiled without GSL and so this function " "will not work. See the gala documentation for more " "information about installing and using GSL with " "gala: http://gala.adrian.pw/en/latest/install.html") lmin = 0 lstride = 1 if skip_odd or skip_even: lstride = 2 if skip_even: lmin = 1 Snlm = np.zeros((nmax+1, lmax+1, lmax+1)) Snlm_e = np.zeros((nmax+1, lmax+1, lmax+1)) Tnlm = np.zeros((nmax+1, lmax+1, lmax+1)) Tnlm_e = np.zeros((nmax+1, lmax+1, lmax+1)) nquad_opts.setdefault('limit', 256) nquad_opts.setdefault('epsrel', 1E-10) limits = [[0, 2*np.pi], [-1, 1.], [-1, 1.]] nlms = [] for n in range(nmax+1): for l in range(lmin, lmax+1, lstride): for m in range(l+1): if skip_m and m > 0: continue nlms.append((n, l, m)) if progress: try: from tqdm import tqdm except ImportError as e: raise ImportError('tqdm is not installed - you can install it ' 'with `pip install tqdm`.\n' + str(e)) iterfunc = tqdm else: iterfunc = lambda x: x for n, l, m in iterfunc(nlms): Snlm[n, l, m], Snlm_e[n, l, m] = si.nquad( Snlm_integrand, ranges=limits, args=(density_func, n, l, m, M, r_s, args), opts=nquad_opts) if not S_only: Tnlm[n, l, m], Tnlm_e[n, l, m] = si.nquad( Tnlm_integrand, ranges=limits, args=(density_func, n, l, m, M, r_s, args), opts=nquad_opts) return (Snlm, Snlm_e), (Tnlm, Tnlm_e)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_coeffs_discrete'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '12', '15', '18']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'xyz'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'mass'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'nmax'}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'lmax'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'r_s'}, {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'skip_odd'}, {'id': '11', 'type': 'False', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'skip_even'}; {'id': '14', 'type': 'False', 'children': []}, {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'skip_m'}, {'id': '17', 'type': 'False', 'children': []}; {'id': '18', 'type': 'default_parameter', 'children': ['19', '20']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'compute_var'}; {'id': '20', 'type': 'False', 'children': []}, {'id': '21', 'type': 'block', 'children': ['22', '26', '30', '39', '46', '64', '82', '121', '135', '149', '169', '175', '193', '203', '289']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}, {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'lmin'}, {'id': '25', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}, {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'lstride'}, {'id': '29', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '34']}, {'id': '31', 'type': 'boolean_operator', 'children': ['32', '33'], 'value': 'or'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'skip_odd'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'skip_even'}; {'id': '34', 'type': 'block', 'children': ['35']}, {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'lstride'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '39', 'type': 'if_statement', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'skip_even'}, {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}, {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'lmin'}, {'id': '45', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}, {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'Snlm'}, {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'zeros'}, {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'tuple', 'children': ['55', '58', '61']}, {'id': '55', 'type': 'binary_operator', 'children': ['56', '57'], 'value': '+'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'nmax'}, {'id': '57', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '60'], 'value': '+'}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'lmax'}; {'id': '60', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '61', 'type': 'binary_operator', 'children': ['62', '63'], 'value': '+'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'lmax'}, {'id': '63', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}, {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'Tnlm'}, {'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': 'zeros'}, {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'tuple', 'children': ['73', '76', '79']}, {'id': '73', 'type': 'binary_operator', 'children': ['74', '75'], 'value': '+'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'nmax'}, {'id': '75', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '76', 'type': 'binary_operator', 'children': ['77', '78'], 'value': '+'}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'lmax'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '79', 'type': 'binary_operator', 'children': ['80', '81'], 'value': '+'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'lmax'}, {'id': '81', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '82', 'type': 'if_statement', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'compute_var'}; {'id': '84', 'type': 'block', 'children': ['85', '103']}, {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'Snlm_var'}; {'id': '88', 'type': 'call', 'children': ['89', '92']}, {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}, {'id': '93', 'type': 'tuple', 'children': ['94', '97', '100']}; {'id': '94', 'type': 'binary_operator', 'children': ['95', '96'], 'value': '+'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'nmax'}; {'id': '96', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '97', 'type': 'binary_operator', 'children': ['98', '99'], 'value': '+'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'lmax'}, {'id': '99', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '100', 'type': 'binary_operator', 'children': ['101', '102'], 'value': '+'}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'lmax'}; {'id': '102', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'assignment', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'Tnlm_var'}; {'id': '106', 'type': 'call', 'children': ['107', '110']}, {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}, {'id': '111', 'type': 'tuple', 'children': ['112', '115', '118']}; {'id': '112', 'type': 'binary_operator', 'children': ['113', '114'], 'value': '+'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'nmax'}; {'id': '114', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '115', 'type': 'binary_operator', 'children': ['116', '117'], 'value': '+'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'lmax'}, {'id': '117', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '118', 'type': 'binary_operator', 'children': ['119', '120'], 'value': '+'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'lmax'}; {'id': '120', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'assignment', 'children': ['123', '124']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'xyz'}; {'id': '124', 'type': 'call', 'children': ['125', '128']}, {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'ascontiguousarray'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}, {'id': '129', 'type': 'call', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'atleast_2d'}, {'id': '133', 'type': 'argument_list', 'children': ['134']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'xyz'}, {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'assignment', 'children': ['137', '138']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'mass'}; {'id': '138', 'type': 'call', 'children': ['139', '142']}, {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'ascontiguousarray'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}, {'id': '143', 'type': 'call', 'children': ['144', '147']}; {'id': '144', 'type': 'attribute', 'children': ['145', '146']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'atleast_1d'}, {'id': '147', 'type': 'argument_list', 'children': ['148']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'mass'}, {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'assignment', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '152', 'type': 'call', 'children': ['153', '156']}, {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'sqrt'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}, {'id': '157', 'type': 'call', 'children': ['158', '161']}; {'id': '158', 'type': 'attribute', 'children': ['159', '160']}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'sum'}, {'id': '161', 'type': 'argument_list', 'children': ['162', '165']}; {'id': '162', 'type': 'binary_operator', 'children': ['163', '164'], 'value': '**'}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'xyz'}; {'id': '164', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '165', 'type': 'keyword_argument', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'axis'}, {'id': '167', 'type': 'unary_operator', 'children': ['168'], 'value': '-'}; {'id': '168', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '169', 'type': 'expression_statement', 'children': ['170']}; {'id': '170', 'type': 'assignment', 'children': ['171', '172']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '172', 'type': 'binary_operator', 'children': ['173', '174'], 'value': '/'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'r_s'}, {'id': '175', 'type': 'expression_statement', 'children': ['176']}; {'id': '176', 'type': 'assignment', 'children': ['177', '178']}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'phi'}; {'id': '178', 'type': 'call', 'children': ['179', '182']}, {'id': '179', 'type': 'attribute', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'arctan2'}; {'id': '182', 'type': 'argument_list', 'children': ['183', '188']}, {'id': '183', 'type': 'subscript', 'children': ['184', '185', '187']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'xyz'}, {'id': '185', 'type': 'slice', 'children': ['186']}; {'id': '186', 'type': 'colon', 'children': []}, {'id': '187', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '188', 'type': 'subscript', 'children': ['189', '190', '192']}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'xyz'}; {'id': '190', 'type': 'slice', 'children': ['191']}, {'id': '191', 'type': 'colon', 'children': []}; {'id': '192', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '193', 'type': 'expression_statement', 'children': ['194']}; {'id': '194', 'type': 'assignment', 'children': ['195', '196']}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '196', 'type': 'binary_operator', 'children': ['197', '202'], 'value': '/'}, {'id': '197', 'type': 'subscript', 'children': ['198', '199', '201']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'xyz'}, {'id': '199', 'type': 'slice', 'children': ['200']}; {'id': '200', 'type': 'colon', 'children': []}, {'id': '201', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'r'}, {'id': '203', 'type': 'for_statement', 'children': ['204', '205', '211']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '205', 'type': 'call', 'children': ['206', '207']}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'range'}, {'id': '207', 'type': 'argument_list', 'children': ['208']}; {'id': '208', 'type': 'binary_operator', 'children': ['209', '210'], 'value': '+'}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'nmax'}; {'id': '210', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '211', 'type': 'block', 'children': ['212']}; {'id': '212', 'type': 'for_statement', 'children': ['213', '214', '222']}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '214', 'type': 'call', 'children': ['215', '216']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '216', 'type': 'argument_list', 'children': ['217', '218', '221']}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'lmin'}; {'id': '218', 'type': 'binary_operator', 'children': ['219', '220'], 'value': '+'}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'lmax'}; {'id': '220', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '221', 'type': 'identifier', 'children': [], 'value': 'lstride'}; {'id': '222', 'type': 'block', 'children': ['223']}, {'id': '223', 'type': 'for_statement', 'children': ['224', '225', '231']}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '225', 'type': 'call', 'children': ['226', '227']}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'range'}, {'id': '227', 'type': 'argument_list', 'children': ['228']}; {'id': '228', 'type': 'binary_operator', 'children': ['229', '230'], 'value': '+'}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '230', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '231', 'type': 'block', 'children': ['232', '240', '263']}; {'id': '232', 'type': 'if_statement', 'children': ['233', '238']}, {'id': '233', 'type': 'boolean_operator', 'children': ['234', '235'], 'value': 'and'}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'skip_m'}, {'id': '235', 'type': 'comparison_operator', 'children': ['236', '237'], 'value': '>'}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '237', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '238', 'type': 'block', 'children': ['239']}, {'id': '239', 'type': 'continue_statement', 'children': []}; {'id': '240', 'type': 'expression_statement', 'children': ['241']}, {'id': '241', 'type': 'assignment', 'children': ['242', '253']}; {'id': '242', 'type': 'pattern_list', 'children': ['243', '248']}, {'id': '243', 'type': 'subscript', 'children': ['244', '245', '246', '247']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'Snlm'}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'l'}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '248', 'type': 'subscript', 'children': ['249', '250', '251', '252']}, {'id': '249', 'type': 'identifier', 'children': [], 'value': 'Tnlm'}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '251', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '253', 'type': 'call', 'children': ['254', '255']}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'STnlm_discrete'}, {'id': '255', 'type': 'argument_list', 'children': ['256', '257', '258', '259', '260', '261', '262']}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '257', 'type': 'identifier', 'children': [], 'value': 'phi'}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'X'}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'mass'}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '262', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '263', 'type': 'if_statement', 'children': ['264', '265']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'compute_var'}, {'id': '265', 'type': 'block', 'children': ['266']}; {'id': '266', 'type': 'expression_statement', 'children': ['267']}, {'id': '267', 'type': 'assignment', 'children': ['268', '279']}; {'id': '268', 'type': 'pattern_list', 'children': ['269', '274']}, {'id': '269', 'type': 'subscript', 'children': ['270', '271', '272', '273']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'Snlm_var'}, {'id': '271', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '272', 'type': 'identifier', 'children': [], 'value': 'l'}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '274', 'type': 'subscript', 'children': ['275', '276', '277', '278']}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 'Tnlm_var'}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '277', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '279', 'type': 'call', 'children': ['280', '281']}; {'id': '280', 'type': 'identifier', 'children': [], 'value': 'STnlm_var_discrete'}, {'id': '281', 'type': 'argument_list', 'children': ['282', '283', '284', '285', '286', '287', '288']}; {'id': '282', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '283', 'type': 'identifier', 'children': [], 'value': 'phi'}; {'id': '284', 'type': 'identifier', 'children': [], 'value': 'X'}, {'id': '285', 'type': 'identifier', 'children': [], 'value': 'mass'}; {'id': '286', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '289', 'type': 'if_statement', 'children': ['290', '291', '300']}; {'id': '290', 'type': 'identifier', 'children': [], 'value': 'compute_var'}, {'id': '291', 'type': 'block', 'children': ['292']}; {'id': '292', 'type': 'return_statement', 'children': ['293']}, {'id': '293', 'type': 'expression_list', 'children': ['294', '297']}; {'id': '294', 'type': 'tuple', 'children': ['295', '296']}, {'id': '295', 'type': 'identifier', 'children': [], 'value': 'Snlm'}; {'id': '296', 'type': 'identifier', 'children': [], 'value': 'Snlm_var'}, {'id': '297', 'type': 'tuple', 'children': ['298', '299']}; {'id': '298', 'type': 'identifier', 'children': [], 'value': 'Tnlm'}, {'id': '299', 'type': 'identifier', 'children': [], 'value': 'Tnlm_var'}; {'id': '300', 'type': 'else_clause', 'children': ['301']}, {'id': '301', 'type': 'block', 'children': ['302']}; {'id': '302', 'type': 'return_statement', 'children': ['303']}, {'id': '303', 'type': 'expression_list', 'children': ['304', '305']}; {'id': '304', 'type': 'identifier', 'children': [], 'value': 'Snlm'}, {'id': '305', 'type': 'identifier', 'children': [], 'value': 'Tnlm'}
def compute_coeffs_discrete(xyz, mass, nmax, lmax, r_s, skip_odd=False, skip_even=False, skip_m=False, compute_var=False): lmin = 0 lstride = 1 if skip_odd or skip_even: lstride = 2 if skip_even: lmin = 1 Snlm = np.zeros((nmax+1, lmax+1, lmax+1)) Tnlm = np.zeros((nmax+1, lmax+1, lmax+1)) if compute_var: Snlm_var = np.zeros((nmax+1, lmax+1, lmax+1)) Tnlm_var = np.zeros((nmax+1, lmax+1, lmax+1)) xyz = np.ascontiguousarray(np.atleast_2d(xyz)) mass = np.ascontiguousarray(np.atleast_1d(mass)) r = np.sqrt(np.sum(xyz**2, axis=-1)) s = r / r_s phi = np.arctan2(xyz[:,1], xyz[:,0]) X = xyz[:,2] / r for n in range(nmax+1): for l in range(lmin, lmax+1, lstride): for m in range(l+1): if skip_m and m > 0: continue Snlm[n,l,m], Tnlm[n,l,m] = STnlm_discrete(s, phi, X, mass, n, l, m) if compute_var: Snlm_var[n,l,m], Tnlm_var[n,l,m] = STnlm_var_discrete(s, phi, X, mass, n, l, m) if compute_var: return (Snlm,Snlm_var), (Tnlm,Tnlm_var) else: return Snlm, Tnlm
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_coord_frame'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'galactocentric_frame'}; {'id': '8', 'type': 'None', 'children': []}, {'id': '9', 'type': 'dictionary_splat_pattern', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'kwargs'}, {'id': '11', 'type': 'block', 'children': ['12', '26', '39', '62', '75', '88', '128', '146', '155']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '18']}, {'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': 'ndim'}, {'id': '17', 'type': 'integer', 'children': [], 'value': '3'}; {'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': 'ValueError'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}, {'id': '23', 'type': 'concatenated_string', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': '"Can only change representation for "'}, {'id': '25', 'type': 'string', 'children': [], 'value': '"ndim=3 instances."'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '30']}, {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'is'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'galactocentric_frame'}, {'id': '29', 'type': 'None', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31']}, {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'galactocentric_frame'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}, {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'coord'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Galactocentric'}; {'id': '38', 'type': 'argument_list', 'children': []}, {'id': '39', 'type': 'if_statement', 'children': ['40', '47']}; {'id': '40', 'type': 'boolean_operator', 'children': ['41', '44'], 'value': 'or'}, {'id': '41', 'type': 'comparison_operator', 'children': ['42', '43'], 'value': 'in'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'vcirc'"}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '46'], 'value': 'in'}, {'id': '45', 'type': 'string', 'children': [], 'value': "'vlsr'"}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'kwargs'}, {'id': '47', 'type': 'block', 'children': ['48', '51']}; {'id': '48', 'type': 'import_statement', 'children': ['49']}, {'id': '49', 'type': 'dotted_name', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'warnings'}, {'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': 'warnings'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '61']}, {'id': '57', 'type': 'concatenated_string', 'children': ['58', '59', '60']}; {'id': '58', 'type': 'string', 'children': [], 'value': '"Instead of passing in \'vcirc\' and \'vlsr\', specify "'}, {'id': '59', 'type': 'string', 'children': [], 'value': '"these parameters to the input Galactocentric frame "'}; {'id': '60', 'type': 'string', 'children': [], 'value': '"using the `galcen_v_sun` argument."'}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'DeprecationWarning'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}, {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'pos_keys'}, {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'list'}, {'id': '67', 'type': 'argument_list', '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': 'pos_components'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '74', 'type': 'argument_list', 'children': []}, {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'vel_keys'}; {'id': '78', 'type': 'call', 'children': ['79', '80']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '80', 'type': 'argument_list', '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': 'self'}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'vel_components'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'keys'}, {'id': '87', 'type': 'argument_list', 'children': []}; {'id': '88', 'type': 'if_statement', 'children': ['89', '117']}, {'id': '89', 'type': 'parenthesized_expression', 'children': ['90']}; {'id': '90', 'type': 'boolean_operator', 'children': ['91', '104'], 'value': 'or'}, {'id': '91', 'type': 'comparison_operator', 'children': ['92', '101'], 'value': '=='}; {'id': '92', 'type': 'attribute', 'children': ['93', '100']}, {'id': '93', 'type': 'call', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'getattr'}, {'id': '95', 'type': 'argument_list', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '97', 'type': 'subscript', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'pos_keys'}, {'id': '99', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'unit'}, {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'u'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'one'}; {'id': '104', 'type': 'comparison_operator', 'children': ['105', '114'], 'value': '=='}, {'id': '105', 'type': 'attribute', 'children': ['106', '113']}; {'id': '106', 'type': 'call', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '108', 'type': 'argument_list', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '110', 'type': 'subscript', 'children': ['111', '112']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'vel_keys'}; {'id': '112', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'u'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'one'}, {'id': '117', 'type': 'block', 'children': ['118']}; {'id': '118', 'type': 'raise_statement', 'children': ['119']}, {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'u'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'UnitConversionError'}, {'id': '123', 'type': 'argument_list', 'children': ['124']}; {'id': '124', 'type': 'concatenated_string', 'children': ['125', '126', '127']}, {'id': '125', 'type': 'string', 'children': [], 'value': '"Position and velocity must have "'}; {'id': '126', 'type': 'string', 'children': [], 'value': '"dimensioned units to convert to a "'}, {'id': '127', 'type': 'string', 'children': [], 'value': '"coordinate frame."'}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}, {'id': '129', 'type': 'assignment', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'gc_c'}, {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'galactocentric_frame'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'realize_frame'}, {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'call', 'children': ['137', '142']}, {'id': '137', 'type': 'attribute', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'pos'}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'with_differentials'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}, {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'vel'}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}, {'id': '147', 'type': 'assignment', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'c'}, {'id': '149', 'type': 'call', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'gc_c'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'transform_to'}, {'id': '153', 'type': 'argument_list', 'children': ['154']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'frame'}, {'id': '155', 'type': 'return_statement', 'children': ['156']}
def to_coord_frame(self, frame, galactocentric_frame=None, **kwargs): if self.ndim != 3: raise ValueError("Can only change representation for " "ndim=3 instances.") if galactocentric_frame is None: galactocentric_frame = coord.Galactocentric() if 'vcirc' in kwargs or 'vlsr' in kwargs: import warnings warnings.warn("Instead of passing in 'vcirc' and 'vlsr', specify " "these parameters to the input Galactocentric frame " "using the `galcen_v_sun` argument.", DeprecationWarning) pos_keys = list(self.pos_components.keys()) vel_keys = list(self.vel_components.keys()) if (getattr(self, pos_keys[0]).unit == u.one or getattr(self, vel_keys[0]).unit == u.one): raise u.UnitConversionError("Position and velocity must have " "dimensioned units to convert to a " "coordinate frame.") gc_c = galactocentric_frame.realize_frame( self.pos.with_differentials(self.vel)) c = gc_c.transform_to(frame) return c
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_plot_prepare'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'components'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'units'}, {'id': '7', 'type': 'block', 'children': ['8', '21', '28', '64', '68', '72', '229']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12']}, {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'is'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'components'}, {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}, {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'components'}; {'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': 'pos'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'components'}, {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'n_comps'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'components'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '32']}, {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': 'is'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'units'}, {'id': '31', 'type': 'None', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33']}, {'id': '33', 'type': 'if_statement', 'children': ['34', '41', '49']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'u'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'UnitBase'}, {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}, {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'units'}, {'id': '45', 'type': 'binary_operator', 'children': ['46', '48'], 'value': '*'}; {'id': '46', 'type': 'list', 'children': ['47'], 'value': '[units]'}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'n_comps'}, {'id': '49', 'type': 'elif_clause', 'children': ['50', '56']}; {'id': '50', 'type': 'comparison_operator', 'children': ['51', '55'], 'value': '!='}, {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'units'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'n_comps'}; {'id': '56', 'type': 'block', 'children': ['57']}, {'id': '57', 'type': 'raise_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}, {'id': '61', 'type': 'concatenated_string', 'children': ['62', '63']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'You must specify a unit for each axis, or a '"}, {'id': '63', 'type': 'string', 'children': [], 'value': "'single unit for all axes.'"}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}, {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'labels'}, {'id': '67', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}, {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '71', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '72', 'type': 'for_statement', 'children': ['73', '76', '80']}, {'id': '73', 'type': 'pattern_list', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '76', 'type': 'call', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'components'}; {'id': '80', 'type': 'block', 'children': ['81', '89', '119', '154', '180', '194', '206', '220']}, {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '84', 'type': 'call', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '89', 'type': 'if_statement', 'children': ['90', '93', '111']}; {'id': '90', 'type': 'comparison_operator', 'children': ['91', '92'], 'value': 'is'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '92', 'type': 'None', 'children': []}, {'id': '93', 'type': 'block', 'children': ['94', '105']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}, {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'to'}, {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'subscript', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '108', 'type': 'subscript', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '111', 'type': 'else_clause', 'children': ['112']}; {'id': '112', 'type': 'block', 'children': ['113']}, {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'assignment', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'unit'}, {'id': '119', 'type': 'if_statement', 'children': ['120', '127', '148']}; {'id': '120', 'type': 'comparison_operator', 'children': ['121', '124'], 'value': '!='}, {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'u'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'one'}, {'id': '127', 'type': 'block', 'children': ['128', '139']}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}, {'id': '129', 'type': 'assignment', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'uu'}, {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'to_string'}, {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'keyword_argument', 'children': ['137', '138']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '138', 'type': 'string', 'children': [], 'value': "'latex_inline'"}, {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'assignment', 'children': ['141', '142']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'unit_str'}; {'id': '142', 'type': 'call', 'children': ['143', '146']}, {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'string', 'children': [], 'value': "' [{}]'"}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '146', 'type': 'argument_list', 'children': ['147']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'uu'}; {'id': '148', 'type': 'else_clause', 'children': ['149']}, {'id': '149', 'type': 'block', 'children': ['150']}; {'id': '150', 'type': 'expression_statement', 'children': ['151']}, {'id': '151', 'type': 'assignment', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'unit_str'}, {'id': '153', 'type': 'string', 'children': [], 'value': "''"}; {'id': '154', 'type': 'if_statement', 'children': ['155', '161', '174']}, {'id': '155', 'type': 'call', 'children': ['156', '159']}; {'id': '156', 'type': 'attribute', 'children': ['157', '158']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'startswith'}, {'id': '159', 'type': 'argument_list', 'children': ['160']}; {'id': '160', 'type': 'string', 'children': [], 'value': "'d_'"}, {'id': '161', 'type': 'block', 'children': ['162', '166']}; {'id': '162', 'type': 'expression_statement', 'children': ['163']}, {'id': '163', 'type': 'assignment', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'dot'}, {'id': '165', 'type': 'True', 'children': []}; {'id': '166', 'type': 'expression_statement', 'children': ['167']}, {'id': '167', 'type': 'assignment', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '169', 'type': 'subscript', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '171', 'type': 'slice', 'children': ['172', '173']}; {'id': '172', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '173', 'type': 'colon', 'children': []}; {'id': '174', 'type': 'else_clause', 'children': ['175']}, {'id': '175', 'type': 'block', 'children': ['176']}; {'id': '176', 'type': 'expression_statement', 'children': ['177']}, {'id': '177', 'type': 'assignment', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'dot'}, {'id': '179', 'type': 'False', 'children': []}; {'id': '180', 'type': 'if_statement', 'children': ['181', '184']}, {'id': '181', 'type': 'comparison_operator', 'children': ['182', '183'], 'value': 'in'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '183', 'type': 'identifier', 'children': [], 'value': '_greek_letters'}; {'id': '184', 'type': 'block', 'children': ['185']}, {'id': '185', 'type': 'expression_statement', 'children': ['186']}; {'id': '186', 'type': 'assignment', 'children': ['187', '188']}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '188', 'type': 'call', 'children': ['189', '192']}, {'id': '189', 'type': 'attribute', 'children': ['190', '191']}; {'id': '190', 'type': 'string', 'children': [], 'value': 'r"\\{}"'}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '192', 'type': 'argument_list', 'children': ['193']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '194', 'type': 'if_statement', 'children': ['195', '196']}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'dot'}; {'id': '196', 'type': 'block', 'children': ['197']}, {'id': '197', 'type': 'expression_statement', 'children': ['198']}; {'id': '198', 'type': 'assignment', 'children': ['199', '200']}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '200', 'type': 'call', 'children': ['201', '204']}, {'id': '201', 'type': 'attribute', 'children': ['202', '203']}; {'id': '202', 'type': 'string', 'children': [], 'value': '"\\dot{{{}}}"'}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '204', 'type': 'argument_list', 'children': ['205']}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '206', 'type': 'expression_statement', 'children': ['207']}, {'id': '207', 'type': 'call', 'children': ['208', '211']}; {'id': '208', 'type': 'attribute', 'children': ['209', '210']}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '211', 'type': 'argument_list', 'children': ['212']}; {'id': '212', 'type': 'binary_operator', 'children': ['213', '219'], 'value': '+'}, {'id': '213', 'type': 'call', 'children': ['214', '217']}; {'id': '214', 'type': 'attribute', 'children': ['215', '216']}, {'id': '215', 'type': 'string', 'children': [], 'value': "'${}$'"}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'format'}, {'id': '217', 'type': 'argument_list', 'children': ['218']}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'unit_str'}; {'id': '220', 'type': 'expression_statement', 'children': ['221']}, {'id': '221', 'type': 'call', 'children': ['222', '225']}; {'id': '222', 'type': 'attribute', 'children': ['223', '224']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '225', 'type': 'argument_list', 'children': ['226']}; {'id': '226', 'type': 'attribute', 'children': ['227', '228']}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '229', 'type': 'return_statement', 'children': ['230']}; {'id': '230', 'type': 'expression_list', 'children': ['231', '232']}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'x'}
def _plot_prepare(self, components, units): if components is None: components = self.pos.components n_comps = len(components) if units is not None: if isinstance(units, u.UnitBase): units = [units]*n_comps elif len(units) != n_comps: raise ValueError('You must specify a unit for each axis, or a ' 'single unit for all axes.') labels = [] x = [] for i,name in enumerate(components): val = getattr(self, name) if units is not None: val = val.to(units[i]) unit = units[i] else: unit = val.unit if val.unit != u.one: uu = unit.to_string(format='latex_inline') unit_str = ' [{}]'.format(uu) else: unit_str = '' if name.startswith('d_'): dot = True name = name[2:] else: dot = False if name in _greek_letters: name = r"\{}".format(name) if dot: name = "\dot{{{}}}".format(name) labels.append('${}$'.format(name) + unit_str) x.append(val.value) return x, labels
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'recommend'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'client_data'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'limit'}, {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'extra_data'}, {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '21', '30', '43', '56', '62', '166', '194', '215', '232', '243']}, {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'preinstalled_addon_ids'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}, {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'client_data'}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}, {'id': '19', 'type': 'string', 'children': [], 'value': '"installed_addons"'}; {'id': '20', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'extended_limit'}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '26'], 'value': '+'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'preinstalled_addon_ids'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}, {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ensemble_suggestions'}, {'id': '33', 'type': 'call', 'children': ['34', '39']}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}, {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': '_ensemble_recommender'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'recommend'}, {'id': '39', 'type': 'argument_list', 'children': ['40', '41', '42']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'client_data'}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'extended_limit'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'extra_data'}, {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'curated_suggestions'}; {'id': '46', 'type': 'call', 'children': ['47', '52']}, {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': '_curated_recommender'}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'recommend'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54', '55']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'client_data'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'extended_limit'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'extra_data'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}, {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'merged_results'}, {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'set'}, {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'while_statement', 'children': ['63', '84']}, {'id': '63', 'type': 'parenthesized_expression', 'children': ['64']}; {'id': '64', 'type': 'boolean_operator', 'children': ['65', '78'], 'value': 'and'}, {'id': '65', 'type': 'boolean_operator', 'children': ['66', '72'], 'value': 'and'}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '71'], 'value': '<'}, {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'merged_results'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '77'], 'value': '>'}, {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ensemble_suggestions'}, {'id': '77', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '78', 'type': 'comparison_operator', 'children': ['79', '83'], 'value': '>'}, {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'curated_suggestions'}, {'id': '83', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '84', 'type': 'block', 'children': ['85', '93', '113', '138', '146']}, {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'r1'}; {'id': '88', 'type': 'call', 'children': ['89', '92']}, {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'ensemble_suggestions'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '92', 'type': 'argument_list', 'children': []}, {'id': '93', 'type': 'if_statement', 'children': ['94', '105']}; {'id': '94', 'type': 'comparison_operator', 'children': ['95', '98'], 'value': 'not'}, {'id': '95', 'type': 'subscript', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'r1'}, {'id': '97', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '98', 'type': 'list_comprehension', 'children': ['99', '102']}, {'id': '99', 'type': 'subscript', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'temp'}, {'id': '101', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '102', 'type': 'for_in_clause', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'temp'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'merged_results'}, {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}, {'id': '107', 'type': 'call', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'merged_results'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'add'}, {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'r1'}, {'id': '113', 'type': 'if_statement', 'children': ['114', '136']}; {'id': '114', 'type': 'not_operator', 'children': ['115']}, {'id': '115', 'type': 'parenthesized_expression', 'children': ['116']}; {'id': '116', 'type': 'boolean_operator', 'children': ['117', '130'], 'value': 'and'}, {'id': '117', 'type': 'boolean_operator', 'children': ['118', '124'], 'value': 'and'}; {'id': '118', 'type': 'comparison_operator', 'children': ['119', '123'], 'value': '<'}, {'id': '119', 'type': 'call', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '121', 'type': 'argument_list', 'children': ['122']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'merged_results'}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '124', 'type': 'comparison_operator', 'children': ['125', '129'], 'value': '>'}, {'id': '125', 'type': 'call', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'ensemble_suggestions'}, {'id': '129', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '130', 'type': 'comparison_operator', 'children': ['131', '135'], 'value': '>'}, {'id': '131', 'type': 'call', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '133', 'type': 'argument_list', 'children': ['134']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'curated_suggestions'}, {'id': '135', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '136', 'type': 'block', 'children': ['137']}, {'id': '137', 'type': 'break_statement', 'children': []}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}, {'id': '139', 'type': 'assignment', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'r2'}, {'id': '141', 'type': 'call', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'curated_suggestions'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'pop'}, {'id': '145', 'type': 'argument_list', 'children': []}; {'id': '146', 'type': 'if_statement', 'children': ['147', '158']}, {'id': '147', 'type': 'comparison_operator', 'children': ['148', '151'], 'value': 'not'}; {'id': '148', 'type': 'subscript', 'children': ['149', '150']}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'r2'}; {'id': '150', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '151', 'type': 'list_comprehension', 'children': ['152', '155']}; {'id': '152', 'type': 'subscript', 'children': ['153', '154']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'temp'}; {'id': '154', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '155', 'type': 'for_in_clause', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'temp'}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'merged_results'}; {'id': '158', 'type': 'block', 'children': ['159']}, {'id': '159', 'type': 'expression_statement', 'children': ['160']}; {'id': '160', 'type': 'call', 'children': ['161', '164']}, {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'merged_results'}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '164', 'type': 'argument_list', 'children': ['165']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'r2'}; {'id': '166', 'type': 'if_statement', 'children': ['167', '173']}, {'id': '167', 'type': 'comparison_operator', 'children': ['168', '172'], 'value': '<'}; {'id': '168', 'type': 'call', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '170', 'type': 'argument_list', 'children': ['171']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'merged_results'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'limit'}, {'id': '173', 'type': 'block', 'children': ['174', '183', '192']}; {'id': '174', 'type': 'expression_statement', 'children': ['175']}, {'id': '175', 'type': 'assignment', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '177', 'type': 'parenthesized_expression', 'children': ['178']}; {'id': '178', 'type': 'binary_operator', 'children': ['179', '180'], 'value': '%'}, {'id': '179', 'type': 'string', 'children': [], 'value': '"Defaulting to empty results. Insufficient recommendations found for client: %s"'}; {'id': '180', 'type': 'subscript', 'children': ['181', '182']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'client_data'}; {'id': '182', 'type': 'string', 'children': [], 'value': '"client_id"'}, {'id': '183', 'type': 'expression_statement', 'children': ['184']}; {'id': '184', 'type': 'call', 'children': ['185', '190']}, {'id': '185', 'type': 'attribute', 'children': ['186', '189']}; {'id': '186', 'type': 'attribute', 'children': ['187', '188']}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'logger'}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '190', 'type': 'argument_list', 'children': ['191']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '192', 'type': 'return_statement', 'children': ['193']}, {'id': '193', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '194', 'type': 'expression_statement', 'children': ['195']}, {'id': '195', 'type': 'assignment', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'sorted_results'}, {'id': '197', 'type': 'call', 'children': ['198', '199']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'sorted'}, {'id': '199', 'type': 'argument_list', 'children': ['200', '204', '212']}; {'id': '200', 'type': 'call', 'children': ['201', '202']}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '202', 'type': 'argument_list', 'children': ['203']}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'merged_results'}; {'id': '204', 'type': 'keyword_argument', 'children': ['205', '206']}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '206', 'type': 'call', 'children': ['207', '210']}, {'id': '207', 'type': 'attribute', 'children': ['208', '209']}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'op'}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'itemgetter'}; {'id': '210', 'type': 'argument_list', 'children': ['211']}, {'id': '211', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '212', 'type': 'keyword_argument', 'children': ['213', '214']}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '214', 'type': 'True', 'children': []}, {'id': '215', 'type': 'expression_statement', 'children': ['216']}; {'id': '216', 'type': 'assignment', 'children': ['217', '218']}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'log_data'}; {'id': '218', 'type': 'tuple', 'children': ['219', '222']}, {'id': '219', 'type': 'subscript', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'client_data'}, {'id': '221', 'type': 'string', 'children': [], 'value': '"client_id"'}; {'id': '222', 'type': 'call', 'children': ['223', '224']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '224', 'type': 'argument_list', 'children': ['225']}, {'id': '225', 'type': 'list_comprehension', 'children': ['226', '229']}; {'id': '226', 'type': 'subscript', 'children': ['227', '228']}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '228', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '229', 'type': 'for_in_clause', 'children': ['230', '231']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'r'}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'sorted_results'}; {'id': '232', 'type': 'expression_statement', 'children': ['233']}, {'id': '233', 'type': 'call', 'children': ['234', '239']}; {'id': '234', 'type': 'attribute', 'children': ['235', '238']}, {'id': '235', 'type': 'attribute', 'children': ['236', '237']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '237', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'info'}, {'id': '239', 'type': 'argument_list', 'children': ['240']}; {'id': '240', 'type': 'binary_operator', 'children': ['241', '242'], 'value': '%'}, {'id': '241', 'type': 'string', 'children': [], 'value': '"Hybrid recommendations client_id: [%s], guids: [%s]"'}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'log_data'}, {'id': '243', 'type': 'return_statement', 'children': ['244']}
def recommend(self, client_data, limit, extra_data={}): preinstalled_addon_ids = client_data.get("installed_addons", []) extended_limit = limit + len(preinstalled_addon_ids) ensemble_suggestions = self._ensemble_recommender.recommend( client_data, extended_limit, extra_data ) curated_suggestions = self._curated_recommender.recommend( client_data, extended_limit, extra_data ) merged_results = set() while ( len(merged_results) < limit and len(ensemble_suggestions) > 0 and len(curated_suggestions) > 0 ): r1 = ensemble_suggestions.pop() if r1[0] not in [temp[0] for temp in merged_results]: merged_results.add(r1) if not ( len(merged_results) < limit and len(ensemble_suggestions) > 0 and len(curated_suggestions) > 0 ): break r2 = curated_suggestions.pop() if r2[0] not in [temp[0] for temp in merged_results]: merged_results.add(r2) if len(merged_results) < limit: msg = ( "Defaulting to empty results. Insufficient recommendations found for client: %s" % client_data["client_id"] ) self.logger.info(msg) return [] sorted_results = sorted( list(merged_results), key=op.itemgetter(1), reverse=True ) log_data = (client_data["client_id"], str([r[0] for r in sorted_results])) self.logger.info( "Hybrid recommendations client_id: [%s], guids: [%s]" % log_data ) return sorted_results
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_recommend'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'client_data'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'limit'}, {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'extra_data'}, {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '20', '30', '39', '43', '53', '120', '134', '149', '153', '185', '200', '216', '224', '245', '256']}, {'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': 'logger'}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}, {'id': '19', 'type': 'string', 'children': [], 'value': '"Ensemble recommend invoked"'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}, {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'preinstalled_addon_ids'}, {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'client_data'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'get'}, {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"installed_addons"'}, {'id': '29', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}, {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'extended_limit'}, {'id': '33', 'type': 'binary_operator', 'children': ['34', '35'], 'value': '+'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'limit'}, {'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': 'preinstalled_addon_ids'}, {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'flattened_results'}; {'id': '42', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'ensemble_weights'}; {'id': '46', 'type': 'call', 'children': ['47', '52']}, {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': '_weight_cache'}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'getWeights'}; {'id': '52', 'type': 'argument_list', 'children': []}, {'id': '53', 'type': 'for_statement', 'children': ['54', '55', '58']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'rkey'}, {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'RECOMMENDER_KEYS'}; {'id': '58', 'type': 'block', 'children': ['59', '67']}, {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'recommender'}; {'id': '62', 'type': 'subscript', 'children': ['63', '66']}, {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': '_recommender_map'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'rkey'}, {'id': '67', 'type': 'if_statement', 'children': ['68', '74']}; {'id': '68', 'type': 'call', 'children': ['69', '72']}, {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'recommender'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'can_recommend'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'client_data'}; {'id': '74', 'type': 'block', 'children': ['75', '86', '90', '113']}, {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'raw_results'}; {'id': '78', 'type': 'call', 'children': ['79', '82']}, {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'recommender'}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'recommend'}; {'id': '82', 'type': 'argument_list', 'children': ['83', '84', '85']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'client_data'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'extended_limit'}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'extra_data'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}, {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'reweighted_results'}, {'id': '89', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '90', 'type': 'for_statement', 'children': ['91', '94', '95']}, {'id': '91', 'type': 'pattern_list', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'guid'}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'weight'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'raw_results'}, {'id': '95', 'type': 'block', 'children': ['96', '106']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}, {'id': '97', 'type': 'assignment', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'item'}, {'id': '99', 'type': 'tuple', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'guid'}, {'id': '101', 'type': 'binary_operator', 'children': ['102', '103'], 'value': '*'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'weight'}, {'id': '103', 'type': 'subscript', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'ensemble_weights'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'rkey'}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}, {'id': '107', 'type': 'call', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'reweighted_results'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'item'}, {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'call', 'children': ['115', '118']}, {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'flattened_results'}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '118', 'type': 'argument_list', 'children': ['119']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'reweighted_results'}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}, {'id': '121', 'type': 'call', 'children': ['122', '125']}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'flattened_results'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'sort'}, {'id': '125', 'type': 'argument_list', 'children': ['126']}; {'id': '126', 'type': 'keyword_argument', 'children': ['127', '128']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '128', 'type': 'lambda', 'children': ['129', '131']}, {'id': '129', 'type': 'lambda_parameters', 'children': ['130']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'item'}, {'id': '131', 'type': 'subscript', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'item'}, {'id': '133', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}, {'id': '135', 'type': 'assignment', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'guid_grouper'}, {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'itertools'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'groupby'}, {'id': '141', 'type': 'argument_list', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'flattened_results'}, {'id': '143', 'type': 'lambda', 'children': ['144', '146']}; {'id': '144', 'type': 'lambda_parameters', 'children': ['145']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '146', 'type': 'subscript', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '148', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'assignment', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'ensemble_suggestions'}; {'id': '152', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '153', 'type': 'for_statement', 'children': ['154', '157', '158']}; {'id': '154', 'type': 'tuple_pattern', 'children': ['155', '156']}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'guid'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'guid_group'}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'guid_grouper'}; {'id': '158', 'type': 'block', 'children': ['159', '172', '178']}, {'id': '159', 'type': 'expression_statement', 'children': ['160']}; {'id': '160', 'type': 'assignment', 'children': ['161', '162']}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'weight_sum'}; {'id': '162', 'type': 'call', 'children': ['163', '164']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '164', 'type': 'argument_list', 'children': ['165']}, {'id': '165', 'type': 'list_comprehension', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '167', 'type': 'for_in_clause', 'children': ['168', '171']}; {'id': '168', 'type': 'tuple_pattern', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'guid_group'}; {'id': '172', 'type': 'expression_statement', 'children': ['173']}, {'id': '173', 'type': 'assignment', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'item'}, {'id': '175', 'type': 'tuple', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'guid'}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'weight_sum'}; {'id': '178', 'type': 'expression_statement', 'children': ['179']}, {'id': '179', 'type': 'call', 'children': ['180', '183']}; {'id': '180', 'type': 'attribute', 'children': ['181', '182']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'ensemble_suggestions'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '183', 'type': 'argument_list', 'children': ['184']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'item'}, {'id': '185', 'type': 'expression_statement', 'children': ['186']}; {'id': '186', 'type': 'call', 'children': ['187', '190']}, {'id': '187', 'type': 'attribute', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'ensemble_suggestions'}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '190', 'type': 'argument_list', 'children': ['191']}, {'id': '191', 'type': 'keyword_argument', 'children': ['192', '193']}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '193', 'type': 'lambda', 'children': ['194', '196']}; {'id': '194', 'type': 'lambda_parameters', 'children': ['195']}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '196', 'type': 'unary_operator', 'children': ['197'], 'value': '-'}, {'id': '197', 'type': 'subscript', 'children': ['198', '199']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '199', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '200', 'type': 'expression_statement', 'children': ['201']}, {'id': '201', 'type': 'assignment', 'children': ['202', '203']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'filtered_ensemble_suggestions'}, {'id': '203', 'type': 'list_comprehension', 'children': ['204', '207', '212']}; {'id': '204', 'type': 'tuple', 'children': ['205', '206']}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'guid'}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'weight'}, {'id': '207', 'type': 'for_in_clause', 'children': ['208', '211']}; {'id': '208', 'type': 'tuple_pattern', 'children': ['209', '210']}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'guid'}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'weight'}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'ensemble_suggestions'}; {'id': '212', 'type': 'if_clause', 'children': ['213']}, {'id': '213', 'type': 'comparison_operator', 'children': ['214', '215'], 'value': 'not'}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'guid'}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'preinstalled_addon_ids'}; {'id': '216', 'type': 'expression_statement', 'children': ['217']}, {'id': '217', 'type': 'assignment', 'children': ['218', '219']}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'results'}, {'id': '219', 'type': 'subscript', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'filtered_ensemble_suggestions'}, {'id': '221', 'type': 'slice', 'children': ['222', '223']}; {'id': '222', 'type': 'colon', 'children': []}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '224', 'type': 'expression_statement', 'children': ['225']}, {'id': '225', 'type': 'assignment', 'children': ['226', '227']}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'log_data'}, {'id': '227', 'type': 'tuple', 'children': ['228', '231', '235']}; {'id': '228', 'type': 'subscript', 'children': ['229', '230']}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'client_data'}; {'id': '230', 'type': 'string', 'children': [], 'value': '"client_id"'}, {'id': '231', 'type': 'call', 'children': ['232', '233']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '233', 'type': 'argument_list', 'children': ['234']}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'ensemble_weights'}, {'id': '235', 'type': 'call', 'children': ['236', '237']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '237', 'type': 'argument_list', 'children': ['238']}; {'id': '238', 'type': 'list_comprehension', 'children': ['239', '242']}, {'id': '239', 'type': 'subscript', 'children': ['240', '241']}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'r'}, {'id': '241', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '242', 'type': 'for_in_clause', 'children': ['243', '244']}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'results'}, {'id': '245', 'type': 'expression_statement', 'children': ['246']}; {'id': '246', 'type': 'call', 'children': ['247', '252']}, {'id': '247', 'type': 'attribute', 'children': ['248', '251']}; {'id': '248', 'type': 'attribute', 'children': ['249', '250']}, {'id': '249', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'logger'}, {'id': '251', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '252', 'type': 'argument_list', 'children': ['253']}, {'id': '253', 'type': 'binary_operator', 'children': ['254', '255'], 'value': '%'}; {'id': '254', 'type': 'string', 'children': [], 'value': '"client_id: [%s], ensemble_weight: [%s], guids: [%s]"'}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'log_data'}; {'id': '256', 'type': 'return_statement', 'children': ['257']}, {'id': '257', 'type': 'identifier', 'children': [], 'value': 'results'}
def _recommend(self, client_data, limit, extra_data={}): self.logger.info("Ensemble recommend invoked") preinstalled_addon_ids = client_data.get("installed_addons", []) extended_limit = limit + len(preinstalled_addon_ids) flattened_results = [] ensemble_weights = self._weight_cache.getWeights() for rkey in self.RECOMMENDER_KEYS: recommender = self._recommender_map[rkey] if recommender.can_recommend(client_data): raw_results = recommender.recommend( client_data, extended_limit, extra_data ) reweighted_results = [] for guid, weight in raw_results: item = (guid, weight * ensemble_weights[rkey]) reweighted_results.append(item) flattened_results.extend(reweighted_results) flattened_results.sort(key=lambda item: item[0]) guid_grouper = itertools.groupby(flattened_results, lambda item: item[0]) ensemble_suggestions = [] for (guid, guid_group) in guid_grouper: weight_sum = sum([v for (g, v) in guid_group]) item = (guid, weight_sum) ensemble_suggestions.append(item) ensemble_suggestions.sort(key=lambda x: -x[1]) filtered_ensemble_suggestions = [ (guid, weight) for (guid, weight) in ensemble_suggestions if guid not in preinstalled_addon_ids ] results = filtered_ensemble_suggestions[:limit] log_data = ( client_data["client_id"], str(ensemble_weights), str([r[0] for r in results]), ) self.logger.info( "client_id: [%s], ensemble_weight: [%s], guids: [%s]" % log_data ) return results
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_build_features_caches'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6', '18', '30', '41', '50', '68', '98', '119', '158']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}, {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': '_donors_pool'}, {'id': '9', 'type': 'subscript', 'children': ['10', '17']}; {'id': '10', 'type': 'call', 'children': ['11', '16']}, {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_donors_pool'}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '16', 'type': 'argument_list', 'children': []}, {'id': '17', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}, {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_lr_curves'}, {'id': '21', 'type': 'subscript', 'children': ['22', '29']}; {'id': '22', 'type': 'call', 'children': ['23', '28']}, {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_lr_curves'}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '28', 'type': 'argument_list', 'children': []}, {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '38']}, {'id': '31', 'type': 'boolean_operator', 'children': ['32', '35'], 'value': 'or'}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '34'], 'value': 'is'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': '_donors_pool'}; {'id': '34', 'type': 'None', 'children': []}, {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'is'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_lr_curves'}, {'id': '37', 'type': 'None', 'children': []}; {'id': '38', 'type': 'block', 'children': ['39']}, {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'None', 'children': []}, {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '46']}, {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'num_donors'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': '_donors_pool'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}, {'id': '51', 'type': 'assignment', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'continuous_features'}, {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'zeros'}, {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'tuple', 'children': ['61', '64']}, {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'num_donors'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'CONTINUOUS_FEATURES'}; {'id': '68', 'type': 'for_statement', 'children': ['69', '72', '76']}, {'id': '69', 'type': 'pattern_list', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'idx'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': '_donors_pool'}; {'id': '76', 'type': 'block', 'children': ['77', '90']}, {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'features'}; {'id': '80', 'type': 'list_comprehension', 'children': ['81', '87']}, {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'get'}, {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'specified_key'}, {'id': '87', 'type': 'for_in_clause', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'specified_key'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'CONTINUOUS_FEATURES'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}, {'id': '91', 'type': 'assignment', 'children': ['92', '97']}; {'id': '92', 'type': 'subscript', 'children': ['93', '96']}, {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'continuous_features'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'idx'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'features'}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}, {'id': '99', 'type': 'assignment', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'categorical_features'}, {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'zeros'}, {'id': '107', 'type': 'argument_list', 'children': ['108', '116']}; {'id': '108', 'type': 'tuple', 'children': ['109', '112']}, {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'num_donors'}; {'id': '112', 'type': 'call', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'CATEGORICAL_FEATURES'}; {'id': '116', 'type': 'keyword_argument', 'children': ['117', '118']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '118', 'type': 'string', 'children': [], 'value': '"object"'}, {'id': '119', 'type': 'for_statement', 'children': ['120', '123', '127']}; {'id': '120', 'type': 'pattern_list', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'd'}, {'id': '123', 'type': 'call', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'enumerate'}, {'id': '125', 'type': 'argument_list', 'children': ['126']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': '_donors_pool'}, {'id': '127', 'type': 'block', 'children': ['128', '141']}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}, {'id': '129', 'type': 'assignment', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'features'}, {'id': '131', 'type': 'list_comprehension', 'children': ['132', '138']}; {'id': '132', 'type': 'call', 'children': ['133', '136']}, {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'd'}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'specified_key'}; {'id': '138', 'type': 'for_in_clause', 'children': ['139', '140']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'specified_key'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'CATEGORICAL_FEATURES'}, {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'assignment', 'children': ['143', '148']}, {'id': '143', 'type': 'subscript', 'children': ['144', '147']}; {'id': '144', 'type': 'attribute', 'children': ['145', '146']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'categorical_features'}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '148', 'type': 'call', 'children': ['149', '152']}, {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '152', 'type': 'argument_list', 'children': ['153', '155']}, {'id': '153', 'type': 'list', 'children': ['154'], 'value': '[features]'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'features'}, {'id': '155', 'type': 'keyword_argument', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'dtype'}, {'id': '157', 'type': 'string', 'children': [], 'value': '"object"'}; {'id': '158', 'type': 'expression_statement', 'children': ['159']}, {'id': '159', 'type': 'call', 'children': ['160', '165']}; {'id': '160', 'type': 'attribute', 'children': ['161', '164']}, {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'info'}, {'id': '165', 'type': 'argument_list', 'children': ['166']}
def _build_features_caches(self): _donors_pool = self._donors_pool.get()[0] _lr_curves = self._lr_curves.get()[0] if _donors_pool is None or _lr_curves is None: return None self.num_donors = len(_donors_pool) self.continuous_features = np.zeros((self.num_donors, len(CONTINUOUS_FEATURES))) for idx, d in enumerate(_donors_pool): features = [d.get(specified_key) for specified_key in CONTINUOUS_FEATURES] self.continuous_features[idx] = features self.categorical_features = np.zeros( (self.num_donors, len(CATEGORICAL_FEATURES)), dtype="object" ) for idx, d in enumerate(_donors_pool): features = [d.get(specified_key) for specified_key in CATEGORICAL_FEATURES] self.categorical_features[idx] = np.array([features], dtype="object") self.logger.info("Reconstructed matrices for similarity recommender")
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pdos_select'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'atoms'}, {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'spin'}; {'id': '10', 'type': 'None', 'children': []}, {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'l'}, {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '16', 'type': 'None', 'children': []}, {'id': '17', 'type': 'block', 'children': ['18', '49', '71', '85', '139', '151', '304']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}, {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'valid_m_values'}, {'id': '21', 'type': 'dictionary', 'children': ['22', '25', '31', '39']}; {'id': '22', 'type': 'pair', 'children': ['23', '24']}, {'id': '23', 'type': 'string', 'children': [], 'value': "'s'"}; {'id': '24', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '25', 'type': 'pair', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'p'"}, {'id': '27', 'type': 'list', 'children': ['28', '29', '30'], 'value': "[ 'x', 'y', 'z' ]"}; {'id': '28', 'type': 'string', 'children': [], 'value': "'x'"}, {'id': '29', 'type': 'string', 'children': [], 'value': "'y'"}; {'id': '30', 'type': 'string', 'children': [], 'value': "'z'"}, {'id': '31', 'type': 'pair', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'d'"}, {'id': '33', 'type': 'list', 'children': ['34', '35', '36', '37', '38'], 'value': "[ 'xy', 'yz', 'z2-r2', 'xz', 'x2-y2' ]"}; {'id': '34', 'type': 'string', 'children': [], 'value': "'xy'"}, {'id': '35', 'type': 'string', 'children': [], 'value': "'yz'"}; {'id': '36', 'type': 'string', 'children': [], 'value': "'z2-r2'"}, {'id': '37', 'type': 'string', 'children': [], 'value': "'xz'"}; {'id': '38', 'type': 'string', 'children': [], 'value': "'x2-y2'"}, {'id': '39', 'type': 'pair', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': "'f'"}, {'id': '41', 'type': 'list', 'children': ['42', '43', '44', '45', '46', '47', '48'], 'value': "[ 'y(3x2-y2)', 'xyz', 'yz2', 'z3', 'xz2', 'z(x2-y2)', 'x(x2-3y2)' ]"}; {'id': '42', 'type': 'string', 'children': [], 'value': "'y(3x2-y2)'"}, {'id': '43', 'type': 'string', 'children': [], 'value': "'xyz'"}; {'id': '44', 'type': 'string', 'children': [], 'value': "'yz2'"}, {'id': '45', 'type': 'string', 'children': [], 'value': "'z3'"}; {'id': '46', 'type': 'string', 'children': [], 'value': "'xz2'"}, {'id': '47', 'type': 'string', 'children': [], 'value': "'z(x2-y2)'"}; {'id': '48', 'type': 'string', 'children': [], 'value': "'x(x2-3y2)'"}, {'id': '49', 'type': 'if_statement', 'children': ['50', '52', '65']}; {'id': '50', 'type': 'not_operator', 'children': ['51']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'atoms'}; {'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': 'atom_idx'}; {'id': '56', 'type': 'call', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}, {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'range'}, {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'number_of_atoms'}, {'id': '65', 'type': 'else_clause', 'children': ['66']}; {'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': 'atom_idx'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'atoms'}, {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'to_return'}; {'id': '74', 'type': 'subscript', 'children': ['75', '78', '79', '81', '83']}, {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'pdos'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'atom_idx'}, {'id': '79', 'type': 'slice', 'children': ['80']}; {'id': '80', 'type': 'colon', 'children': []}, {'id': '81', 'type': 'slice', 'children': ['82']}; {'id': '82', 'type': 'colon', 'children': []}, {'id': '83', 'type': 'slice', 'children': ['84']}; {'id': '84', 'type': 'colon', 'children': []}, {'id': '85', 'type': 'if_statement', 'children': ['86', '88', '101', '111', '121', '132']}; {'id': '86', 'type': 'not_operator', 'children': ['87']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'spin'}; {'id': '88', 'type': 'block', 'children': ['89']}, {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'spin_idx'}; {'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': 'range'}, {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'ispin'}, {'id': '101', 'type': 'elif_clause', 'children': ['102', '105']}; {'id': '102', 'type': 'comparison_operator', 'children': ['103', '104'], 'value': 'is'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'spin'}; {'id': '104', 'type': 'string', 'children': [], 'value': "'up'"}, {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}, {'id': '107', 'type': 'assignment', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'spin_idx'}, {'id': '109', 'type': 'list', 'children': ['110'], 'value': '[0]'}; {'id': '110', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '111', 'type': 'elif_clause', 'children': ['112', '115']}; {'id': '112', 'type': 'comparison_operator', 'children': ['113', '114'], 'value': 'is'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'spin'}; {'id': '114', 'type': 'string', 'children': [], 'value': "'down'"}, {'id': '115', 'type': 'block', 'children': ['116']}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}, {'id': '117', 'type': 'assignment', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'spin_idx'}, {'id': '119', 'type': 'list', 'children': ['120'], 'value': '[1]'}; {'id': '120', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '121', 'type': 'elif_clause', 'children': ['122', '125']}; {'id': '122', 'type': 'comparison_operator', 'children': ['123', '124'], 'value': 'is'}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'spin'}; {'id': '124', 'type': 'string', 'children': [], 'value': "'both'"}, {'id': '125', 'type': 'block', 'children': ['126']}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}, {'id': '127', 'type': 'assignment', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'spin_idx'}, {'id': '129', 'type': 'list', 'children': ['130', '131'], 'value': '[0,1]'}; {'id': '130', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '131', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '132', 'type': 'else_clause', 'children': ['133']}, {'id': '133', 'type': 'block', 'children': ['134']}; {'id': '134', 'type': 'raise_statement', 'children': ['135']}, {'id': '135', 'type': 'call', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'string', 'children': [], 'value': '"valid spin values are \'up\', \'down\', and \'both\'. The default is \'both\'"'}, {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'assignment', 'children': ['141', '142']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'to_return'}; {'id': '142', 'type': 'subscript', 'children': ['143', '144', '146', '148', '150']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'to_return'}; {'id': '144', 'type': 'slice', 'children': ['145']}, {'id': '145', 'type': 'colon', 'children': []}; {'id': '146', 'type': 'slice', 'children': ['147']}, {'id': '147', 'type': 'colon', 'children': []}; {'id': '148', 'type': 'slice', 'children': ['149']}, {'id': '149', 'type': 'colon', 'children': []}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'spin_idx'}, {'id': '151', 'type': 'if_statement', 'children': ['152', '154', '167', '177', '216', '257', '300']}; {'id': '152', 'type': 'not_operator', 'children': ['153']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '154', 'type': 'block', 'children': ['155']}, {'id': '155', 'type': 'expression_statement', 'children': ['156']}; {'id': '156', 'type': 'assignment', 'children': ['157', '158']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'channel_idx'}; {'id': '158', 'type': 'call', 'children': ['159', '160']}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '160', 'type': 'argument_list', 'children': ['161']}, {'id': '161', 'type': 'call', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'range'}, {'id': '163', 'type': 'argument_list', 'children': ['164']}; {'id': '164', 'type': 'attribute', 'children': ['165', '166']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'number_of_channels'}, {'id': '167', 'type': 'elif_clause', 'children': ['168', '171']}; {'id': '168', 'type': 'comparison_operator', 'children': ['169', '170'], 'value': '=='}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '170', 'type': 'string', 'children': [], 'value': "'s'"}, {'id': '171', 'type': 'block', 'children': ['172']}; {'id': '172', 'type': 'expression_statement', 'children': ['173']}, {'id': '173', 'type': 'assignment', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'channel_idx'}, {'id': '175', 'type': 'list', 'children': ['176'], 'value': '[ 0 ]'}; {'id': '176', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '177', 'type': 'elif_clause', 'children': ['178', '181']}; {'id': '178', 'type': 'comparison_operator', 'children': ['179', '180'], 'value': '=='}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '180', 'type': 'string', 'children': [], 'value': "'p'"}, {'id': '181', 'type': 'block', 'children': ['182']}; {'id': '182', 'type': 'if_statement', 'children': ['183', '185', '193']}, {'id': '183', 'type': 'not_operator', 'children': ['184']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '185', 'type': 'block', 'children': ['186']}; {'id': '186', 'type': 'expression_statement', 'children': ['187']}, {'id': '187', 'type': 'assignment', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'channel_idx'}, {'id': '189', 'type': 'list', 'children': ['190', '191', '192'], 'value': '[ 1, 2, 3 ]'}; {'id': '190', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '191', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '192', 'type': 'integer', 'children': [], 'value': '3'}, {'id': '193', 'type': 'else_clause', 'children': ['194']}; {'id': '194', 'type': 'block', 'children': ['195']}, {'id': '195', 'type': 'expression_statement', 'children': ['196']}; {'id': '196', 'type': 'assignment', 'children': ['197', '198']}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'channel_idx'}; {'id': '198', 'type': 'list_comprehension', 'children': ['199', '202', '212']}, {'id': '199', 'type': 'binary_operator', 'children': ['200', '201'], 'value': '+'}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '201', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '202', 'type': 'for_in_clause', 'children': ['203', '206']}, {'id': '203', 'type': 'pattern_list', 'children': ['204', '205']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '206', 'type': 'call', 'children': ['207', '208']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '208', 'type': 'argument_list', 'children': ['209']}, {'id': '209', 'type': 'subscript', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'valid_m_values'}, {'id': '211', 'type': 'string', 'children': [], 'value': "'p'"}; {'id': '212', 'type': 'if_clause', 'children': ['213']}, {'id': '213', 'type': 'comparison_operator', 'children': ['214', '215'], 'value': 'in'}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '216', 'type': 'elif_clause', 'children': ['217', '220']}, {'id': '217', 'type': 'comparison_operator', 'children': ['218', '219'], 'value': '=='}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'l'}, {'id': '219', 'type': 'string', 'children': [], 'value': "'d'"}; {'id': '220', 'type': 'block', 'children': ['221']}, {'id': '221', 'type': 'if_statement', 'children': ['222', '224', '234']}; {'id': '222', 'type': 'not_operator', 'children': ['223']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '224', 'type': 'block', 'children': ['225']}, {'id': '225', 'type': 'expression_statement', 'children': ['226']}; {'id': '226', 'type': 'assignment', 'children': ['227', '228']}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'channel_idx'}; {'id': '228', 'type': 'list', 'children': ['229', '230', '231', '232', '233'], 'value': '[ 4, 5, 6, 7, 8 ]'}, {'id': '229', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '230', 'type': 'integer', 'children': [], 'value': '5'}, {'id': '231', 'type': 'integer', 'children': [], 'value': '6'}; {'id': '232', 'type': 'integer', 'children': [], 'value': '7'}, {'id': '233', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '234', 'type': 'else_clause', 'children': ['235']}, {'id': '235', 'type': 'block', 'children': ['236']}; {'id': '236', 'type': 'expression_statement', 'children': ['237']}, {'id': '237', 'type': 'assignment', 'children': ['238', '239']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'channel_idx'}, {'id': '239', 'type': 'list_comprehension', 'children': ['240', '243', '253']}; {'id': '240', 'type': 'binary_operator', 'children': ['241', '242'], 'value': '+'}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '242', 'type': 'integer', 'children': [], 'value': '4'}, {'id': '243', 'type': 'for_in_clause', 'children': ['244', '247']}; {'id': '244', 'type': 'pattern_list', 'children': ['245', '246']}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '247', 'type': 'call', 'children': ['248', '249']}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 'enumerate'}, {'id': '249', 'type': 'argument_list', 'children': ['250']}; {'id': '250', 'type': 'subscript', 'children': ['251', '252']}, {'id': '251', 'type': 'identifier', 'children': [], 'value': 'valid_m_values'}; {'id': '252', 'type': 'string', 'children': [], 'value': "'d'"}, {'id': '253', 'type': 'if_clause', 'children': ['254']}; {'id': '254', 'type': 'comparison_operator', 'children': ['255', '256'], 'value': 'in'}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '257', 'type': 'elif_clause', 'children': ['258', '261']}; {'id': '258', 'type': 'comparison_operator', 'children': ['259', '260'], 'value': '=='}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '260', 'type': 'string', 'children': [], 'value': "'f'"}, {'id': '261', 'type': 'block', 'children': ['262']}; {'id': '262', 'type': 'if_statement', 'children': ['263', '265', '277']}, {'id': '263', 'type': 'not_operator', 'children': ['264']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '265', 'type': 'block', 'children': ['266']}; {'id': '266', 'type': 'expression_statement', 'children': ['267']}, {'id': '267', 'type': 'assignment', 'children': ['268', '269']}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'channel_idx'}, {'id': '269', 'type': 'list', 'children': ['270', '271', '272', '273', '274', '275', '276'], 'value': '[ 9, 10, 11, 12, 13, 14, 15 ]'}; {'id': '270', 'type': 'integer', 'children': [], 'value': '9'}, {'id': '271', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '272', 'type': 'integer', 'children': [], 'value': '11'}, {'id': '273', 'type': 'integer', 'children': [], 'value': '12'}; {'id': '274', 'type': 'integer', 'children': [], 'value': '13'}, {'id': '275', 'type': 'integer', 'children': [], 'value': '14'}; {'id': '276', 'type': 'integer', 'children': [], 'value': '15'}, {'id': '277', 'type': 'else_clause', 'children': ['278']}; {'id': '278', 'type': 'block', 'children': ['279']}, {'id': '279', 'type': 'expression_statement', 'children': ['280']}; {'id': '280', 'type': 'assignment', 'children': ['281', '282']}, {'id': '281', 'type': 'identifier', 'children': [], 'value': 'channel_idx'}; {'id': '282', 'type': 'list_comprehension', 'children': ['283', '286', '296']}, {'id': '283', 'type': 'binary_operator', 'children': ['284', '285'], 'value': '+'}; {'id': '284', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '285', 'type': 'integer', 'children': [], 'value': '9'}; {'id': '286', 'type': 'for_in_clause', 'children': ['287', '290']}, {'id': '287', 'type': 'pattern_list', 'children': ['288', '289']}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '289', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '290', 'type': 'call', 'children': ['291', '292']}, {'id': '291', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '292', 'type': 'argument_list', 'children': ['293']}, {'id': '293', 'type': 'subscript', 'children': ['294', '295']}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'valid_m_values'}, {'id': '295', 'type': 'string', 'children': [], 'value': "'f'"}; {'id': '296', 'type': 'if_clause', 'children': ['297']}, {'id': '297', 'type': 'comparison_operator', 'children': ['298', '299'], 'value': 'in'}; {'id': '298', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '299', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '300', 'type': 'else_clause', 'children': ['301']}, {'id': '301', 'type': 'block', 'children': ['302']}; {'id': '302', 'type': 'raise_statement', 'children': ['303']}, {'id': '303', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '304', 'type': 'return_statement', 'children': ['305']}, {'id': '305', 'type': 'subscript', 'children': ['306', '307', '309', '311', '312']}; {'id': '306', 'type': 'identifier', 'children': [], 'value': 'to_return'}, {'id': '307', 'type': 'slice', 'children': ['308']}; {'id': '308', 'type': 'colon', 'children': []}, {'id': '309', 'type': 'slice', 'children': ['310']}; {'id': '310', 'type': 'colon', 'children': []}, {'id': '311', 'type': 'identifier', 'children': [], 'value': 'channel_idx'}; {'id': '312', 'type': 'slice', 'children': ['313']}, {'id': '313', 'type': 'colon', 'children': []}
def pdos_select( self, atoms=None, spin=None, l=None, m=None ): valid_m_values = { 's': [], 'p': [ 'x', 'y', 'z' ], 'd': [ 'xy', 'yz', 'z2-r2', 'xz', 'x2-y2' ], 'f': [ 'y(3x2-y2)', 'xyz', 'yz2', 'z3', 'xz2', 'z(x2-y2)', 'x(x2-3y2)' ] } if not atoms: atom_idx = list(range( self.number_of_atoms )) else: atom_idx = atoms to_return = self.pdos[ atom_idx, :, :, : ] if not spin: spin_idx = list(range( self.ispin )) elif spin is 'up': spin_idx = [0] elif spin is 'down': spin_idx = [1] elif spin is 'both': spin_idx = [0,1] else: raise ValueError( "valid spin values are 'up', 'down', and 'both'. The default is 'both'" ) to_return = to_return[ :, :, :, spin_idx ] if not l: channel_idx = list(range( self.number_of_channels )) elif l == 's': channel_idx = [ 0 ] elif l == 'p': if not m: channel_idx = [ 1, 2, 3 ] else: channel_idx = [ i+1 for i, v in enumerate( valid_m_values['p'] ) if v in m ] elif l == 'd': if not m: channel_idx = [ 4, 5, 6, 7, 8 ] else: channel_idx = [ i+4 for i, v in enumerate( valid_m_values['d'] ) if v in m ] elif l == 'f': if not m: channel_idx = [ 9, 10, 11, 12, 13, 14, 15 ] else: channel_idx = [ i+9 for i, v in enumerate( valid_m_values['f'] ) if v in m ] else: raise ValueError return to_return[ :, :, channel_idx, : ]
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_describe'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '24', '210']}, {'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': 'name'}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'children'}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}, {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'is_placeholder'}, {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'isinstance'}, {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'logger'}, {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'logging'}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'PlaceHolder'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '26', '32']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'is_placeholder'}; {'id': '26', 'type': 'block', 'children': ['27']}, {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'yield', 'children': ['29']}, {'id': '29', 'type': 'binary_operator', 'children': ['30', '31'], 'value': '%'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'<--[%s]'"}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '32', 'type': 'else_clause', 'children': ['33']}, {'id': '33', 'type': 'block', 'children': ['34', '48', '71', '78', '106', '143', '152', '160', '177']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}, {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'parent_is_correct'}, {'id': '37', 'type': 'boolean_operator', 'children': ['38', '42'], 'value': 'or'}; {'id': '38', 'type': 'parenthesized_expression', 'children': ['39']}, {'id': '39', 'type': 'comparison_operator', 'children': ['40', '41'], 'value': 'is'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'parent'}, {'id': '41', 'type': 'None', 'children': []}; {'id': '42', 'type': 'parenthesized_expression', 'children': ['43']}, {'id': '43', 'type': 'comparison_operator', 'children': ['44', '47'], 'value': 'is'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'parent'}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '53', '58', '65']}, {'id': '49', 'type': 'not_operator', 'children': ['50']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'propagate'}, {'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': 'arrow'}, {'id': '57', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '58', 'type': 'elif_clause', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'parent_is_correct'}; {'id': '60', 'type': 'block', 'children': ['61']}, {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'arrow'}; {'id': '64', 'type': 'string', 'children': [], 'value': "'<--'"}, {'id': '65', 'type': 'else_clause', 'children': ['66']}; {'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': 'arrow'}; {'id': '70', 'type': 'string', 'children': [], 'value': "' !-'"}, {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'yield', 'children': ['73']}, {'id': '73', 'type': 'binary_operator', 'children': ['74', '75'], 'value': '%'}; {'id': '74', 'type': 'string', 'children': [], 'value': '\'%s"%s"\''}, {'id': '75', 'type': 'tuple', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'arrow'}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '78', 'type': 'if_statement', 'children': ['79', '81']}, {'id': '79', 'type': 'not_operator', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'parent_is_correct'}, {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'if_statement', 'children': ['83', '88', '93']}, {'id': '83', 'type': 'comparison_operator', 'children': ['84', '87'], 'value': 'is'}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'parent'}, {'id': '87', 'type': 'None', 'children': []}; {'id': '88', 'type': 'block', 'children': ['89']}, {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'yield', 'children': ['91']}, {'id': '91', 'type': 'parenthesized_expression', 'children': ['92']}; {'id': '92', 'type': 'string', 'children': [], 'value': "' Broken .parent is None, so messages stop here'"}, {'id': '93', 'type': 'else_clause', 'children': ['94']}; {'id': '94', 'type': 'block', 'children': ['95']}, {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'yield', 'children': ['97']}, {'id': '97', 'type': 'parenthesized_expression', 'children': ['98']}; {'id': '98', 'type': 'binary_operator', 'children': ['99', '100'], 'value': '%'}, {'id': '99', 'type': 'string', 'children': [], 'value': "' Broken .parent redirects messages to %r instead'"}; {'id': '100', 'type': 'tuple', 'children': ['101']}, {'id': '101', 'type': 'attribute', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'parent'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '106', 'type': 'if_statement', 'children': ['107', '114', '129']}, {'id': '107', 'type': 'comparison_operator', 'children': ['108', '111'], 'value': '=='}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'level'}, {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'logging'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'NOTSET'}; {'id': '114', 'type': 'block', 'children': ['115']}, {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'yield', 'children': ['117']}, {'id': '117', 'type': 'binary_operator', 'children': ['118', '119'], 'value': '+'}; {'id': '118', 'type': 'string', 'children': [], 'value': "' Level NOTSET so inherits level '"}, {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'getLevelName'}, {'id': '123', 'type': 'argument_list', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '128']}, {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'logger'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'getEffectiveLevel'}; {'id': '128', 'type': 'argument_list', 'children': []}, {'id': '129', 'type': 'else_clause', 'children': ['130']}; {'id': '130', 'type': 'block', 'children': ['131']}, {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'yield', 'children': ['133']}, {'id': '133', 'type': 'binary_operator', 'children': ['134', '135'], 'value': '+'}; {'id': '134', 'type': 'string', 'children': [], 'value': "' Level '"}, {'id': '135', 'type': 'call', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'getLevelName'}, {'id': '139', 'type': 'argument_list', 'children': ['140']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'level'}, {'id': '143', 'type': 'if_statement', 'children': ['144', '148']}; {'id': '144', 'type': 'not_operator', 'children': ['145']}, {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'logger'}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'propagate'}; {'id': '148', 'type': 'block', 'children': ['149']}, {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'yield', 'children': ['151']}, {'id': '151', 'type': 'string', 'children': [], 'value': "' Propagate OFF'"}; {'id': '152', 'type': 'if_statement', 'children': ['153', '156']}, {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'logger'}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'disabled'}; {'id': '156', 'type': 'block', 'children': ['157']}, {'id': '157', 'type': 'expression_statement', 'children': ['158']}; {'id': '158', 'type': 'yield', 'children': ['159']}, {'id': '159', 'type': 'string', 'children': [], 'value': "' Disabled'"}; {'id': '160', 'type': 'for_statement', 'children': ['161', '162', '168']}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '162', 'type': 'call', 'children': ['163', '164']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '164', 'type': 'argument_list', 'children': ['165', '166', '167']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '166', 'type': 'string', 'children': [], 'value': "'filters'"}, {'id': '167', 'type': 'tuple', 'children': []}; {'id': '168', 'type': 'block', 'children': ['169']}, {'id': '169', 'type': 'expression_statement', 'children': ['170']}; {'id': '170', 'type': 'yield', 'children': ['171']}, {'id': '171', 'type': 'binary_operator', 'children': ['172', '173'], 'value': '%'}; {'id': '172', 'type': 'string', 'children': [], 'value': "' Filter %s'"}, {'id': '173', 'type': 'call', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'describe_filter'}, {'id': '175', 'type': 'argument_list', 'children': ['176']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '177', 'type': 'for_statement', 'children': ['178', '179', '185']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'h'}, {'id': '179', 'type': 'call', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'getattr'}, {'id': '181', 'type': 'argument_list', 'children': ['182', '183', '184']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'logger'}, {'id': '183', 'type': 'string', 'children': [], 'value': "'handlers'"}; {'id': '184', 'type': 'tuple', 'children': []}, {'id': '185', 'type': 'block', 'children': ['186', '193', '201']}; {'id': '186', 'type': 'expression_statement', 'children': ['187']}, {'id': '187', 'type': 'assignment', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'g'}, {'id': '189', 'type': 'call', 'children': ['190', '191']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'describe_handler'}, {'id': '191', 'type': 'argument_list', 'children': ['192']}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'h'}, {'id': '193', 'type': 'expression_statement', 'children': ['194']}; {'id': '194', 'type': 'yield', 'children': ['195']}, {'id': '195', 'type': 'binary_operator', 'children': ['196', '197'], 'value': '%'}; {'id': '196', 'type': 'string', 'children': [], 'value': "' Handler %s'"}, {'id': '197', 'type': 'call', 'children': ['198', '199']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'next'}, {'id': '199', 'type': 'argument_list', 'children': ['200']}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'g'}, {'id': '201', 'type': 'for_statement', 'children': ['202', '203', '204']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '204', 'type': 'block', 'children': ['205']}, {'id': '205', 'type': 'expression_statement', 'children': ['206']}; {'id': '206', 'type': 'yield', 'children': ['207']}, {'id': '207', 'type': 'binary_operator', 'children': ['208', '209'], 'value': '+'}; {'id': '208', 'type': 'string', 'children': [], 'value': "' '"}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '210', 'type': 'if_statement', 'children': ['211', '212']}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '212', 'type': 'block', 'children': ['213', '221', '228']}, {'id': '213', 'type': 'if_statement', 'children': ['214', '216']}; {'id': '214', 'type': 'not_operator', 'children': ['215']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'is_placeholder'}; {'id': '216', 'type': 'block', 'children': ['217']}, {'id': '217', 'type': 'expression_statement', 'children': ['218']}; {'id': '218', 'type': 'assignment', 'children': ['219', '220']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'logger'}, {'id': '221', 'type': 'expression_statement', 'children': ['222']}; {'id': '222', 'type': 'assignment', 'children': ['223', '224']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'last_child'}; {'id': '224', 'type': 'subscript', 'children': ['225', '226']}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '226', 'type': 'unary_operator', 'children': ['227'], 'value': '-'}, {'id': '227', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '228', 'type': 'for_statement', 'children': ['229', '230', '231']}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'children'}, {'id': '231', 'type': 'block', 'children': ['232', '240', '243', '251', '266']}; {'id': '232', 'type': 'expression_statement', 'children': ['233']}, {'id': '233', 'type': 'assignment', 'children': ['234', '235']}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'g'}, {'id': '235', 'type': 'call', 'children': ['236', '237']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': '_describe'}, {'id': '237', 'type': 'argument_list', 'children': ['238', '239']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'child'}, {'id': '239', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '240', 'type': 'expression_statement', 'children': ['241']}, {'id': '241', 'type': 'yield', 'children': ['242']}; {'id': '242', 'type': 'string', 'children': [], 'value': "' |'"}, {'id': '243', 'type': 'expression_statement', 'children': ['244']}; {'id': '244', 'type': 'yield', 'children': ['245']}, {'id': '245', 'type': 'binary_operator', 'children': ['246', '247'], 'value': '+'}; {'id': '246', 'type': 'string', 'children': [], 'value': "' o'"}, {'id': '247', 'type': 'call', 'children': ['248', '249']}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 'next'}, {'id': '249', 'type': 'argument_list', 'children': ['250']}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'g'}, {'id': '251', 'type': 'if_statement', 'children': ['252', '255', '260']}; {'id': '252', 'type': 'comparison_operator', 'children': ['253', '254'], 'value': 'is'}, {'id': '253', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'last_child'}, {'id': '255', 'type': 'block', 'children': ['256']}; {'id': '256', 'type': 'expression_statement', 'children': ['257']}, {'id': '257', 'type': 'assignment', 'children': ['258', '259']}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'prefix'}, {'id': '259', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '260', 'type': 'else_clause', 'children': ['261']}, {'id': '261', 'type': 'block', 'children': ['262']}; {'id': '262', 'type': 'expression_statement', 'children': ['263']}, {'id': '263', 'type': 'assignment', 'children': ['264', '265']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'prefix'}, {'id': '265', 'type': 'string', 'children': [], 'value': "' |'"}; {'id': '266', 'type': 'for_statement', 'children': ['267', '268', '269']}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'g'}, {'id': '269', 'type': 'block', 'children': ['270']}; {'id': '270', 'type': 'expression_statement', 'children': ['271']}, {'id': '271', 'type': 'yield', 'children': ['272']}; {'id': '272', 'type': 'binary_operator', 'children': ['273', '274'], 'value': '+'}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'prefix'}
def _describe(node, parent): name, logger, children = node is_placeholder = isinstance(logger, logging.PlaceHolder) if is_placeholder: yield '<--[%s]' % name else: parent_is_correct = (parent is None) or (logger.parent is parent) if not logger.propagate: arrow = ' ' elif parent_is_correct: arrow = '<--' else: arrow = ' !-' yield '%s"%s"' % (arrow, name) if not parent_is_correct: if logger.parent is None: yield (' Broken .parent is None, so messages stop here') else: yield (' Broken .parent redirects messages to %r instead' % (logger.parent.name,)) if logger.level == logging.NOTSET: yield ' Level NOTSET so inherits level ' + logging.getLevelName( logger.getEffectiveLevel()) else: yield ' Level ' + logging.getLevelName(logger.level) if not logger.propagate: yield ' Propagate OFF' if logger.disabled: yield ' Disabled' for f in getattr(logger, 'filters', ()): yield ' Filter %s' % describe_filter(f) for h in getattr(logger, 'handlers', ()): g = describe_handler(h) yield ' Handler %s' % next(g) for line in g: yield ' ' + line if children: if not is_placeholder: parent = logger last_child = children[-1] for child in children: g = _describe(child, parent) yield ' |' yield ' o' + next(g) if child is last_child: prefix = ' ' else: prefix = ' |' for line in g: yield prefix + line
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resample'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6', '21', '27', '33', '60', '81', '93', '101', '109', '134', '162', '184']}; {'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': 'just_resampled'}; {'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': 'warnings'}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '20']}, {'id': '17', 'type': 'concatenated_string', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"Resampling without additional data; this may not perform as "'}, {'id': '19', 'type': 'string', 'children': [], 'value': '"desired."'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ResamplerWarning'}, {'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': '_just_resampled'}; {'id': '26', 'type': 'True', 'children': []}, {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'augmented_assignment', 'children': ['29', '32'], 'value': '+='}, {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '31', 'type': 'identifier', 'children': [], 'value': '_resample_count'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '33', 'type': 'if_statement', 'children': ['34', '39']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '38'], 'value': 'is'}, {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': '_resampling_divergences'}; {'id': '38', 'type': 'None', 'children': []}, {'id': '39', 'type': 'block', 'children': ['40', '50']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}, {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'old_locs'}, {'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': 'particle_locations'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'copy'}, {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}, {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'old_weights'}, {'id': '53', 'type': 'call', 'children': ['54', '59']}; {'id': '54', 'type': 'attribute', 'children': ['55', '58']}, {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'particle_weights'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'copy'}, {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'if_statement', 'children': ['61', '64']}, {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': '_debug_resampling'}; {'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': 'old_mean'}; {'id': '68', 'type': 'call', 'children': ['69', '72']}, {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'est_mean'}; {'id': '72', 'type': 'argument_list', 'children': []}, {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'old_cov'}; {'id': '76', 'type': 'call', 'children': ['77', '80']}, {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'est_covariance_mtx'}; {'id': '80', 'type': 'argument_list', 'children': []}, {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'new_distribution'}; {'id': '84', 'type': 'call', 'children': ['85', '88']}, {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'resampler'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '92']}, {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '98']}, {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'particle_weights'}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'new_distribution'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'particle_weights'}, {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '106']}, {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'particle_locations'}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'new_distribution'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'particle_locations'}, {'id': '109', 'type': 'if_statement', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': '_canonicalize'}, {'id': '113', 'type': 'block', 'children': ['114']}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}, {'id': '115', 'type': 'assignment', 'children': ['116', '124']}; {'id': '116', 'type': 'subscript', 'children': ['117', '120', '122']}, {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'particle_locations'}; {'id': '120', 'type': 'slice', 'children': ['121']}, {'id': '121', 'type': 'colon', 'children': []}; {'id': '122', 'type': 'slice', 'children': ['123']}, {'id': '123', 'type': 'colon', 'children': []}; {'id': '124', 'type': 'call', 'children': ['125', '130']}, {'id': '125', 'type': 'attribute', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'model'}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'canonicalize'}; {'id': '130', 'type': 'argument_list', 'children': ['131']}, {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'particle_locations'}; {'id': '134', 'type': 'try_statement', 'children': ['135', '144']}, {'id': '135', 'type': 'block', 'children': ['136']}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}, {'id': '137', 'type': 'call', 'children': ['138', '143']}; {'id': '138', 'type': 'attribute', 'children': ['139', '142']}, {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'clear_cache'}, {'id': '143', 'type': 'argument_list', 'children': []}; {'id': '144', 'type': 'except_clause', 'children': ['145', '149']}, {'id': '145', 'type': 'as_pattern', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'Exception'}, {'id': '147', 'type': 'as_pattern_target', 'children': ['148']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'e'}, {'id': '149', 'type': 'block', 'children': ['150']}; {'id': '150', 'type': 'expression_statement', 'children': ['151']}, {'id': '151', 'type': 'call', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'warnings'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'warn'}, {'id': '155', 'type': 'argument_list', 'children': ['156']}; {'id': '156', 'type': 'call', 'children': ['157', '160']}, {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'string', 'children': [], 'value': '"Exception raised when clearing model cache: {}. Ignoring."'}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '160', 'type': 'argument_list', 'children': ['161']}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '162', 'type': 'if_statement', 'children': ['163', '168']}, {'id': '163', 'type': 'comparison_operator', 'children': ['164', '167'], 'value': 'is'}; {'id': '164', 'type': 'attribute', 'children': ['165', '166']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': '_resampling_divergences'}, {'id': '167', 'type': 'None', 'children': []}; {'id': '168', 'type': 'block', 'children': ['169']}, {'id': '169', 'type': 'expression_statement', 'children': ['170']}; {'id': '170', 'type': 'call', 'children': ['171', '176']}, {'id': '171', 'type': 'attribute', 'children': ['172', '175']}; {'id': '172', 'type': 'attribute', 'children': ['173', '174']}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': '_resampling_divergences'}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '176', 'type': 'argument_list', 'children': ['177']}, {'id': '177', 'type': 'call', 'children': ['178', '181']}; {'id': '178', 'type': 'attribute', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '180', 'type': 'identifier', 'children': [], 'value': '_kl_divergence'}, {'id': '181', 'type': 'argument_list', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'old_locs'}, {'id': '183', 'type': 'identifier', 'children': [], 'value': 'old_weights'}; {'id': '184', 'type': 'if_statement', 'children': ['185', '188']}, {'id': '185', 'type': 'attribute', 'children': ['186', '187']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '187', 'type': 'identifier', 'children': [], 'value': '_debug_resampling'}; {'id': '188', 'type': 'block', 'children': ['189', '197', '205']}, {'id': '189', 'type': 'expression_statement', 'children': ['190']}; {'id': '190', 'type': 'assignment', 'children': ['191', '192']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'new_mean'}; {'id': '192', 'type': 'call', 'children': ['193', '196']}, {'id': '193', 'type': 'attribute', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'est_mean'}; {'id': '196', 'type': 'argument_list', 'children': []}, {'id': '197', 'type': 'expression_statement', 'children': ['198']}; {'id': '198', 'type': 'assignment', 'children': ['199', '200']}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'new_cov'}; {'id': '200', 'type': 'call', 'children': ['201', '204']}, {'id': '201', 'type': 'attribute', 'children': ['202', '203']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'est_covariance_mtx'}; {'id': '204', 'type': 'argument_list', 'children': []}, {'id': '205', 'type': 'expression_statement', 'children': ['206']}; {'id': '206', 'type': 'call', 'children': ['207', '210']}, {'id': '207', 'type': 'attribute', 'children': ['208', '209']}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'logger'}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '210', 'type': 'argument_list', 'children': ['211']}, {'id': '211', 'type': 'call', 'children': ['212', '215']}; {'id': '212', 'type': 'attribute', 'children': ['213', '214']}, {'id': '213', 'type': 'string', 'children': [], 'value': '"Resampling changed mean by {}. Norm change in cov: {}."'}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'format'}, {'id': '215', 'type': 'argument_list', 'children': ['216', '219']}; {'id': '216', 'type': 'binary_operator', 'children': ['217', '218'], 'value': '-'}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'old_mean'}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'new_mean'}, {'id': '219', 'type': 'call', 'children': ['220', '225']}; {'id': '220', 'type': 'attribute', 'children': ['221', '224']}, {'id': '221', 'type': 'attribute', 'children': ['222', '223']}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'linalg'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'norm'}, {'id': '225', 'type': 'argument_list', 'children': ['226']}; {'id': '226', 'type': 'binary_operator', 'children': ['227', '228'], 'value': '-'}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'new_cov'}
def resample(self): if self.just_resampled: warnings.warn( "Resampling without additional data; this may not perform as " "desired.", ResamplerWarning ) self._just_resampled = True self._resample_count += 1 if self._resampling_divergences is not None: old_locs = self.particle_locations.copy() old_weights = self.particle_weights.copy() if self._debug_resampling: old_mean = self.est_mean() old_cov = self.est_covariance_mtx() new_distribution = self.resampler(self.model, self) self.particle_weights = new_distribution.particle_weights self.particle_locations = new_distribution.particle_locations if self._canonicalize: self.particle_locations[:, :] = self.model.canonicalize(self.particle_locations) try: self.model.clear_cache() except Exception as e: warnings.warn("Exception raised when clearing model cache: {}. Ignoring.".format(e)) if self._resampling_divergences is not None: self._resampling_divergences.append( self._kl_divergence(old_locs, old_weights) ) if self._debug_resampling: new_mean = self.est_mean() new_cov = self.est_covariance_mtx() logger.debug("Resampling changed mean by {}. Norm change in cov: {}.".format( old_mean - new_mean, np.linalg.norm(new_cov - old_cov) ))
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'expected_information_gain'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'expparams'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '15', '61', '81', '105', '129', '165', '179', '201', '224']}, {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'r'}, {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'n_eps'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'expparams'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'size'}, {'id': '15', 'type': 'if_statement', 'children': ['16', '26']}; {'id': '16', 'type': 'boolean_operator', 'children': ['17', '20'], 'value': 'and'}, {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': '>'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'n_eps'}, {'id': '19', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '20', 'type': 'not_operator', 'children': ['21']}, {'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': 'model'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'is_n_outcomes_constant'}; {'id': '26', 'type': 'block', 'children': ['27', '36', '59']}, {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'risk'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}, {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'empty'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'n_eps'}; {'id': '36', 'type': 'for_statement', 'children': ['37', '38', '42']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'n_eps'}; {'id': '42', 'type': 'block', 'children': ['43']}, {'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': 'risk'}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '48', 'type': 'call', 'children': ['49', '52']}, {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'expected_information_gain'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}, {'id': '53', 'type': 'subscript', 'children': ['54', '55', '56']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'expparams'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'newaxis'}, {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'risk'}, {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '64', 'type': 'attribute', 'children': ['65', '80']}, {'id': '65', 'type': 'subscript', 'children': ['66', '79']}; {'id': '66', 'type': 'call', 'children': ['67', '72']}, {'id': '67', 'type': 'attribute', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'model'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}, {'id': '73', 'type': 'subscript', 'children': ['74', '75', '76']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'expparams'}, {'id': '75', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'newaxis'}, {'id': '79', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'values'}, {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '87']}, {'id': '83', 'type': 'pattern_list', 'children': ['84', '85', '86']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'w_hyp'}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'L'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'N'}, {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'hypothetical_update'}, {'id': '91', 'type': 'argument_list', 'children': ['92', '98', '99', '102']}; {'id': '92', 'type': 'subscript', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '94', 'type': 'slice', 'children': ['95', '96']}, {'id': '95', 'type': 'colon', 'children': []}; {'id': '96', 'type': 'unary_operator', 'children': ['97'], 'value': '-'}, {'id': '97', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'expparams'}, {'id': '99', 'type': 'keyword_argument', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'return_normalization'}, {'id': '101', 'type': 'True', 'children': []}; {'id': '102', 'type': 'keyword_argument', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'return_likelihood'}; {'id': '104', 'type': 'True', 'children': []}, {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'w_hyp_last_outcome'}; {'id': '108', 'type': 'binary_operator', 'children': ['109', '120'], 'value': '*'}, {'id': '109', 'type': 'parenthesized_expression', 'children': ['110']}; {'id': '110', 'type': 'binary_operator', 'children': ['111', '112'], 'value': '-'}, {'id': '111', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '112', 'type': 'call', 'children': ['113', '116']}, {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'L'}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}, {'id': '117', 'type': 'keyword_argument', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'axis'}, {'id': '119', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '120', 'type': 'subscript', 'children': ['121', '124', '127']}, {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'particle_weights'}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'newaxis'}, {'id': '127', 'type': 'slice', 'children': ['128']}; {'id': '128', 'type': 'colon', 'children': []}, {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'assignment', 'children': ['131', '132']}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '132', 'type': 'call', 'children': ['133', '136']}, {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'concatenate'}; {'id': '136', 'type': 'argument_list', 'children': ['137', '162']}, {'id': '137', 'type': 'list', 'children': ['138', '145'], 'value': '[N[:,:,0], np.sum(w_hyp_last_outcome[np.newaxis,:,:], axis=2)]'}; {'id': '138', 'type': 'subscript', 'children': ['139', '140', '142', '144']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '140', 'type': 'slice', 'children': ['141']}, {'id': '141', 'type': 'colon', 'children': []}; {'id': '142', 'type': 'slice', 'children': ['143']}, {'id': '143', 'type': 'colon', 'children': []}; {'id': '144', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '145', 'type': 'call', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'sum'}, {'id': '149', 'type': 'argument_list', 'children': ['150', '159']}; {'id': '150', 'type': 'subscript', 'children': ['151', '152', '155', '157']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'w_hyp_last_outcome'}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'newaxis'}, {'id': '155', 'type': 'slice', 'children': ['156']}; {'id': '156', 'type': 'colon', 'children': []}, {'id': '157', 'type': 'slice', 'children': ['158']}; {'id': '158', 'type': 'colon', 'children': []}, {'id': '159', 'type': 'keyword_argument', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'axis'}, {'id': '161', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '162', 'type': 'keyword_argument', 'children': ['163', '164']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '164', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '165', 'type': 'expression_statement', 'children': ['166']}; {'id': '166', 'type': 'assignment', 'children': ['167', '168']}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'w_hyp_last_outcome'}; {'id': '168', 'type': 'binary_operator', 'children': ['169', '170'], 'value': '/'}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'w_hyp_last_outcome'}; {'id': '170', 'type': 'subscript', 'children': ['171', '172', '174', '176']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '172', 'type': 'unary_operator', 'children': ['173'], 'value': '-'}, {'id': '173', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '174', 'type': 'slice', 'children': ['175']}, {'id': '175', 'type': 'colon', 'children': []}; {'id': '176', 'type': 'attribute', 'children': ['177', '178']}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'newaxis'}, {'id': '179', 'type': 'expression_statement', 'children': ['180']}; {'id': '180', 'type': 'assignment', 'children': ['181', '182']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'w_hyp'}; {'id': '182', 'type': 'call', 'children': ['183', '186']}, {'id': '183', 'type': 'attribute', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'concatenate'}; {'id': '186', 'type': 'argument_list', 'children': ['187', '198']}, {'id': '187', 'type': 'list', 'children': ['188', '189'], 'value': '[w_hyp, w_hyp_last_outcome[np.newaxis,:,:]]'}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'w_hyp'}, {'id': '189', 'type': 'subscript', 'children': ['190', '191', '194', '196']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'w_hyp_last_outcome'}, {'id': '191', 'type': 'attribute', 'children': ['192', '193']}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'newaxis'}; {'id': '194', 'type': 'slice', 'children': ['195']}, {'id': '195', 'type': 'colon', 'children': []}; {'id': '196', 'type': 'slice', 'children': ['197']}, {'id': '197', 'type': 'colon', 'children': []}; {'id': '198', 'type': 'keyword_argument', 'children': ['199', '200']}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '200', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '201', 'type': 'expression_statement', 'children': ['202']}; {'id': '202', 'type': 'assignment', 'children': ['203', '204']}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'KLD'}; {'id': '204', 'type': 'call', 'children': ['205', '208']}, {'id': '205', 'type': 'attribute', 'children': ['206', '207']}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'np'}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '208', 'type': 'argument_list', 'children': ['209', '221']}, {'id': '209', 'type': 'binary_operator', 'children': ['210', '211'], 'value': '*'}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'w_hyp'}, {'id': '211', 'type': 'call', 'children': ['212', '215']}; {'id': '212', 'type': 'attribute', 'children': ['213', '214']}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'log'}, {'id': '215', 'type': 'argument_list', 'children': ['216']}; {'id': '216', 'type': 'binary_operator', 'children': ['217', '218'], 'value': '/'}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'w_hyp'}; {'id': '218', 'type': 'attribute', 'children': ['219', '220']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'particle_weights'}, {'id': '221', 'type': 'keyword_argument', 'children': ['222', '223']}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'axis'}, {'id': '223', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '224', 'type': 'return_statement', 'children': ['225']}, {'id': '225', 'type': 'call', 'children': ['226', '229']}; {'id': '226', 'type': 'attribute', 'children': ['227', '228']}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'sum'}, {'id': '229', 'type': 'argument_list', 'children': ['230', '233']}; {'id': '230', 'type': 'binary_operator', 'children': ['231', '232'], 'value': '*'}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'KLD'}, {'id': '233', 'type': 'keyword_argument', 'children': ['234', '235']}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'axis'}, {'id': '235', 'type': 'integer', 'children': [], 'value': '0'}
def expected_information_gain(self, expparams): r n_eps = expparams.size if n_eps > 1 and not self.model.is_n_outcomes_constant: risk = np.empty(n_eps) for idx in range(n_eps): risk[idx] = self.expected_information_gain(expparams[idx, np.newaxis]) return risk os = self.model.domain(expparams[0,np.newaxis])[0].values w_hyp, L, N = self.hypothetical_update( os[:-1], expparams, return_normalization=True, return_likelihood=True ) w_hyp_last_outcome = (1 - L.sum(axis=0)) * self.particle_weights[np.newaxis, :] N = np.concatenate([N[:,:,0], np.sum(w_hyp_last_outcome[np.newaxis,:,:], axis=2)], axis=0) w_hyp_last_outcome = w_hyp_last_outcome / N[-1,:,np.newaxis] w_hyp = np.concatenate([w_hyp, w_hyp_last_outcome[np.newaxis,:,:]], axis=0) KLD = np.sum(w_hyp * np.log(w_hyp / self.particle_weights), axis=2) return np.sum(N * KLD, axis=0)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iter_actions'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6', '10', '27', '36', '40', '54', '200', '214']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}, {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ns'}, {'id': '9', 'type': 'string', 'children': [], 'value': "'{urn:schemas-upnp-org:service-1-0}'"}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}, {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'scpd_body'}, {'id': '13', 'type': 'attribute', 'children': ['14', '26']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}, {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'requests'}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}, {'id': '19', 'type': 'binary_operator', 'children': ['20', '23'], 'value': '+'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'base_url'}, {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'scpd_url'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'content'}, {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}, {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'XML'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'fromstring'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'scpd_body'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}, {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'vartypes'}, {'id': '39', 'type': 'dictionary', 'children': []}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}, {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'srvStateTables'}, {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'findall'}, {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}, {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'string', 'children': [], 'value': "'{}serviceStateTable'"}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '54', 'type': 'for_statement', 'children': ['55', '56', '57']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'srvStateTable'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'srvStateTables'}, {'id': '57', 'type': 'block', 'children': ['58', '72']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}, {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'statevars'}, {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'srvStateTable'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'findall'}, {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '70']}, {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'string', 'children': [], 'value': "'{}stateVariable'"}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '72', 'type': 'for_statement', 'children': ['73', '74', '75']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'statevars'}, {'id': '75', 'type': 'block', 'children': ['76', '90', '104', '118', '132', '141', '153', '167', '176', '188']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}, {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'findtext'}, {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '88']}, {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'string', 'children': [], 'value': "'{}name'"}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}, {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'datatype'}, {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'findtext'}, {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'call', 'children': ['99', '102']}, {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'string', 'children': [], 'value': "'{}dataType'"}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}, {'id': '105', 'type': 'assignment', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'default'}, {'id': '107', 'type': 'call', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'findtext'}, {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'call', 'children': ['113', '116']}, {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'string', 'children': [], 'value': "'{}defaultValue'"}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}, {'id': '119', 'type': 'assignment', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'value_list_elt'}, {'id': '121', 'type': 'call', 'children': ['122', '125']}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'find'}, {'id': '125', 'type': 'argument_list', 'children': ['126']}; {'id': '126', 'type': 'call', 'children': ['127', '130']}, {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'string', 'children': [], 'value': "'{}allowedValueList'"}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '130', 'type': 'argument_list', 'children': ['131']}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '132', 'type': 'if_statement', 'children': ['133', '136']}, {'id': '133', 'type': 'comparison_operator', 'children': ['134', '135'], 'value': 'is'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'value_list_elt'}, {'id': '135', 'type': 'None', 'children': []}; {'id': '136', 'type': 'block', 'children': ['137']}, {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'assignment', 'children': ['139', '140']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'value_list_elt'}; {'id': '140', 'type': 'tuple', 'children': []}, {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'assignment', 'children': ['143', '144']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'value_list'}; {'id': '144', 'type': 'boolean_operator', 'children': ['145', '152'], 'value': 'or'}, {'id': '145', 'type': 'list_comprehension', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'text'}, {'id': '149', 'type': 'for_in_clause', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'item'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'value_list_elt'}; {'id': '152', 'type': 'None', 'children': []}, {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'assignment', 'children': ['155', '156']}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'value_range_elt'}; {'id': '156', 'type': 'call', 'children': ['157', '160']}, {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'state'}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '160', 'type': 'argument_list', 'children': ['161']}, {'id': '161', 'type': 'call', 'children': ['162', '165']}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}, {'id': '163', 'type': 'string', 'children': [], 'value': "'{}allowedValueRange'"}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'format'}, {'id': '165', 'type': 'argument_list', 'children': ['166']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'ns'}, {'id': '167', 'type': 'if_statement', 'children': ['168', '171']}; {'id': '168', 'type': 'comparison_operator', 'children': ['169', '170'], 'value': 'is'}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'value_range_elt'}; {'id': '170', 'type': 'None', 'children': []}, {'id': '171', 'type': 'block', 'children': ['172']}; {'id': '172', 'type': 'expression_statement', 'children': ['173']}, {'id': '173', 'type': 'assignment', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'value_range_elt'}, {'id': '175', 'type': 'tuple', 'children': []}; {'id': '176', 'type': 'expression_statement', 'children': ['177']}, {'id': '177', 'type': 'assignment', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'value_range'}, {'id': '179', 'type': 'boolean_operator', 'children': ['180', '187'], 'value': 'or'}; {'id': '180', 'type': 'list_comprehension', 'children': ['181', '184']}, {'id': '181', 'type': 'attribute', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'item'}, {'id': '183', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '184', 'type': 'for_in_clause', 'children': ['185', '186']}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'value_range_elt'}, {'id': '187', 'type': 'None', 'children': []}; {'id': '188', 'type': 'expression_statement', 'children': ['189']}, {'id': '189', 'type': 'assignment', 'children': ['190', '193']}; {'id': '190', 'type': 'subscript', 'children': ['191', '192']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'vartypes'}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '193', 'type': 'call', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'Vartype'}, {'id': '195', 'type': 'argument_list', 'children': ['196', '197', '198', '199']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'datatype'}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'value_list'}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'value_range'}; {'id': '200', 'type': 'expression_statement', 'children': ['201']}, {'id': '201', 'type': 'assignment', 'children': ['202', '203']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'actionLists'}, {'id': '203', 'type': 'call', 'children': ['204', '207']}; {'id': '204', 'type': 'attribute', 'children': ['205', '206']}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'findall'}, {'id': '207', 'type': 'argument_list', 'children': ['208']}; {'id': '208', 'type': 'call', 'children': ['209', '212']}, {'id': '209', 'type': 'attribute', 'children': ['210', '211']}; {'id': '210', 'type': 'string', 'children': [], 'value': "'{}actionList'"}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '212', 'type': 'argument_list', 'children': ['213']}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '214', 'type': 'for_statement', 'children': ['215', '216', '217']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'actionList'}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'actionLists'}, {'id': '217', 'type': 'block', 'children': ['218', '232']}; {'id': '218', 'type': 'expression_statement', 'children': ['219']}, {'id': '219', 'type': 'assignment', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'actions'}, {'id': '221', 'type': 'call', 'children': ['222', '225']}; {'id': '222', 'type': 'attribute', 'children': ['223', '224']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'actionList'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'findall'}, {'id': '225', 'type': 'argument_list', 'children': ['226']}; {'id': '226', 'type': 'call', 'children': ['227', '230']}, {'id': '227', 'type': 'attribute', 'children': ['228', '229']}; {'id': '228', 'type': 'string', 'children': [], 'value': "'{}action'"}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '230', 'type': 'argument_list', 'children': ['231']}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '232', 'type': 'for_statement', 'children': ['233', '234', '235']}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'actions'}, {'id': '235', 'type': 'block', 'children': ['236', '250', '264']}; {'id': '236', 'type': 'expression_statement', 'children': ['237']}, {'id': '237', 'type': 'assignment', 'children': ['238', '239']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'action_name'}, {'id': '239', 'type': 'call', 'children': ['240', '243']}; {'id': '240', 'type': 'attribute', 'children': ['241', '242']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'findtext'}, {'id': '243', 'type': 'argument_list', 'children': ['244']}; {'id': '244', 'type': 'call', 'children': ['245', '248']}, {'id': '245', 'type': 'attribute', 'children': ['246', '247']}; {'id': '246', 'type': 'string', 'children': [], 'value': "'{}name'"}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '248', 'type': 'argument_list', 'children': ['249']}, {'id': '249', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '250', 'type': 'expression_statement', 'children': ['251']}, {'id': '251', 'type': 'assignment', 'children': ['252', '253']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'argLists'}, {'id': '253', 'type': 'call', 'children': ['254', '257']}; {'id': '254', 'type': 'attribute', 'children': ['255', '256']}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'findall'}, {'id': '257', 'type': 'argument_list', 'children': ['258']}; {'id': '258', 'type': 'call', 'children': ['259', '262']}, {'id': '259', 'type': 'attribute', 'children': ['260', '261']}; {'id': '260', 'type': 'string', 'children': [], 'value': "'{}argumentList'"}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '262', 'type': 'argument_list', 'children': ['263']}, {'id': '263', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '264', 'type': 'for_statement', 'children': ['265', '266', '267']}, {'id': '265', 'type': 'identifier', 'children': [], 'value': 'argList'}; {'id': '266', 'type': 'identifier', 'children': [], 'value': 'argLists'}, {'id': '267', 'type': 'block', 'children': ['268', '282', '286', '290', '371']}; {'id': '268', 'type': 'expression_statement', 'children': ['269']}, {'id': '269', 'type': 'assignment', 'children': ['270', '271']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'args_iter'}, {'id': '271', 'type': 'call', 'children': ['272', '275']}; {'id': '272', 'type': 'attribute', 'children': ['273', '274']}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'argList'}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'findall'}, {'id': '275', 'type': 'argument_list', 'children': ['276']}; {'id': '276', 'type': 'call', 'children': ['277', '280']}, {'id': '277', 'type': 'attribute', 'children': ['278', '279']}; {'id': '278', 'type': 'string', 'children': [], 'value': "'{}argument'"}, {'id': '279', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '280', 'type': 'argument_list', 'children': ['281']}, {'id': '281', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '282', 'type': 'expression_statement', 'children': ['283']}, {'id': '283', 'type': 'assignment', 'children': ['284', '285']}; {'id': '284', 'type': 'identifier', 'children': [], 'value': 'in_args'}, {'id': '285', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '286', 'type': 'expression_statement', 'children': ['287']}, {'id': '287', 'type': 'assignment', 'children': ['288', '289']}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'out_args'}, {'id': '289', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '290', 'type': 'for_statement', 'children': ['291', '292', '293']}, {'id': '291', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '292', 'type': 'identifier', 'children': [], 'value': 'args_iter'}, {'id': '293', 'type': 'block', 'children': ['294', '308', '322', '336', '342']}; {'id': '294', 'type': 'expression_statement', 'children': ['295']}, {'id': '295', 'type': 'assignment', 'children': ['296', '297']}; {'id': '296', 'type': 'identifier', 'children': [], 'value': 'arg_name'}, {'id': '297', 'type': 'call', 'children': ['298', '301']}; {'id': '298', 'type': 'attribute', 'children': ['299', '300']}, {'id': '299', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '300', 'type': 'identifier', 'children': [], 'value': 'findtext'}, {'id': '301', 'type': 'argument_list', 'children': ['302']}; {'id': '302', 'type': 'call', 'children': ['303', '306']}, {'id': '303', 'type': 'attribute', 'children': ['304', '305']}; {'id': '304', 'type': 'string', 'children': [], 'value': "'{}name'"}, {'id': '305', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '306', 'type': 'argument_list', 'children': ['307']}, {'id': '307', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '308', 'type': 'expression_statement', 'children': ['309']}, {'id': '309', 'type': 'assignment', 'children': ['310', '311']}; {'id': '310', 'type': 'identifier', 'children': [], 'value': 'direction'}, {'id': '311', 'type': 'call', 'children': ['312', '315']}; {'id': '312', 'type': 'attribute', 'children': ['313', '314']}, {'id': '313', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '314', 'type': 'identifier', 'children': [], 'value': 'findtext'}, {'id': '315', 'type': 'argument_list', 'children': ['316']}; {'id': '316', 'type': 'call', 'children': ['317', '320']}, {'id': '317', 'type': 'attribute', 'children': ['318', '319']}; {'id': '318', 'type': 'string', 'children': [], 'value': "'{}direction'"}, {'id': '319', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '320', 'type': 'argument_list', 'children': ['321']}, {'id': '321', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '322', 'type': 'expression_statement', 'children': ['323']}, {'id': '323', 'type': 'assignment', 'children': ['324', '325']}; {'id': '324', 'type': 'identifier', 'children': [], 'value': 'related_variable'}, {'id': '325', 'type': 'call', 'children': ['326', '329']}; {'id': '326', 'type': 'attribute', 'children': ['327', '328']}, {'id': '327', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '328', 'type': 'identifier', 'children': [], 'value': 'findtext'}, {'id': '329', 'type': 'argument_list', 'children': ['330']}; {'id': '330', 'type': 'call', 'children': ['331', '334']}, {'id': '331', 'type': 'attribute', 'children': ['332', '333']}; {'id': '332', 'type': 'string', 'children': [], 'value': "'{}relatedStateVariable'"}, {'id': '333', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '334', 'type': 'argument_list', 'children': ['335']}, {'id': '335', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '336', 'type': 'expression_statement', 'children': ['337']}, {'id': '337', 'type': 'assignment', 'children': ['338', '339']}; {'id': '338', 'type': 'identifier', 'children': [], 'value': 'vartype'}, {'id': '339', 'type': 'subscript', 'children': ['340', '341']}; {'id': '340', 'type': 'identifier', 'children': [], 'value': 'vartypes'}, {'id': '341', 'type': 'identifier', 'children': [], 'value': 'related_variable'}; {'id': '342', 'type': 'if_statement', 'children': ['343', '346', '358']}, {'id': '343', 'type': 'comparison_operator', 'children': ['344', '345'], 'value': '=='}; {'id': '344', 'type': 'identifier', 'children': [], 'value': 'direction'}, {'id': '345', 'type': 'string', 'children': [], 'value': '"in"'}; {'id': '346', 'type': 'block', 'children': ['347']}, {'id': '347', 'type': 'expression_statement', 'children': ['348']}; {'id': '348', 'type': 'call', 'children': ['349', '352']}, {'id': '349', 'type': 'attribute', 'children': ['350', '351']}; {'id': '350', 'type': 'identifier', 'children': [], 'value': 'in_args'}, {'id': '351', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '352', 'type': 'argument_list', 'children': ['353']}, {'id': '353', 'type': 'call', 'children': ['354', '355']}; {'id': '354', 'type': 'identifier', 'children': [], 'value': 'Argument'}, {'id': '355', 'type': 'argument_list', 'children': ['356', '357']}; {'id': '356', 'type': 'identifier', 'children': [], 'value': 'arg_name'}, {'id': '357', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '358', 'type': 'else_clause', 'children': ['359']}, {'id': '359', 'type': 'block', 'children': ['360']}; {'id': '360', 'type': 'expression_statement', 'children': ['361']}, {'id': '361', 'type': 'call', 'children': ['362', '365']}; {'id': '362', 'type': 'attribute', 'children': ['363', '364']}, {'id': '363', 'type': 'identifier', 'children': [], 'value': 'out_args'}; {'id': '364', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '365', 'type': 'argument_list', 'children': ['366']}; {'id': '366', 'type': 'call', 'children': ['367', '368']}, {'id': '367', 'type': 'identifier', 'children': [], 'value': 'Argument'}; {'id': '368', 'type': 'argument_list', 'children': ['369', '370']}, {'id': '369', 'type': 'identifier', 'children': [], 'value': 'arg_name'}; {'id': '370', 'type': 'identifier', 'children': [], 'value': 'vartype'}, {'id': '371', 'type': 'expression_statement', 'children': ['372']}; {'id': '372', 'type': 'yield', 'children': ['373']}, {'id': '373', 'type': 'call', 'children': ['374', '375']}; {'id': '374', 'type': 'identifier', 'children': [], 'value': 'Action'}, {'id': '375', 'type': 'argument_list', 'children': ['376', '377', '378']}; {'id': '376', 'type': 'identifier', 'children': [], 'value': 'action_name'}, {'id': '377', 'type': 'identifier', 'children': [], 'value': 'in_args'}
def iter_actions(self): ns = '{urn:schemas-upnp-org:service-1-0}' scpd_body = requests.get(self.base_url + self.scpd_url).content tree = XML.fromstring(scpd_body) vartypes = {} srvStateTables = tree.findall('{}serviceStateTable'.format(ns)) for srvStateTable in srvStateTables: statevars = srvStateTable.findall('{}stateVariable'.format(ns)) for state in statevars: name = state.findtext('{}name'.format(ns)) datatype = state.findtext('{}dataType'.format(ns)) default = state.findtext('{}defaultValue'.format(ns)) value_list_elt = state.find('{}allowedValueList'.format(ns)) if value_list_elt is None: value_list_elt = () value_list = [item.text for item in value_list_elt] or None value_range_elt = state.find('{}allowedValueRange'.format(ns)) if value_range_elt is None: value_range_elt = () value_range = [item.text for item in value_range_elt] or None vartypes[name] = Vartype(datatype, default, value_list, value_range) actionLists = tree.findall('{}actionList'.format(ns)) for actionList in actionLists: actions = actionList.findall('{}action'.format(ns)) for i in actions: action_name = i.findtext('{}name'.format(ns)) argLists = i.findall('{}argumentList'.format(ns)) for argList in argLists: args_iter = argList.findall('{}argument'.format(ns)) in_args = [] out_args = [] for arg in args_iter: arg_name = arg.findtext('{}name'.format(ns)) direction = arg.findtext('{}direction'.format(ns)) related_variable = arg.findtext( '{}relatedStateVariable'.format(ns)) vartype = vartypes[related_variable] if direction == "in": in_args.append(Argument(arg_name, vartype)) else: out_args.append(Argument(arg_name, vartype)) yield Action(action_name, in_args, out_args)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_event_xml'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'xml_event'}, {'id': '5', 'type': 'block', 'children': ['6', '10', '19', '28', '280']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}, {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}, {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'tree'}, {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'XML'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'fromstring'}, {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'xml_event'}, {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'properties'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}, {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'tree'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'findall'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}, {'id': '27', 'type': 'string', 'children': [], 'value': "'{urn:schemas-upnp-org:event-1-0}property'"}; {'id': '28', 'type': 'for_statement', 'children': ['29', '30', '31']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'properties'}, {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'for_statement', 'children': ['33', '34', '35']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'prop'}, {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'if_statement', 'children': ['37', '42', '265']}, {'id': '37', 'type': 'comparison_operator', 'children': ['38', '41'], 'value': '=='}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'tag'}, {'id': '41', 'type': 'string', 'children': [], 'value': '"LastChange"'}; {'id': '42', 'type': 'block', 'children': ['43', '59', '68', '82', '96']}, {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'last_change_tree'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}, {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'XML'}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'fromstring'}; {'id': '50', 'type': 'argument_list', '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': 'variable'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'encode'}, {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'string', 'children': [], 'value': "'utf-8'"}, {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '62', 'type': 'call', 'children': ['63', '66']}, {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'last_change_tree'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}, {'id': '67', 'type': 'string', 'children': [], 'value': '"{urn:schemas-upnp-org:metadata-1-0/AVT/}InstanceID"'}; {'id': '68', 'type': 'if_statement', 'children': ['69', '72']}, {'id': '69', 'type': 'comparison_operator', 'children': ['70', '71'], 'value': 'is'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'instance'}, {'id': '71', 'type': 'None', 'children': []}; {'id': '72', 'type': 'block', 'children': ['73']}, {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '76', 'type': 'call', 'children': ['77', '80']}, {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'last_change_tree'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}, {'id': '81', 'type': 'string', 'children': [], 'value': '"{urn:schemas-upnp-org:metadata-1-0/RCS/}InstanceID"'}; {'id': '82', 'type': 'if_statement', 'children': ['83', '86']}, {'id': '83', 'type': 'comparison_operator', 'children': ['84', '85'], 'value': 'is'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'instance'}, {'id': '85', 'type': 'None', 'children': []}; {'id': '86', 'type': 'block', 'children': ['87']}, {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '90', 'type': 'call', 'children': ['91', '94']}, {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'last_change_tree'}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}, {'id': '95', 'type': 'string', 'children': [], 'value': '"{urn:schemas-sonos-com:metadata-1-0/Queue/}QueueID"'}; {'id': '96', 'type': 'for_statement', 'children': ['97', '98', '99']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'last_change_var'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'instance'}, {'id': '99', 'type': 'block', 'children': ['100', '106', '126', '133', '142', '153', '219', '228']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}, {'id': '101', 'type': 'assignment', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'tag'}, {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'last_change_var'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '106', 'type': 'if_statement', 'children': ['107', '113']}, {'id': '107', 'type': 'call', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'startswith'}, {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'string', 'children': [], 'value': "'{'"}, {'id': '113', 'type': 'block', 'children': ['114']}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}, {'id': '115', 'type': 'assignment', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'tag'}, {'id': '117', 'type': 'subscript', 'children': ['118', '125']}; {'id': '118', 'type': 'call', 'children': ['119', '122']}, {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'tag'}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '122', 'type': 'argument_list', 'children': ['123', '124']}, {'id': '123', 'type': 'string', 'children': [], 'value': "'}'"}; {'id': '124', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '125', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}, {'id': '127', 'type': 'assignment', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'tag'}, {'id': '129', 'type': 'call', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'camel_to_underscore'}, {'id': '131', 'type': 'argument_list', 'children': ['132']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'tag'}, {'id': '133', 'type': 'expression_statement', 'children': ['134']}; {'id': '134', 'type': 'assignment', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '136', 'type': 'call', 'children': ['137', '140']}, {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'last_change_var'}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}, {'id': '141', 'type': 'string', 'children': [], 'value': "'val'"}; {'id': '142', 'type': 'if_statement', 'children': ['143', '146']}, {'id': '143', 'type': 'comparison_operator', 'children': ['144', '145'], 'value': 'is'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '145', 'type': 'None', 'children': []}; {'id': '146', 'type': 'block', 'children': ['147']}, {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'assignment', 'children': ['149', '150']}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'last_change_var'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'text'}, {'id': '153', 'type': 'if_statement', 'children': ['154', '160']}; {'id': '154', 'type': 'call', 'children': ['155', '158']}, {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '158', 'type': 'argument_list', 'children': ['159']}, {'id': '159', 'type': 'string', 'children': [], 'value': "'<DIDL-Lite'"}; {'id': '160', 'type': 'block', 'children': ['161']}, {'id': '161', 'type': 'try_statement', 'children': ['162', '181']}; {'id': '162', 'type': 'block', 'children': ['163', '170', '175']}, {'id': '163', 'type': 'expression_statement', 'children': ['164']}; {'id': '164', 'type': 'assignment', 'children': ['165', '166']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'didl'}; {'id': '166', 'type': 'call', 'children': ['167', '168']}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'from_didl_string'}; {'id': '168', 'type': 'argument_list', 'children': ['169']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '170', 'type': 'if_statement', 'children': ['171', '173']}, {'id': '171', 'type': 'not_operator', 'children': ['172']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'didl'}, {'id': '173', 'type': 'block', 'children': ['174']}; {'id': '174', 'type': 'continue_statement', 'children': []}, {'id': '175', 'type': 'expression_statement', 'children': ['176']}; {'id': '176', 'type': 'assignment', 'children': ['177', '178']}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '178', 'type': 'subscript', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'didl'}; {'id': '180', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '181', 'type': 'except_clause', 'children': ['182', '186']}; {'id': '182', 'type': 'as_pattern', 'children': ['183', '184']}, {'id': '183', 'type': 'identifier', 'children': [], 'value': 'SoCoException'}; {'id': '184', 'type': 'as_pattern_target', 'children': ['185']}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'original_exception'}; {'id': '186', 'type': 'block', 'children': ['187', '203', '212']}, {'id': '187', 'type': 'expression_statement', 'children': ['188']}; {'id': '188', 'type': 'call', 'children': ['189', '192']}, {'id': '189', 'type': 'attribute', 'children': ['190', '191']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'log'}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '192', 'type': 'argument_list', 'children': ['193', '198', '199']}, {'id': '193', 'type': 'concatenated_string', 'children': ['194', '195', '196', '197']}; {'id': '194', 'type': 'string', 'children': [], 'value': '"Event contains illegal metadata"'}, {'id': '195', 'type': 'string', 'children': [], 'value': '"for \'%s\'.\\n"'}; {'id': '196', 'type': 'string', 'children': [], 'value': '"Error message: \'%s\'\\n"'}, {'id': '197', 'type': 'string', 'children': [], 'value': '"The result will be a SoCoFault."'}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'tag'}, {'id': '199', 'type': 'call', 'children': ['200', '201']}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '201', 'type': 'argument_list', 'children': ['202']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'original_exception'}, {'id': '203', 'type': 'expression_statement', 'children': ['204']}; {'id': '204', 'type': 'assignment', 'children': ['205', '206']}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'event_parse_exception'}; {'id': '206', 'type': 'call', 'children': ['207', '208']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'EventParseException'}; {'id': '208', 'type': 'argument_list', 'children': ['209', '210', '211']}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'original_exception'}; {'id': '212', 'type': 'expression_statement', 'children': ['213']}, {'id': '213', 'type': 'assignment', 'children': ['214', '215']}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '215', 'type': 'call', 'children': ['216', '217']}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'SoCoFault'}, {'id': '217', 'type': 'argument_list', 'children': ['218']}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'event_parse_exception'}, {'id': '219', 'type': 'expression_statement', 'children': ['220']}; {'id': '220', 'type': 'assignment', 'children': ['221', '222']}, {'id': '221', 'type': 'identifier', 'children': [], 'value': 'channel'}; {'id': '222', 'type': 'call', 'children': ['223', '226']}, {'id': '223', 'type': 'attribute', 'children': ['224', '225']}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'last_change_var'}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '226', 'type': 'argument_list', 'children': ['227']}, {'id': '227', 'type': 'string', 'children': [], 'value': "'channel'"}; {'id': '228', 'type': 'if_statement', 'children': ['229', '232', '257']}, {'id': '229', 'type': 'comparison_operator', 'children': ['230', '231'], 'value': 'is'}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'channel'}, {'id': '231', 'type': 'None', 'children': []}; {'id': '232', 'type': 'block', 'children': ['233', '249']}, {'id': '233', 'type': 'if_statement', 'children': ['234', '242']}; {'id': '234', 'type': 'comparison_operator', 'children': ['235', '241'], 'value': 'is'}, {'id': '235', 'type': 'call', 'children': ['236', '239']}; {'id': '236', 'type': 'attribute', 'children': ['237', '238']}, {'id': '237', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'get'}, {'id': '239', 'type': 'argument_list', 'children': ['240']}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'tag'}, {'id': '241', 'type': 'None', 'children': []}; {'id': '242', 'type': 'block', 'children': ['243']}, {'id': '243', 'type': 'expression_statement', 'children': ['244']}; {'id': '244', 'type': 'assignment', 'children': ['245', '248']}, {'id': '245', 'type': 'subscript', 'children': ['246', '247']}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '248', 'type': 'dictionary', 'children': []}, {'id': '249', 'type': 'expression_statement', 'children': ['250']}; {'id': '250', 'type': 'assignment', 'children': ['251', '256']}, {'id': '251', 'type': 'subscript', 'children': ['252', '255']}; {'id': '252', 'type': 'subscript', 'children': ['253', '254']}, {'id': '253', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'tag'}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'channel'}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '257', 'type': 'else_clause', 'children': ['258']}; {'id': '258', 'type': 'block', 'children': ['259']}, {'id': '259', 'type': 'expression_statement', 'children': ['260']}; {'id': '260', 'type': 'assignment', 'children': ['261', '264']}, {'id': '261', 'type': 'subscript', 'children': ['262', '263']}; {'id': '262', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '263', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '265', 'type': 'else_clause', 'children': ['266']}; {'id': '266', 'type': 'block', 'children': ['267']}, {'id': '267', 'type': 'expression_statement', 'children': ['268']}; {'id': '268', 'type': 'assignment', 'children': ['269', '277']}, {'id': '269', 'type': 'subscript', 'children': ['270', '271']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '271', 'type': 'call', 'children': ['272', '273']}; {'id': '272', 'type': 'identifier', 'children': [], 'value': 'camel_to_underscore'}, {'id': '273', 'type': 'argument_list', 'children': ['274']}; {'id': '274', 'type': 'attribute', 'children': ['275', '276']}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'tag'}, {'id': '277', 'type': 'attribute', 'children': ['278', '279']}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'variable'}, {'id': '279', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '280', 'type': 'return_statement', 'children': ['281']}, {'id': '281', 'type': 'identifier', 'children': [], 'value': 'result'}
def parse_event_xml(xml_event): result = {} tree = XML.fromstring(xml_event) properties = tree.findall( '{urn:schemas-upnp-org:event-1-0}property') for prop in properties: for variable in prop: if variable.tag == "LastChange": last_change_tree = XML.fromstring( variable.text.encode('utf-8')) instance = last_change_tree.find( "{urn:schemas-upnp-org:metadata-1-0/AVT/}InstanceID") if instance is None: instance = last_change_tree.find( "{urn:schemas-upnp-org:metadata-1-0/RCS/}InstanceID") if instance is None: instance = last_change_tree.find( "{urn:schemas-sonos-com:metadata-1-0/Queue/}QueueID") for last_change_var in instance: tag = last_change_var.tag if tag.startswith('{'): tag = tag.split('}', 1)[1] tag = camel_to_underscore(tag) value = last_change_var.get('val') if value is None: value = last_change_var.text if value.startswith('<DIDL-Lite'): try: didl = from_didl_string(value) if not didl: continue value = didl[0] except SoCoException as original_exception: log.debug("Event contains illegal metadata" "for '%s'.\n" "Error message: '%s'\n" "The result will be a SoCoFault.", tag, str(original_exception)) event_parse_exception = EventParseException( tag, value, original_exception ) value = SoCoFault(event_parse_exception) channel = last_change_var.get('channel') if channel is not None: if result.get(tag) is None: result[tag] = {} result[tag][channel] = value else: result[tag] = value else: result[camel_to_underscore(variable.tag)] = variable.text return result
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_restore_coordinator'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6', '16', '36', '42']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}, {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'transport_info'}, {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}, {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_current_transport_info'}, {'id': '15', 'type': 'argument_list', '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': 'transport_info'}, {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21']}, {'id': '21', 'type': 'if_statement', 'children': ['22', '27']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '26'], 'value': '=='}, {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'transport_info'}, {'id': '25', 'type': 'string', 'children': [], 'value': "'current_transport_state'"}; {'id': '26', 'type': 'string', 'children': [], 'value': "'PLAYING'"}, {'id': '27', 'type': 'block', 'children': ['28']}; {'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': 'self'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'pause'}, {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}, {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_restore_queue'}, {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'if_statement', 'children': ['43', '52', '123', '129']}, {'id': '43', 'type': 'boolean_operator', 'children': ['44', '47'], 'value': 'and'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'is_playing_queue'}, {'id': '47', 'type': 'comparison_operator', 'children': ['48', '51'], 'value': '>'}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'playlist_position'}, {'id': '51', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '52', 'type': 'block', 'children': ['53', '78', '103', '113']}, {'id': '53', 'type': 'if_statement', 'children': ['54', '59']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '58'], 'value': 'is'}, {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'playlist_position'}; {'id': '58', 'type': 'None', 'children': []}, {'id': '59', 'type': 'block', 'children': ['60', '66']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}, {'id': '61', 'type': 'augmented_assignment', 'children': ['62', '65'], 'value': '-='}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'playlist_position'}, {'id': '65', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}, {'id': '67', 'type': 'call', 'children': ['68', '73']}; {'id': '68', 'type': 'attribute', 'children': ['69', '72']}, {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'play_from_queue'}, {'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': 'playlist_position'}, {'id': '77', 'type': 'False', 'children': []}; {'id': '78', 'type': 'if_statement', 'children': ['79', '84']}, {'id': '79', 'type': 'comparison_operator', 'children': ['80', '83'], 'value': 'is'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'track_position'}, {'id': '83', 'type': 'None', 'children': []}; {'id': '84', 'type': 'block', 'children': ['85']}, {'id': '85', 'type': 'if_statement', 'children': ['86', '91']}; {'id': '86', 'type': 'comparison_operator', 'children': ['87', '90'], 'value': '!='}, {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'track_position'}; {'id': '90', 'type': 'string', 'children': [], 'value': '""'}, {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}, {'id': '93', 'type': 'call', 'children': ['94', '99']}; {'id': '94', 'type': 'attribute', 'children': ['95', '98']}, {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'seek'}, {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'track_position'}, {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'assignment', 'children': ['105', '110']}, {'id': '105', 'type': 'attribute', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'device'}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'play_mode'}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'play_mode'}, {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'assignment', 'children': ['115', '120']}, {'id': '115', 'type': 'attribute', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'device'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'cross_fade'}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'cross_fade'}, {'id': '123', 'type': 'elif_clause', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'is_playing_cloud_queue'}, {'id': '127', 'type': 'block', 'children': ['128']}; {'id': '128', 'type': 'pass_statement', 'children': []}, {'id': '129', 'type': 'else_clause', 'children': ['130']}; {'id': '130', 'type': 'block', 'children': ['131']}, {'id': '131', 'type': 'if_statement', 'children': ['132', '137']}; {'id': '132', 'type': 'comparison_operator', 'children': ['133', '136'], 'value': '!='}, {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'media_uri'}; {'id': '136', 'type': 'string', 'children': [], 'value': '""'}, {'id': '137', 'type': 'block', 'children': ['138']}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}, {'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': 'self'}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'play_uri'}, {'id': '145', 'type': 'argument_list', 'children': ['146', '149', '152']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'media_uri'}, {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'media_metadata'}; {'id': '152', 'type': 'keyword_argument', 'children': ['153', '154']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'start'}
def _restore_coordinator(self): transport_info = self.device.get_current_transport_info() if transport_info is not None: if transport_info['current_transport_state'] == 'PLAYING': self.device.pause() self._restore_queue() if self.is_playing_queue and self.playlist_position > 0: if self.playlist_position is not None: self.playlist_position -= 1 self.device.play_from_queue(self.playlist_position, False) if self.track_position is not None: if self.track_position != "": self.device.seek(self.track_position) self.device.play_mode = self.play_mode self.device.cross_fade = self.cross_fade elif self.is_playing_cloud_queue: pass else: if self.media_uri != "": self.device.play_uri( self.media_uri, self.media_metadata, start=False)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_loading_order'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'step_files'}, {'id': '5', 'type': 'block', 'children': ['6', '10', '14', '18', '121']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}, {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'tools'}, {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}, {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'workflows'}, {'id': '13', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}, {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'workflows_with_subworkflows'}, {'id': '17', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '18', 'type': 'for_statement', 'children': ['19', '20', '21']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'step_files'}, {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'if_statement', 'children': ['23', '36', '44']}, {'id': '23', 'type': 'boolean_operator', 'children': ['24', '30'], 'value': 'or'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}, {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}, {'id': '29', 'type': 'string', 'children': [], 'value': "'http://'"}; {'id': '30', 'type': 'call', 'children': ['31', '34']}, {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}, {'id': '35', 'type': 'string', 'children': [], 'value': "'https://'"}; {'id': '36', 'type': 'block', 'children': ['37']}, {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}, {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'tools'}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '44', 'type': 'else_clause', 'children': ['45']}, {'id': '45', 'type': 'block', 'children': ['46', '53']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}, {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'obj'}, {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'load_yaml'}, {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '53', 'type': 'if_statement', 'children': ['54', '63', '112']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '62'], 'value': '=='}, {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'get'}, {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'string', 'children': [], 'value': "'class'"}, {'id': '61', 'type': 'string', 'children': [], 'value': "''"}; {'id': '62', 'type': 'string', 'children': [], 'value': "'Workflow'"}, {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'if_statement', 'children': ['65', '72', '103']}, {'id': '65', 'type': 'comparison_operator', 'children': ['66', '67'], 'value': 'in'}; {'id': '66', 'type': 'string', 'children': [], 'value': "'requirements'"}, {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'keys'}, {'id': '71', 'type': 'argument_list', 'children': []}; {'id': '72', 'type': 'block', 'children': ['73', '80']}, {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'subw'}; {'id': '76', 'type': 'dictionary', 'children': ['77']}, {'id': '77', 'type': 'pair', 'children': ['78', '79']}; {'id': '78', 'type': 'string', 'children': [], 'value': "'class'"}, {'id': '79', 'type': 'string', 'children': [], 'value': "'SubworkflowFeatureRequirement'"}; {'id': '80', 'type': 'if_statement', 'children': ['81', '86', '94']}, {'id': '81', 'type': 'comparison_operator', 'children': ['82', '83'], 'value': 'in'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'subw'}, {'id': '83', 'type': 'subscript', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'obj'}, {'id': '85', 'type': 'string', 'children': [], 'value': "'requirements'"}; {'id': '86', 'type': 'block', 'children': ['87']}, {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '92']}, {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'workflows_with_subworkflows'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '94', 'type': 'else_clause', 'children': ['95']}, {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}, {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'workflows'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '103', 'type': 'else_clause', 'children': ['104']}; {'id': '104', 'type': 'block', 'children': ['105']}, {'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': 'workflows'}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '112', 'type': 'else_clause', 'children': ['113']}, {'id': '113', 'type': 'block', 'children': ['114']}; {'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': 'tools'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '121', 'type': 'return_statement', 'children': ['122']}; {'id': '122', 'type': 'binary_operator', 'children': ['123', '126'], 'value': '+'}, {'id': '123', 'type': 'binary_operator', 'children': ['124', '125'], 'value': '+'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'tools'}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'workflows'}
def sort_loading_order(step_files): tools = [] workflows = [] workflows_with_subworkflows = [] for f in step_files: if f.startswith('http://') or f.startswith('https://'): tools.append(f) else: obj = load_yaml(f) if obj.get('class', '') == 'Workflow': if 'requirements' in obj.keys(): subw = {'class': 'SubworkflowFeatureRequirement'} if subw in obj['requirements']: workflows_with_subworkflows.append(f) else: workflows.append(f) else: workflows.append(f) else: tools.append(f) return tools + workflows + workflows_with_subworkflows
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_input'}, {'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', '53', '57', '63', '79', '95', '109', '118', '205', '211', '228', '241', '265']}; {'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': '_closed'}, {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'function_definition', 'children': ['15', '16', '18']}, {'id': '15', 'type': 'function_name', 'children': [], 'value': '_get_item'}; {'id': '16', 'type': 'parameters', 'children': ['17']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '18', 'type': 'block', 'children': ['19', '28', '36', '51']}, {'id': '19', 'type': 'if_statement', 'children': ['20', '22']}; {'id': '20', 'type': 'not_operator', 'children': ['21']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '22', 'type': 'block', 'children': ['23']}, {'id': '23', 'type': 'raise_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}, {'id': '27', 'type': 'string', 'children': [], 'value': '"No parameter specified."'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}, {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'item'}, {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'popitem'}, {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'if_statement', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '38', 'type': 'block', 'children': ['39']}, {'id': '39', 'type': 'raise_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}, {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}, {'id': '45', 'type': 'concatenated_string', 'children': ['46', '47']}; {'id': '46', 'type': 'string', 'children': [], 'value': '"Too many parameters, not clear what to do "'}, {'id': '47', 'type': 'string', 'children': [], 'value': '"with {}"'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'format'}, {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'kwargs'}, {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'item'}, {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'symbols'}; {'id': '56', 'type': 'None', 'children': []}, {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'input_dict'}; {'id': '60', 'type': 'call', 'children': ['61', '62']}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'CommentedMap'}; {'id': '62', 'type': 'argument_list', 'children': []}, {'id': '63', 'type': 'if_statement', 'children': ['64', '67']}; {'id': '64', 'type': 'comparison_operator', 'children': ['65', '66'], 'value': 'in'}, {'id': '65', 'type': 'string', 'children': [], 'value': "'default'"}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'kwargs'}, {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}, {'id': '69', 'type': 'assignment', 'children': ['70', '73']}; {'id': '70', 'type': 'subscript', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'input_dict'}; {'id': '72', 'type': 'string', 'children': [], 'value': "'default'"}, {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'pop'}, {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'string', 'children': [], 'value': "'default'"}, {'id': '79', 'type': 'if_statement', 'children': ['80', '83']}; {'id': '80', 'type': 'comparison_operator', 'children': ['81', '82'], 'value': 'in'}, {'id': '81', 'type': 'string', 'children': [], 'value': "'label'"}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'kwargs'}, {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}, {'id': '85', 'type': 'assignment', 'children': ['86', '89']}; {'id': '86', 'type': 'subscript', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'input_dict'}; {'id': '88', 'type': 'string', 'children': [], 'value': "'label'"}, {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'pop'}, {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'string', 'children': [], 'value': "'label'"}, {'id': '95', 'type': 'if_statement', 'children': ['96', '99']}; {'id': '96', 'type': 'comparison_operator', 'children': ['97', '98'], 'value': 'in'}, {'id': '97', 'type': 'string', 'children': [], 'value': "'symbols'"}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'kwargs'}, {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}, {'id': '101', 'type': 'assignment', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'symbols'}, {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'pop'}, {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'string', 'children': [], 'value': "'symbols'"}, {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '114']}, {'id': '111', 'type': 'pattern_list', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'input_type'}; {'id': '114', 'type': 'call', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': '_get_item'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '118', 'type': 'if_statement', 'children': ['119', '122', '191']}, {'id': '119', 'type': 'comparison_operator', 'children': ['120', '121'], 'value': '=='}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'input_type'}, {'id': '121', 'type': 'string', 'children': [], 'value': "'enum'"}; {'id': '122', 'type': 'block', 'children': ['123', '129', '135', '145', '155', '168', '179', '185']}, {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '126', 'type': 'call', 'children': ['127', '128']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'CommentedMap'}; {'id': '128', 'type': 'argument_list', 'children': []}, {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'assignment', 'children': ['131', '134']}, {'id': '131', 'type': 'subscript', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'typ'}, {'id': '133', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '134', 'type': 'string', 'children': [], 'value': "'enum'"}, {'id': '135', 'type': 'if_statement', 'children': ['136', '139']}; {'id': '136', 'type': 'comparison_operator', 'children': ['137', '138'], 'value': 'is'}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'symbols'}; {'id': '138', 'type': 'None', 'children': []}, {'id': '139', 'type': 'block', 'children': ['140']}; {'id': '140', 'type': 'raise_statement', 'children': ['141']}, {'id': '141', 'type': 'call', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '143', 'type': 'argument_list', 'children': ['144']}; {'id': '144', 'type': 'string', 'children': [], 'value': '"Please specify the enum\'s symbols."'}, {'id': '145', 'type': 'if_statement', 'children': ['146', '149']}; {'id': '146', 'type': 'comparison_operator', 'children': ['147', '148'], 'value': '=='}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'symbols'}; {'id': '148', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '149', 'type': 'block', 'children': ['150']}; {'id': '150', 'type': 'raise_statement', 'children': ['151']}, {'id': '151', 'type': 'call', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '153', 'type': 'argument_list', 'children': ['154']}; {'id': '154', 'type': 'string', 'children': [], 'value': '"The enum\'s symbols cannot be empty."'}, {'id': '155', 'type': 'if_statement', 'children': ['156', '162']}; {'id': '156', 'type': 'comparison_operator', 'children': ['157', '161'], 'value': '!='}, {'id': '157', 'type': 'call', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'type'}, {'id': '159', 'type': 'argument_list', 'children': ['160']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'symbols'}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '162', 'type': 'block', 'children': ['163']}, {'id': '163', 'type': 'raise_statement', 'children': ['164']}; {'id': '164', 'type': 'call', 'children': ['165', '166']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '166', 'type': 'argument_list', 'children': ['167']}, {'id': '167', 'type': 'string', 'children': [], 'value': "'Symbols should be a list.'"}; {'id': '168', 'type': 'expression_statement', 'children': ['169']}, {'id': '169', 'type': 'assignment', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'symbols'}, {'id': '171', 'type': 'list_comprehension', 'children': ['172', '176']}; {'id': '172', 'type': 'call', 'children': ['173', '174']}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '174', 'type': 'argument_list', 'children': ['175']}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '176', 'type': 'for_in_clause', 'children': ['177', '178']}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'symbols'}, {'id': '179', 'type': 'expression_statement', 'children': ['180']}; {'id': '180', 'type': 'assignment', 'children': ['181', '184']}, {'id': '181', 'type': 'subscript', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'typ'}, {'id': '183', 'type': 'string', 'children': [], 'value': "'symbols'"}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'symbols'}, {'id': '185', 'type': 'expression_statement', 'children': ['186']}; {'id': '186', 'type': 'assignment', 'children': ['187', '190']}, {'id': '187', 'type': 'subscript', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'input_dict'}, {'id': '189', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'typ'}, {'id': '191', 'type': 'else_clause', 'children': ['192']}; {'id': '192', 'type': 'block', 'children': ['193']}, {'id': '193', 'type': 'if_statement', 'children': ['194', '198']}; {'id': '194', 'type': 'call', 'children': ['195', '196']}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '196', 'type': 'argument_list', 'children': ['197']}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'input_dict'}; {'id': '198', 'type': 'block', 'children': ['199']}, {'id': '199', 'type': 'expression_statement', 'children': ['200']}; {'id': '200', 'type': 'assignment', 'children': ['201', '204']}, {'id': '201', 'type': 'subscript', 'children': ['202', '203']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'input_dict'}, {'id': '203', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'input_type'}, {'id': '205', 'type': 'expression_statement', 'children': ['206']}; {'id': '206', 'type': 'assignment', 'children': ['207', '208']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '208', 'type': 'binary_operator', 'children': ['209', '210'], 'value': '+'}, {'id': '209', 'type': 'string', 'children': [], 'value': '\'"{}" is already used as a workflow input. Please use a \''}; {'id': '210', 'type': 'string', 'children': [], 'value': "'different name.'"}, {'id': '211', 'type': 'if_statement', 'children': ['212', '217']}; {'id': '212', 'type': 'comparison_operator', 'children': ['213', '214'], 'value': 'in'}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '214', 'type': 'attribute', 'children': ['215', '216']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'wf_inputs'}, {'id': '217', 'type': 'block', 'children': ['218']}; {'id': '218', 'type': 'raise_statement', 'children': ['219']}, {'id': '219', 'type': 'call', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '221', 'type': 'argument_list', 'children': ['222']}; {'id': '222', 'type': 'call', 'children': ['223', '226']}, {'id': '223', 'type': 'attribute', 'children': ['224', '225']}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '226', 'type': 'argument_list', 'children': ['227']}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '228', 'type': 'if_statement', 'children': ['229', '234']}, {'id': '229', 'type': 'call', 'children': ['230', '231']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'isinstance'}, {'id': '231', 'type': 'argument_list', 'children': ['232', '233']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'input_type'}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '234', 'type': 'block', 'children': ['235']}, {'id': '235', 'type': 'expression_statement', 'children': ['236']}; {'id': '236', 'type': 'assignment', 'children': ['237', '240']}, {'id': '237', 'type': 'subscript', 'children': ['238', '239']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'input_dict'}, {'id': '239', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'input_type'}, {'id': '241', 'type': 'if_statement', 'children': ['242', '246', '255']}; {'id': '242', 'type': 'call', 'children': ['243', '244']}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '244', 'type': 'argument_list', 'children': ['245']}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'input_dict'}; {'id': '246', 'type': 'block', 'children': ['247']}, {'id': '247', 'type': 'expression_statement', 'children': ['248']}; {'id': '248', 'type': 'assignment', 'children': ['249', '254']}, {'id': '249', 'type': 'subscript', 'children': ['250', '253']}; {'id': '250', 'type': 'attribute', 'children': ['251', '252']}, {'id': '251', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'wf_inputs'}, {'id': '253', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'input_dict'}, {'id': '255', 'type': 'else_clause', 'children': ['256']}; {'id': '256', 'type': 'block', 'children': ['257']}, {'id': '257', 'type': 'expression_statement', 'children': ['258']}; {'id': '258', 'type': 'assignment', 'children': ['259', '264']}, {'id': '259', 'type': 'subscript', 'children': ['260', '263']}; {'id': '260', 'type': 'attribute', 'children': ['261', '262']}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '262', 'type': 'identifier', 'children': [], 'value': 'wf_inputs'}, {'id': '263', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'input_type'}, {'id': '265', 'type': 'return_statement', 'children': ['266']}; {'id': '266', 'type': 'call', 'children': ['267', '268']}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'Reference'}; {'id': '268', 'type': 'argument_list', 'children': ['269']}, {'id': '269', 'type': 'keyword_argument', 'children': ['270', '271']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'input_name'}, {'id': '271', 'type': 'identifier', 'children': [], 'value': 'name'}
def add_input(self, **kwargs): self._closed() def _get_item(args): if not args: raise ValueError("No parameter specified.") item = args.popitem() if args: raise ValueError("Too many parameters, not clear what to do " "with {}".format(kwargs)) return item symbols = None input_dict = CommentedMap() if 'default' in kwargs: input_dict['default'] = kwargs.pop('default') if 'label' in kwargs: input_dict['label'] = kwargs.pop('label') if 'symbols' in kwargs: symbols = kwargs.pop('symbols') name, input_type = _get_item(kwargs) if input_type == 'enum': typ = CommentedMap() typ['type'] = 'enum' if symbols is None: raise ValueError("Please specify the enum's symbols.") if symbols == []: raise ValueError("The enum's symbols cannot be empty.") if type(symbols) != list: raise ValueError('Symbols should be a list.') symbols = [str(s) for s in symbols] typ['symbols'] = symbols input_dict['type'] = typ else: if bool(input_dict): input_dict['type'] = input_type msg = '"{}" is already used as a workflow input. Please use a ' +\ 'different name.' if name in self.wf_inputs: raise ValueError(msg.format(name)) if isinstance(input_type, dict): input_dict['type'] = input_type if bool(input_dict): self.wf_inputs[name] = input_dict else: self.wf_inputs[name] = input_type return Reference(input_name=name)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_obj'}, {'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': 'wd'}, {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '10', 'type': 'False', 'children': []}, {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'relpath'}, {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '21', '27', '33', '39', '55', '71', '84', '101', '118', '135', '143', '151', '157', '186', '192']}, {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}, {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '19', 'type': 'identifier', 'children': [], 'value': '_closed'}; {'id': '20', 'type': 'argument_list', 'children': []}, {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'CommentedMap'}; {'id': '26', 'type': 'argument_list', 'children': []}, {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '32']}, {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'obj'}, {'id': '31', 'type': 'string', 'children': [], 'value': "'cwlVersion'"}; {'id': '32', 'type': 'string', 'children': [], 'value': "'v1.0'"}, {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '38']}, {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'obj'}, {'id': '37', 'type': 'string', 'children': [], 'value': "'class'"}; {'id': '38', 'type': 'string', 'children': [], 'value': "'Workflow'"}, {'id': '39', 'type': 'try_statement', 'children': ['40', '49']}; {'id': '40', 'type': 'block', 'children': ['41']}, {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '46']}, {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'obj'}, {'id': '45', 'type': 'string', 'children': [], 'value': "'doc'"}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'documentation'}, {'id': '49', 'type': 'except_clause', 'children': ['50', '53']}; {'id': '50', 'type': 'tuple', 'children': ['51', '52']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'pass_statement', 'children': []}, {'id': '55', 'type': 'try_statement', 'children': ['56', '65']}; {'id': '56', 'type': 'block', 'children': ['57']}, {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '62']}, {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'obj'}, {'id': '61', 'type': 'string', 'children': [], 'value': "'label'"}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'label'}, {'id': '65', 'type': 'except_clause', 'children': ['66', '69']}; {'id': '66', 'type': 'tuple', 'children': ['67', '68']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'pass_statement', 'children': []}, {'id': '71', 'type': 'if_statement', 'children': ['72', '77']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}, {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': '_has_requirements'}; {'id': '76', 'type': 'argument_list', 'children': []}, {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}, {'id': '79', 'type': 'assignment', 'children': ['80', '83']}; {'id': '80', 'type': 'subscript', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '82', 'type': 'string', 'children': [], 'value': "'requirements'"}, {'id': '83', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '84', 'type': 'if_statement', 'children': ['85', '88']}, {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'has_workflow_step'}; {'id': '88', 'type': 'block', 'children': ['89']}, {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '96']}, {'id': '91', 'type': 'attribute', 'children': ['92', '95']}; {'id': '92', 'type': 'subscript', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '94', 'type': 'string', 'children': [], 'value': "'requirements'"}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}, {'id': '97', 'type': 'dictionary', 'children': ['98']}; {'id': '98', 'type': 'pair', 'children': ['99', '100']}, {'id': '99', 'type': 'string', 'children': [], 'value': "'class'"}; {'id': '100', 'type': 'string', 'children': [], 'value': "'SubworkflowFeatureRequirement'"}, {'id': '101', 'type': 'if_statement', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'has_scatter_requirement'}, {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}, {'id': '107', 'type': 'call', 'children': ['108', '113']}; {'id': '108', 'type': 'attribute', 'children': ['109', '112']}, {'id': '109', 'type': 'subscript', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'obj'}, {'id': '111', 'type': 'string', 'children': [], 'value': "'requirements'"}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'dictionary', 'children': ['115']}, {'id': '115', 'type': 'pair', 'children': ['116', '117']}; {'id': '116', 'type': 'string', 'children': [], 'value': "'class'"}, {'id': '117', 'type': 'string', 'children': [], 'value': "'ScatterFeatureRequirement'"}; {'id': '118', 'type': 'if_statement', 'children': ['119', '122']}, {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'has_multiple_inputs'}; {'id': '122', 'type': 'block', 'children': ['123']}, {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '130']}, {'id': '125', 'type': 'attribute', 'children': ['126', '129']}; {'id': '126', 'type': 'subscript', 'children': ['127', '128']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '128', 'type': 'string', 'children': [], 'value': "'requirements'"}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '130', 'type': 'argument_list', 'children': ['131']}, {'id': '131', 'type': 'dictionary', 'children': ['132']}; {'id': '132', 'type': 'pair', 'children': ['133', '134']}, {'id': '133', 'type': 'string', 'children': [], 'value': "'class'"}; {'id': '134', 'type': 'string', 'children': [], 'value': "'MultipleInputFeatureRequirement'"}, {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'assignment', 'children': ['137', '140']}, {'id': '137', 'type': 'subscript', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'obj'}, {'id': '139', 'type': 'string', 'children': [], 'value': "'inputs'"}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'wf_inputs'}, {'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': 'obj'}, {'id': '147', 'type': 'string', 'children': [], 'value': "'outputs'"}; {'id': '148', 'type': 'attribute', 'children': ['149', '150']}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'wf_outputs'}, {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'assignment', 'children': ['153', '154']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'steps_obj'}; {'id': '154', 'type': 'call', 'children': ['155', '156']}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'CommentedMap'}; {'id': '156', 'type': 'argument_list', 'children': []}, {'id': '157', 'type': 'for_statement', 'children': ['158', '159', '162']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'wf_steps'}; {'id': '162', 'type': 'block', 'children': ['163']}, {'id': '163', 'type': 'expression_statement', 'children': ['164']}; {'id': '164', 'type': 'assignment', 'children': ['165', '168']}, {'id': '165', 'type': 'subscript', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'steps_obj'}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '168', 'type': 'call', 'children': ['169', '176']}, {'id': '169', 'type': 'attribute', 'children': ['170', '175']}; {'id': '170', 'type': 'subscript', 'children': ['171', '174']}, {'id': '171', 'type': 'attribute', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'wf_steps'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'to_obj'}; {'id': '176', 'type': 'argument_list', 'children': ['177', '180', '183']}, {'id': '177', 'type': 'keyword_argument', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'relpath'}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'relpath'}; {'id': '180', 'type': 'keyword_argument', 'children': ['181', '182']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'pack'}, {'id': '183', 'type': 'keyword_argument', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'wd'}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'wd'}; {'id': '186', 'type': 'expression_statement', 'children': ['187']}, {'id': '187', 'type': 'assignment', 'children': ['188', '191']}; {'id': '188', 'type': 'subscript', 'children': ['189', '190']}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '190', 'type': 'string', 'children': [], 'value': "'steps'"}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'steps_obj'}; {'id': '192', 'type': 'return_statement', 'children': ['193']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'obj'}
def to_obj(self, wd=False, pack=False, relpath=None): self._closed() obj = CommentedMap() obj['cwlVersion'] = 'v1.0' obj['class'] = 'Workflow' try: obj['doc'] = self.documentation except (AttributeError, ValueError): pass try: obj['label'] = self.label except (AttributeError, ValueError): pass if self._has_requirements(): obj['requirements'] = [] if self.has_workflow_step: obj['requirements'].append( {'class': 'SubworkflowFeatureRequirement'}) if self.has_scatter_requirement: obj['requirements'].append({'class': 'ScatterFeatureRequirement'}) if self.has_multiple_inputs: obj['requirements'].append( {'class': 'MultipleInputFeatureRequirement'}) obj['inputs'] = self.wf_inputs obj['outputs'] = self.wf_outputs steps_obj = CommentedMap() for key in self.wf_steps: steps_obj[key] = self.wf_steps[key].to_obj(relpath=relpath, pack=pack, wd=wd) obj['steps'] = steps_obj return obj
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'ERROR', 'children': ['2', '21', '22', '26', '30', '62', '86', '90', '174', '178', '208', '226']}; {'id': '2', 'type': 'function_definition', 'children': ['3', '4', '9']}, {'id': '3', 'type': 'function_name', 'children': [], 'value': 'to_script'}; {'id': '4', 'type': 'parameters', 'children': ['5', '6']}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'wf_name'}; {'id': '8', 'type': 'string', 'children': [], 'value': "'wf'"}, {'id': '9', 'type': 'block', 'children': ['10', '16', '20']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}, {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_closed'}, {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}, {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'script'}, {'id': '19', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '20', 'type': 'comment', 'children': []}, {'id': '21', 'type': 'ERROR', 'children': []}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}, {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'params'}, {'id': '25', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}, {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'returns'}, {'id': '29', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '30', 'type': 'for_statement', 'children': ['31', '34', '41']}, {'id': '31', 'type': 'pattern_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'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': 'wf_inputs'}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '40', 'type': 'argument_list', 'children': []}, {'id': '41', 'type': 'block', 'children': ['42', '55']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}, {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '47', 'type': 'argument_list', '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': 'format'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'typ'}, {'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': 'returns'}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}, {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'script'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '72']}, {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'{} = {}.add_inputs({})'"}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '72', 'type': 'argument_list', 'children': ['73', '79', '80']}, {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}, {'id': '75', 'type': 'string', 'children': [], 'value': "', '"}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'returns'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'wf_name'}; {'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': 'identifier', 'children': [], 'value': 'params'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}, {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'returns'}, {'id': '89', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '90', 'type': 'for_statement', 'children': ['91', '94', '101']}, {'id': '91', 'type': 'pattern_list', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '94', 'type': 'call', 'children': ['95', '100']}, {'id': '95', 'type': 'attribute', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'wf_steps'}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '100', 'type': 'argument_list', 'children': []}, {'id': '101', 'type': 'block', 'children': ['102', '108', '124', '149']}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}, {'id': '103', 'type': 'assignment', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'pyname'}, {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'step'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'python_name'}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}, {'id': '109', 'type': 'assignment', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'returns'}, {'id': '111', 'type': 'list_comprehension', 'children': ['112', '119']}; {'id': '112', 'type': 'call', 'children': ['113', '116']}, {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'string', 'children': [], 'value': "'{}_{}'"}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '116', 'type': 'argument_list', 'children': ['117', '118']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'pyname'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'o'}, {'id': '119', 'type': 'for_in_clause', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'o'}, {'id': '121', 'type': 'subscript', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'step'}, {'id': '123', 'type': 'string', 'children': [], 'value': "'out'"}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}, {'id': '125', 'type': 'assignment', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'params'}, {'id': '127', 'type': 'list_comprehension', 'children': ['128', '138']}; {'id': '128', 'type': 'call', 'children': ['129', '132']}, {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'string', 'children': [], 'value': "'{}={}'"}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '132', 'type': 'argument_list', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '134', 'type': 'call', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'python_name'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '138', 'type': 'for_in_clause', 'children': ['139', '142']}, {'id': '139', 'type': 'pattern_list', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '142', 'type': 'call', 'children': ['143', '148']}, {'id': '143', 'type': 'attribute', 'children': ['144', '147']}; {'id': '144', 'type': 'subscript', 'children': ['145', '146']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '146', 'type': 'string', 'children': [], 'value': "'in'"}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '148', 'type': 'argument_list', 'children': []}, {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'call', 'children': ['151', '154']}, {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'script'}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '154', 'type': 'argument_list', 'children': ['155']}, {'id': '155', 'type': 'call', 'children': ['156', '159']}; {'id': '156', 'type': 'attribute', 'children': ['157', '158']}, {'id': '157', 'type': 'string', 'children': [], 'value': "'{} = {}.{}({})'"}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'format'}, {'id': '159', 'type': 'argument_list', 'children': ['160', '166', '167', '168']}; {'id': '160', 'type': 'call', 'children': ['161', '164']}, {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'string', 'children': [], 'value': "', '"}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '164', 'type': 'argument_list', 'children': ['165']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'returns'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'wf_name'}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'pyname'}; {'id': '168', 'type': 'call', 'children': ['169', '172']}, {'id': '169', 'type': 'attribute', 'children': ['170', '171']}; {'id': '170', 'type': 'string', 'children': [], 'value': "', '"}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '172', 'type': 'argument_list', 'children': ['173']}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '174', 'type': 'expression_statement', 'children': ['175']}, {'id': '175', 'type': 'assignment', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'params'}, {'id': '177', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '178', 'type': 'for_statement', 'children': ['179', '182', '189']}, {'id': '179', 'type': 'pattern_list', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'details'}; {'id': '182', 'type': 'call', 'children': ['183', '188']}, {'id': '183', 'type': 'attribute', 'children': ['184', '187']}; {'id': '184', 'type': 'attribute', 'children': ['185', '186']}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'wf_outputs'}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '188', 'type': 'argument_list', 'children': []}, {'id': '189', 'type': 'block', 'children': ['190']}; {'id': '190', 'type': 'expression_statement', 'children': ['191']}, {'id': '191', 'type': 'call', 'children': ['192', '195']}; {'id': '192', 'type': 'attribute', 'children': ['193', '194']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '195', 'type': 'argument_list', 'children': ['196']}; {'id': '196', 'type': 'call', 'children': ['197', '200']}, {'id': '197', 'type': 'attribute', 'children': ['198', '199']}; {'id': '198', 'type': 'string', 'children': [], 'value': "'{}={}'"}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '200', 'type': 'argument_list', 'children': ['201', '202']}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '202', 'type': 'call', 'children': ['203', '204']}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'python_name'}; {'id': '204', 'type': 'argument_list', 'children': ['205']}, {'id': '205', 'type': 'subscript', 'children': ['206', '207']}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'details'}, {'id': '207', 'type': 'string', 'children': [], 'value': "'outputSource'"}; {'id': '208', 'type': 'expression_statement', 'children': ['209']}, {'id': '209', 'type': 'call', 'children': ['210', '213']}; {'id': '210', 'type': 'attribute', 'children': ['211', '212']}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'script'}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '213', 'type': 'argument_list', 'children': ['214']}; {'id': '214', 'type': 'call', 'children': ['215', '218']}, {'id': '215', 'type': 'attribute', 'children': ['216', '217']}; {'id': '216', 'type': 'string', 'children': [], 'value': "'{}.add_outputs({})'"}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '218', 'type': 'argument_list', 'children': ['219', '220']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'wf_name'}; {'id': '220', 'type': 'call', 'children': ['221', '224']}, {'id': '221', 'type': 'attribute', 'children': ['222', '223']}; {'id': '222', 'type': 'string', 'children': [], 'value': "', '"}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '224', 'type': 'argument_list', 'children': ['225']}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '226', 'type': 'return_statement', 'children': ['227']}, {'id': '227', 'type': 'call', 'children': ['228', '231']}; {'id': '228', 'type': 'attribute', 'children': ['229', '230']}, {'id': '229', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '231', 'type': 'argument_list', 'children': ['232']}
def to_script(self, wf_name='wf'): self._closed() script = [] # print('doc = ') params = [] returns = [] for name, typ in self.wf_inputs.items(): params.append('{}=\'{}\''.format(name, typ)) returns.append(name) script.append('{} = {}.add_inputs({})'.format( ', '.join(returns), wf_name, ', '.join(params))) returns = [] for name, step in self.wf_steps.items(): pyname = step.python_name returns = ['{}_{}'.format(pyname, o) for o in step['out']] params = ['{}={}'.format(name, python_name(param)) for name, param in step['in'].items()] script.append('{} = {}.{}({})'.format( ', '.join(returns), wf_name, pyname, ', '.join(params))) params = [] for name, details in self.wf_outputs.items(): params.append('{}={}'.format( name, python_name(details['outputSource']))) script.append('{}.add_outputs({})'.format(wf_name, ', '.join(params))) return '\n'.join(script)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '27']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '8', 'type': 'None', 'children': []}, {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'validate'}, {'id': '11', 'type': 'True', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'utf-8'"}, {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'wd'}, {'id': '17', 'type': 'False', 'children': []}; {'id': '18', 'type': 'default_parameter', 'children': ['19', '20']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'inline'}; {'id': '20', 'type': 'False', 'children': []}, {'id': '21', 'type': 'default_parameter', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'relative'}, {'id': '23', 'type': 'False', 'children': []}; {'id': '24', 'type': 'default_parameter', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '26', 'type': 'False', 'children': []}, {'id': '27', 'type': 'block', 'children': ['28', '34', '85', '94', '120', '129', '147', '165', '189', '217', '241', '254']}; {'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': '_closed'}, {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'if_statement', 'children': ['35', '38']}, {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'is'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'mode'}, {'id': '37', 'type': 'None', 'children': []}; {'id': '38', 'type': 'block', 'children': ['39', '43', '64', '77']}, {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'abs'"}, {'id': '43', 'type': 'if_statement', 'children': ['44', '45', '50', '57']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'pack'}, {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}, {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'mode'}, {'id': '49', 'type': 'string', 'children': [], 'value': "'pack'"}; {'id': '50', 'type': 'elif_clause', 'children': ['51', '52']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'wd'}; {'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': 'mode'}; {'id': '56', 'type': 'string', 'children': [], 'value': "'wd'"}, {'id': '57', 'type': 'elif_clause', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'relative'}, {'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': 'mode'}, {'id': '63', 'type': 'string', 'children': [], 'value': "'rel'"}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}, {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '67', 'type': 'call', 'children': ['68', '74']}; {'id': '68', 'type': 'attribute', 'children': ['69', '73']}, {'id': '69', 'type': 'concatenated_string', 'children': ['70', '71', '72']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'Using deprecated save method. Please save the workflow '"}, {'id': '71', 'type': 'string', 'children': [], 'value': "'with: wf.save(\\'{}\\', mode=\\'{}\\'). Redirecting to new '"}; {'id': '72', 'type': 'string', 'children': [], 'value': "'save method.'"}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'mode'}, {'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': 'warnings'}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '82', 'type': 'argument_list', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'DeprecationWarning'}, {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'modes'}; {'id': '88', 'type': 'tuple', 'children': ['89', '90', '91', '92', '93']}, {'id': '89', 'type': 'string', 'children': [], 'value': "'rel'"}; {'id': '90', 'type': 'string', 'children': [], 'value': "'abs'"}, {'id': '91', 'type': 'string', 'children': [], 'value': "'wd'"}; {'id': '92', 'type': 'string', 'children': [], 'value': "'inline'"}, {'id': '93', 'type': 'string', 'children': [], 'value': "'pack'"}; {'id': '94', 'type': 'if_statement', 'children': ['95', '98']}, {'id': '95', 'type': 'comparison_operator', 'children': ['96', '97'], 'value': 'not'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'mode'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'modes'}; {'id': '98', 'type': 'block', 'children': ['99', '115']}, {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '102']}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '102', 'type': 'call', 'children': ['103', '107']}, {'id': '103', 'type': 'attribute', 'children': ['104', '105', '106']}; {'id': '104', 'type': 'string', 'children': [], 'value': '\'Illegal mode "{}". Choose one of ({}).\''}, {'id': '105', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'format'}, {'id': '107', 'type': 'argument_list', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'mode'}, {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}, {'id': '111', 'type': 'string', 'children': [], 'value': "','"}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'modes'}, {'id': '115', 'type': 'raise_statement', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '118']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '118', 'type': 'argument_list', 'children': ['119']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '120', 'type': 'if_statement', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'validate'}; {'id': '122', 'type': 'block', 'children': ['123']}, {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '128']}, {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'validate'}; {'id': '128', 'type': 'argument_list', 'children': []}, {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'assignment', 'children': ['131', '132']}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '132', 'type': 'call', 'children': ['133', '138']}, {'id': '133', 'type': 'attribute', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '138', 'type': 'argument_list', 'children': ['139']}, {'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': 'abspath'}, {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'fname'}, {'id': '147', 'type': 'if_statement', 'children': ['148', '157']}; {'id': '148', 'type': 'not_operator', 'children': ['149']}, {'id': '149', 'type': 'call', 'children': ['150', '155']}; {'id': '150', 'type': 'attribute', 'children': ['151', '154']}, {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'exists'}, {'id': '155', 'type': 'argument_list', 'children': ['156']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'dirname'}, {'id': '157', 'type': 'block', 'children': ['158']}; {'id': '158', 'type': 'expression_statement', 'children': ['159']}, {'id': '159', 'type': 'call', 'children': ['160', '163']}; {'id': '160', 'type': 'attribute', 'children': ['161', '162']}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'makedirs'}, {'id': '163', 'type': 'argument_list', 'children': ['164']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'dirname'}, {'id': '165', 'type': 'if_statement', 'children': ['166', '169']}; {'id': '166', 'type': 'comparison_operator', 'children': ['167', '168'], 'value': '=='}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '168', 'type': 'string', 'children': [], 'value': "'inline'"}, {'id': '169', 'type': 'block', 'children': ['170', '177', '185']}; {'id': '170', 'type': 'expression_statement', 'children': ['171']}, {'id': '171', 'type': 'assignment', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '173', 'type': 'parenthesized_expression', 'children': ['174']}; {'id': '174', 'type': 'concatenated_string', 'children': ['175', '176']}, {'id': '175', 'type': 'string', 'children': [], 'value': "'Inline saving is deprecated. Please save the workflow '"}; {'id': '176', 'type': 'string', 'children': [], 'value': "'using mode=\\'pack\\'. Setting mode to pack.'"}, {'id': '177', 'type': 'expression_statement', 'children': ['178']}; {'id': '178', 'type': 'call', 'children': ['179', '182']}, {'id': '179', 'type': 'attribute', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'warnings'}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '182', 'type': 'argument_list', 'children': ['183', '184']}, {'id': '183', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'DeprecationWarning'}, {'id': '185', 'type': 'expression_statement', 'children': ['186']}; {'id': '186', 'type': 'assignment', 'children': ['187', '188']}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '188', 'type': 'string', 'children': [], 'value': "'pack'"}, {'id': '189', 'type': 'if_statement', 'children': ['190', '193']}; {'id': '190', 'type': 'comparison_operator', 'children': ['191', '192'], 'value': '=='}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '192', 'type': 'string', 'children': [], 'value': "'rel'"}, {'id': '193', 'type': 'block', 'children': ['194', '198']}; {'id': '194', 'type': 'expression_statement', 'children': ['195']}, {'id': '195', 'type': 'assignment', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'relpath'}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '198', 'type': 'expression_statement', 'children': ['199']}, {'id': '199', 'type': 'call', 'children': ['200', '201']}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'save_yaml'}, {'id': '201', 'type': 'argument_list', 'children': ['202', '205', '208', '211', '214']}; {'id': '202', 'type': 'keyword_argument', 'children': ['203', '204']}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'fname'}, {'id': '205', 'type': 'keyword_argument', 'children': ['206', '207']}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'wf'}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '208', 'type': 'keyword_argument', 'children': ['209', '210']}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '210', 'type': 'False', 'children': []}, {'id': '211', 'type': 'keyword_argument', 'children': ['212', '213']}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'relpath'}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'relpath'}; {'id': '214', 'type': 'keyword_argument', 'children': ['215', '216']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'wd'}; {'id': '216', 'type': 'False', 'children': []}, {'id': '217', 'type': 'if_statement', 'children': ['218', '221']}; {'id': '218', 'type': 'comparison_operator', 'children': ['219', '220'], 'value': '=='}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '220', 'type': 'string', 'children': [], 'value': "'abs'"}, {'id': '221', 'type': 'block', 'children': ['222']}; {'id': '222', 'type': 'expression_statement', 'children': ['223']}, {'id': '223', 'type': 'call', 'children': ['224', '225']}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'save_yaml'}, {'id': '225', 'type': 'argument_list', 'children': ['226', '229', '232', '235', '238']}; {'id': '226', 'type': 'keyword_argument', 'children': ['227', '228']}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'fname'}, {'id': '229', 'type': 'keyword_argument', 'children': ['230', '231']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'wf'}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '232', 'type': 'keyword_argument', 'children': ['233', '234']}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '234', 'type': 'False', 'children': []}, {'id': '235', 'type': 'keyword_argument', 'children': ['236', '237']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'relpath'}, {'id': '237', 'type': 'None', 'children': []}; {'id': '238', 'type': 'keyword_argument', 'children': ['239', '240']}, {'id': '239', 'type': 'identifier', 'children': [], 'value': 'wd'}; {'id': '240', 'type': 'False', 'children': []}, {'id': '241', 'type': 'if_statement', 'children': ['242', '245']}; {'id': '242', 'type': 'comparison_operator', 'children': ['243', '244'], 'value': '=='}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '244', 'type': 'string', 'children': [], 'value': "'pack'"}, {'id': '245', 'type': 'block', 'children': ['246']}; {'id': '246', 'type': 'expression_statement', 'children': ['247']}, {'id': '247', 'type': 'call', 'children': ['248', '251']}; {'id': '248', 'type': 'attribute', 'children': ['249', '250']}, {'id': '249', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '250', 'type': 'identifier', 'children': [], 'value': '_pack'}, {'id': '251', 'type': 'argument_list', 'children': ['252', '253']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'fname'}, {'id': '253', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '254', 'type': 'if_statement', 'children': ['255', '258']}, {'id': '255', 'type': 'comparison_operator', 'children': ['256', '257'], 'value': '=='}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'mode'}, {'id': '257', 'type': 'string', 'children': [], 'value': "'wd'"}; {'id': '258', 'type': 'block', 'children': ['259']}, {'id': '259', 'type': 'if_statement', 'children': ['260', '267', '273']}; {'id': '260', 'type': 'comparison_operator', 'children': ['261', '266'], 'value': 'is'}, {'id': '261', 'type': 'call', 'children': ['262', '265']}; {'id': '262', 'type': 'attribute', 'children': ['263', '264']}, {'id': '263', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'get_working_dir'}, {'id': '265', 'type': 'argument_list', 'children': []}; {'id': '266', 'type': 'None', 'children': []}, {'id': '267', 'type': 'block', 'children': ['268']}; {'id': '268', 'type': 'raise_statement', 'children': ['269']}, {'id': '269', 'type': 'call', 'children': ['270', '271']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '271', 'type': 'argument_list', 'children': ['272']}; {'id': '272', 'type': 'string', 'children': [], 'value': "'Working directory not set.'"}, {'id': '273', 'type': 'else_clause', 'children': ['274']}; {'id': '274', 'type': 'block', 'children': ['275', '286', '300', '319']}, {'id': '275', 'type': 'expression_statement', 'children': ['276']}; {'id': '276', 'type': 'assignment', 'children': ['277', '278']}, {'id': '277', 'type': 'identifier', 'children': [], 'value': 'bn'}; {'id': '278', 'type': 'call', 'children': ['279', '284']}, {'id': '279', 'type': 'attribute', 'children': ['280', '283']}; {'id': '280', 'type': 'attribute', 'children': ['281', '282']}, {'id': '281', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '282', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '283', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '284', 'type': 'argument_list', 'children': ['285']}, {'id': '285', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '286', 'type': 'expression_statement', 'children': ['287']}, {'id': '287', 'type': 'assignment', 'children': ['288', '289']}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'wd_file'}, {'id': '289', 'type': 'call', 'children': ['290', '295']}; {'id': '290', 'type': 'attribute', 'children': ['291', '294']}, {'id': '291', 'type': 'attribute', 'children': ['292', '293']}; {'id': '292', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '293', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '295', 'type': 'argument_list', 'children': ['296', '299']}; {'id': '296', 'type': 'attribute', 'children': ['297', '298']}, {'id': '297', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '298', 'type': 'identifier', 'children': [], 'value': 'working_dir'}, {'id': '299', 'type': 'identifier', 'children': [], 'value': 'bn'}; {'id': '300', 'type': 'expression_statement', 'children': ['301']}, {'id': '301', 'type': 'call', 'children': ['302', '303']}; {'id': '302', 'type': 'identifier', 'children': [], 'value': 'save_yaml'}, {'id': '303', 'type': 'argument_list', 'children': ['304', '307', '310', '313', '316']}; {'id': '304', 'type': 'keyword_argument', 'children': ['305', '306']}, {'id': '305', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '306', 'type': 'identifier', 'children': [], 'value': 'wd_file'}, {'id': '307', 'type': 'keyword_argument', 'children': ['308', '309']}; {'id': '308', 'type': 'identifier', 'children': [], 'value': 'wf'}, {'id': '309', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '310', 'type': 'keyword_argument', 'children': ['311', '312']}, {'id': '311', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '312', 'type': 'False', 'children': []}, {'id': '313', 'type': 'keyword_argument', 'children': ['314', '315']}; {'id': '314', 'type': 'identifier', 'children': [], 'value': 'relpath'}, {'id': '315', 'type': 'None', 'children': []}; {'id': '316', 'type': 'keyword_argument', 'children': ['317', '318']}, {'id': '317', 'type': 'identifier', 'children': [], 'value': 'wd'}; {'id': '318', 'type': 'True', 'children': []}, {'id': '319', 'type': 'try_statement', 'children': ['320', '329']}; {'id': '320', 'type': 'block', 'children': ['321']}, {'id': '321', 'type': 'expression_statement', 'children': ['322']}; {'id': '322', 'type': 'call', 'children': ['323', '326']}, {'id': '323', 'type': 'attribute', 'children': ['324', '325']}; {'id': '324', 'type': 'identifier', 'children': [], 'value': 'shutil'}, {'id': '325', 'type': 'identifier', 'children': [], 'value': 'copy2'}; {'id': '326', 'type': 'argument_list', 'children': ['327', '328']}, {'id': '327', 'type': 'identifier', 'children': [], 'value': 'wd_file'}; {'id': '328', 'type': 'identifier', 'children': [], 'value': 'fname'}, {'id': '329', 'type': 'except_clause', 'children': ['330', '333']}; {'id': '330', 'type': 'attribute', 'children': ['331', '332']}, {'id': '331', 'type': 'identifier', 'children': [], 'value': 'shutil'}; {'id': '332', 'type': 'identifier', 'children': [], 'value': 'Error'}, {'id': '333', 'type': 'block', 'children': ['334']}
def save(self, fname, mode=None, validate=True, encoding='utf-8', wd=False, inline=False, relative=False, pack=False): self._closed() if mode is None: mode = 'abs' if pack: mode = 'pack' elif wd: mode = 'wd' elif relative: mode = 'rel' msg = 'Using deprecated save method. Please save the workflow ' \ 'with: wf.save(\'{}\', mode=\'{}\'). Redirecting to new ' \ 'save method.'.format(fname, mode) warnings.warn(msg, DeprecationWarning) modes = ('rel', 'abs', 'wd', 'inline', 'pack') if mode not in modes: msg = 'Illegal mode "{}". Choose one of ({}).'\ .format(mode, ','.join(modes)) raise ValueError(msg) if validate: self.validate() dirname = os.path.dirname(os.path.abspath(fname)) if not os.path.exists(dirname): os.makedirs(dirname) if mode == 'inline': msg = ('Inline saving is deprecated. Please save the workflow ' 'using mode=\'pack\'. Setting mode to pack.') warnings.warn(msg, DeprecationWarning) mode = 'pack' if mode == 'rel': relpath = dirname save_yaml(fname=fname, wf=self, pack=False, relpath=relpath, wd=False) if mode == 'abs': save_yaml(fname=fname, wf=self, pack=False, relpath=None, wd=False) if mode == 'pack': self._pack(fname, encoding) if mode == 'wd': if self.get_working_dir() is None: raise ValueError('Working directory not set.') else: bn = os.path.basename(fname) wd_file = os.path.join(self.working_dir, bn) save_yaml(fname=wd_file, wf=self, pack=False, relpath=None, wd=True) try: shutil.copy2(wd_file, fname) except shutil.Error: pass
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_snodas_ds'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dem_dt'}, {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'code'}, {'id': '7', 'type': 'integer', 'children': [], 'value': '1036'}; {'id': '8', 'type': 'block', 'children': ['9', '12', '15', '19', '23', '35', '53', '105', '339']}, {'id': '9', 'type': 'import_statement', 'children': ['10']}; {'id': '10', 'type': 'dotted_name', 'children': ['11']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'tarfile'}; {'id': '12', 'type': 'import_statement', 'children': ['13']}, {'id': '13', 'type': 'dotted_name', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'gzip'}, {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'snodas_ds'}; {'id': '18', 'type': 'None', 'children': []}, {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'snodas_url_str'}; {'id': '22', 'type': 'None', 'children': []}, {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'outdir'}; {'id': '26', 'type': 'call', 'children': ['27', '32']}, {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'datadir'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'snodas'"}, {'id': '35', 'type': 'if_statement', 'children': ['36', '45']}; {'id': '36', 'type': 'not_operator', 'children': ['37']}, {'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': 'exists'}, {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'outdir'}, {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}, {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'makedirs'}, {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'outdir'}, {'id': '53', 'type': 'if_statement', 'children': ['54', '71', '80', '98']}; {'id': '54', 'type': 'boolean_operator', 'children': ['55', '63'], 'value': 'and'}, {'id': '55', 'type': 'comparison_operator', 'children': ['56', '57'], 'value': '>='}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'dem_dt'}, {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'datetime'}, {'id': '59', 'type': 'argument_list', 'children': ['60', '61', '62']}; {'id': '60', 'type': 'integer', 'children': [], 'value': '2003'}, {'id': '61', 'type': 'integer', 'children': [], 'value': '9'}; {'id': '62', 'type': 'integer', 'children': [], 'value': '30'}, {'id': '63', 'type': 'comparison_operator', 'children': ['64', '65'], 'value': '<'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'dem_dt'}, {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'datetime'}, {'id': '67', 'type': 'argument_list', 'children': ['68', '69', '70']}; {'id': '68', 'type': 'integer', 'children': [], 'value': '2010'}, {'id': '69', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '70', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '71', 'type': 'block', 'children': ['72', '76']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}, {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'snodas_url_str'}, {'id': '75', 'type': 'string', 'children': [], 'value': "'ftp://sidads.colorado.edu/DATASETS/NOAA/G02158/masked/%Y/%m_%b/SNODAS_%Y%m%d.tar'"}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}, {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'tar_subfn_str_fmt'}, {'id': '79', 'type': 'string', 'children': [], 'value': "'us_ssmv1%itS__T0001TTNATS%%Y%%m%%d05HP001.%s.gz'"}; {'id': '80', 'type': 'elif_clause', 'children': ['81', '89']}, {'id': '81', 'type': 'comparison_operator', 'children': ['82', '83'], 'value': '>='}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'dem_dt'}, {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'datetime'}, {'id': '85', 'type': 'argument_list', 'children': ['86', '87', '88']}; {'id': '86', 'type': 'integer', 'children': [], 'value': '2010'}, {'id': '87', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '88', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '89', 'type': 'block', 'children': ['90', '94']}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}, {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'snodas_url_str'}, {'id': '93', 'type': 'string', 'children': [], 'value': "'ftp://sidads.colorado.edu/DATASETS/NOAA/G02158/unmasked/%Y/%m_%b/SNODAS_unmasked_%Y%m%d.tar'"}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}, {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'tar_subfn_str_fmt'}, {'id': '97', 'type': 'string', 'children': [], 'value': "'./zz_ssmv1%itS__T0001TTNATS%%Y%%m%%d05HP001.%s.gz'"}; {'id': '98', 'type': 'else_clause', 'children': ['99']}, {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}, {'id': '101', 'type': 'call', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'print'}, {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'string', 'children': [], 'value': '"No SNODAS data available for input date"'}, {'id': '105', 'type': 'if_statement', 'children': ['106', '109']}; {'id': '106', 'type': 'comparison_operator', 'children': ['107', '108'], 'value': 'is'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'snodas_url_str'}; {'id': '108', 'type': 'None', 'children': []}, {'id': '109', 'type': 'block', 'children': ['110', '119', '131', '136', '145', '267', '271', '275', '282', '286', '303', '309', '317', '324', '330']}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}, {'id': '111', 'type': 'assignment', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'snodas_url'}, {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'dem_dt'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'strftime'}, {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'snodas_url_str'}, {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'assignment', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'snodas_tar_fn'}; {'id': '122', 'type': 'call', 'children': ['123', '126']}, {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'iolib'}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'getfile'}; {'id': '126', 'type': 'argument_list', 'children': ['127', '128']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'snodas_url'}; {'id': '128', 'type': 'keyword_argument', 'children': ['129', '130']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'outdir'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'outdir'}, {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'call', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}, {'id': '135', 'type': 'string', 'children': [], 'value': '"Unpacking"'}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}, {'id': '137', 'type': 'assignment', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'tar'}, {'id': '139', 'type': 'call', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'tarfile'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'open'}, {'id': '143', 'type': 'argument_list', 'children': ['144']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'snodas_tar_fn'}, {'id': '145', 'type': 'for_statement', 'children': ['146', '147', '150']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'ext'}, {'id': '147', 'type': 'tuple', 'children': ['148', '149']}; {'id': '148', 'type': 'string', 'children': [], 'value': "'dat'"}, {'id': '149', 'type': 'string', 'children': [], 'value': "'Hdr'"}; {'id': '150', 'type': 'block', 'children': ['151', '159', '168', '181', '186', '203']}, {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'assignment', 'children': ['153', '154']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'tar_subfn_str'}; {'id': '154', 'type': 'binary_operator', 'children': ['155', '156'], 'value': '%'}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'tar_subfn_str_fmt'}; {'id': '156', 'type': 'tuple', 'children': ['157', '158']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'ext'}, {'id': '159', 'type': 'expression_statement', 'children': ['160']}; {'id': '160', 'type': 'assignment', 'children': ['161', '162']}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'tar_subfn_gz'}; {'id': '162', 'type': 'call', 'children': ['163', '166']}, {'id': '163', 'type': 'attribute', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'dem_dt'}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'strftime'}; {'id': '166', 'type': 'argument_list', 'children': ['167']}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'tar_subfn_str'}; {'id': '168', 'type': 'expression_statement', 'children': ['169']}, {'id': '169', 'type': 'assignment', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'tar_subfn'}, {'id': '171', 'type': 'subscript', 'children': ['172', '180']}; {'id': '172', 'type': 'call', 'children': ['173', '178']}, {'id': '173', 'type': 'attribute', 'children': ['174', '177']}; {'id': '174', 'type': 'attribute', 'children': ['175', '176']}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'splitext'}; {'id': '178', 'type': 'argument_list', 'children': ['179']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'tar_subfn_gz'}; {'id': '180', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '181', 'type': 'expression_statement', 'children': ['182']}; {'id': '182', 'type': 'call', 'children': ['183', '184']}, {'id': '183', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '184', 'type': 'argument_list', 'children': ['185']}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'tar_subfn'}; {'id': '186', 'type': 'if_statement', 'children': ['187', '190']}, {'id': '187', 'type': 'comparison_operator', 'children': ['188', '189'], 'value': 'is'}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'outdir'}, {'id': '189', 'type': 'None', 'children': []}; {'id': '190', 'type': 'block', 'children': ['191']}, {'id': '191', 'type': 'expression_statement', 'children': ['192']}; {'id': '192', 'type': 'assignment', 'children': ['193', '194']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'tar_subfn'}; {'id': '194', 'type': 'call', 'children': ['195', '200']}, {'id': '195', 'type': 'attribute', 'children': ['196', '199']}; {'id': '196', 'type': 'attribute', 'children': ['197', '198']}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '200', 'type': 'argument_list', 'children': ['201', '202']}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'outdir'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'tar_subfn'}, {'id': '203', 'type': 'if_statement', 'children': ['204', '213']}; {'id': '204', 'type': 'not_operator', 'children': ['205']}, {'id': '205', 'type': 'call', 'children': ['206', '211']}; {'id': '206', 'type': 'attribute', 'children': ['207', '210']}, {'id': '207', 'type': 'attribute', 'children': ['208', '209']}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'exists'}, {'id': '211', 'type': 'argument_list', 'children': ['212']}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'tar_subfn'}, {'id': '213', 'type': 'block', 'children': ['214', '221', '260']}; {'id': '214', 'type': 'expression_statement', 'children': ['215']}, {'id': '215', 'type': 'call', 'children': ['216', '219']}; {'id': '216', 'type': 'attribute', 'children': ['217', '218']}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'tar'}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'extract'}, {'id': '219', 'type': 'argument_list', 'children': ['220']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'tar_subfn_gz'}, {'id': '221', 'type': 'with_statement', 'children': ['222', '234']}; {'id': '222', 'type': 'with_clause', 'children': ['223']}, {'id': '223', 'type': 'with_item', 'children': ['224']}; {'id': '224', 'type': 'as_pattern', 'children': ['225', '232']}, {'id': '225', 'type': 'call', 'children': ['226', '229']}; {'id': '226', 'type': 'attribute', 'children': ['227', '228']}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'gzip'}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'open'}, {'id': '229', 'type': 'argument_list', 'children': ['230', '231']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'tar_subfn_gz'}, {'id': '231', 'type': 'string', 'children': [], 'value': "'rb'"}; {'id': '232', 'type': 'as_pattern_target', 'children': ['233']}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '234', 'type': 'block', 'children': ['235', '243', '254']}, {'id': '235', 'type': 'expression_statement', 'children': ['236']}; {'id': '236', 'type': 'assignment', 'children': ['237', '238']}, {'id': '237', 'type': 'identifier', 'children': [], 'value': 'outf'}; {'id': '238', 'type': 'call', 'children': ['239', '240']}, {'id': '239', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '240', 'type': 'argument_list', 'children': ['241', '242']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'tar_subfn'}; {'id': '242', 'type': 'string', 'children': [], 'value': "'wb'"}, {'id': '243', 'type': 'expression_statement', 'children': ['244']}; {'id': '244', 'type': 'call', 'children': ['245', '248']}, {'id': '245', 'type': 'attribute', 'children': ['246', '247']}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'outf'}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '248', 'type': 'argument_list', 'children': ['249']}, {'id': '249', 'type': 'call', 'children': ['250', '253']}; {'id': '250', 'type': 'attribute', 'children': ['251', '252']}, {'id': '251', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'read'}, {'id': '253', 'type': 'argument_list', 'children': []}; {'id': '254', 'type': 'expression_statement', 'children': ['255']}, {'id': '255', 'type': 'call', 'children': ['256', '259']}; {'id': '256', 'type': 'attribute', 'children': ['257', '258']}, {'id': '257', 'type': 'identifier', 'children': [], 'value': 'outf'}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'close'}, {'id': '259', 'type': 'argument_list', 'children': []}; {'id': '260', 'type': 'expression_statement', 'children': ['261']}, {'id': '261', 'type': 'call', 'children': ['262', '265']}; {'id': '262', 'type': 'attribute', 'children': ['263', '264']}, {'id': '263', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'remove'}, {'id': '265', 'type': 'argument_list', 'children': ['266']}; {'id': '266', 'type': 'identifier', 'children': [], 'value': 'tar_subfn_gz'}, {'id': '267', 'type': 'expression_statement', 'children': ['268']}; {'id': '268', 'type': 'assignment', 'children': ['269', '270']}, {'id': '269', 'type': 'identifier', 'children': [], 'value': 'bad_str'}; {'id': '270', 'type': 'string', 'children': [], 'value': "'Created by module comment'"}, {'id': '271', 'type': 'expression_statement', 'children': ['272']}; {'id': '272', 'type': 'assignment', 'children': ['273', '274']}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'snodas_fn'}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'tar_subfn'}, {'id': '275', 'type': 'expression_statement', 'children': ['276']}; {'id': '276', 'type': 'assignment', 'children': ['277', '278']}, {'id': '277', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '278', 'type': 'call', 'children': ['279', '280']}, {'id': '279', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '280', 'type': 'argument_list', 'children': ['281']}, {'id': '281', 'type': 'identifier', 'children': [], 'value': 'snodas_fn'}; {'id': '282', 'type': 'expression_statement', 'children': ['283']}, {'id': '283', 'type': 'assignment', 'children': ['284', '285']}; {'id': '284', 'type': 'identifier', 'children': [], 'value': 'output'}, {'id': '285', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '286', 'type': 'for_statement', 'children': ['287', '288', '289']}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '289', 'type': 'block', 'children': ['290']}; {'id': '290', 'type': 'if_statement', 'children': ['291', '295']}, {'id': '291', 'type': 'not_operator', 'children': ['292']}; {'id': '292', 'type': 'comparison_operator', 'children': ['293', '294'], 'value': 'in'}, {'id': '293', 'type': 'identifier', 'children': [], 'value': 'bad_str'}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '295', 'type': 'block', 'children': ['296']}; {'id': '296', 'type': 'expression_statement', 'children': ['297']}, {'id': '297', 'type': 'call', 'children': ['298', '301']}; {'id': '298', 'type': 'attribute', 'children': ['299', '300']}, {'id': '299', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '300', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '301', 'type': 'argument_list', 'children': ['302']}; {'id': '302', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '303', 'type': 'expression_statement', 'children': ['304']}; {'id': '304', 'type': 'call', 'children': ['305', '308']}, {'id': '305', 'type': 'attribute', 'children': ['306', '307']}; {'id': '306', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '307', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '308', 'type': 'argument_list', 'children': []}, {'id': '309', 'type': 'expression_statement', 'children': ['310']}; {'id': '310', 'type': 'assignment', 'children': ['311', '312']}, {'id': '311', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '312', 'type': 'call', 'children': ['313', '314']}, {'id': '313', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '314', 'type': 'argument_list', 'children': ['315', '316']}, {'id': '315', 'type': 'identifier', 'children': [], 'value': 'snodas_fn'}; {'id': '316', 'type': 'string', 'children': [], 'value': "'w'"}, {'id': '317', 'type': 'expression_statement', 'children': ['318']}; {'id': '318', 'type': 'call', 'children': ['319', '322']}, {'id': '319', 'type': 'attribute', 'children': ['320', '321']}; {'id': '320', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '321', 'type': 'identifier', 'children': [], 'value': 'writelines'}; {'id': '322', 'type': 'argument_list', 'children': ['323']}, {'id': '323', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '324', 'type': 'expression_statement', 'children': ['325']}, {'id': '325', 'type': 'call', 'children': ['326', '329']}; {'id': '326', 'type': 'attribute', 'children': ['327', '328']}, {'id': '327', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '328', 'type': 'identifier', 'children': [], 'value': 'close'}, {'id': '329', 'type': 'argument_list', 'children': []}; {'id': '330', 'type': 'expression_statement', 'children': ['331']}, {'id': '331', 'type': 'assignment', 'children': ['332', '333']}; {'id': '332', 'type': 'identifier', 'children': [], 'value': 'snodas_ds'}, {'id': '333', 'type': 'call', 'children': ['334', '337']}; {'id': '334', 'type': 'attribute', 'children': ['335', '336']}, {'id': '335', 'type': 'identifier', 'children': [], 'value': 'gdal'}; {'id': '336', 'type': 'identifier', 'children': [], 'value': 'Open'}, {'id': '337', 'type': 'argument_list', 'children': ['338']}; {'id': '338', 'type': 'identifier', 'children': [], 'value': 'snodas_fn'}, {'id': '339', 'type': 'return_statement', 'children': ['340']}
def get_snodas_ds(dem_dt, code=1036): import tarfile import gzip snodas_ds = None snodas_url_str = None outdir = os.path.join(datadir, 'snodas') if not os.path.exists(outdir): os.makedirs(outdir) if dem_dt >= datetime(2003,9,30) and dem_dt < datetime(2010,1,1): snodas_url_str = 'ftp://sidads.colorado.edu/DATASETS/NOAA/G02158/masked/%Y/%m_%b/SNODAS_%Y%m%d.tar' tar_subfn_str_fmt = 'us_ssmv1%itS__T0001TTNATS%%Y%%m%%d05HP001.%s.gz' elif dem_dt >= datetime(2010,1,1): snodas_url_str = 'ftp://sidads.colorado.edu/DATASETS/NOAA/G02158/unmasked/%Y/%m_%b/SNODAS_unmasked_%Y%m%d.tar' tar_subfn_str_fmt = './zz_ssmv1%itS__T0001TTNATS%%Y%%m%%d05HP001.%s.gz' else: print("No SNODAS data available for input date") if snodas_url_str is not None: snodas_url = dem_dt.strftime(snodas_url_str) snodas_tar_fn = iolib.getfile(snodas_url, outdir=outdir) print("Unpacking") tar = tarfile.open(snodas_tar_fn) for ext in ('dat', 'Hdr'): tar_subfn_str = tar_subfn_str_fmt % (code, ext) tar_subfn_gz = dem_dt.strftime(tar_subfn_str) tar_subfn = os.path.splitext(tar_subfn_gz)[0] print(tar_subfn) if outdir is not None: tar_subfn = os.path.join(outdir, tar_subfn) if not os.path.exists(tar_subfn): tar.extract(tar_subfn_gz) with gzip.open(tar_subfn_gz, 'rb') as f: outf = open(tar_subfn, 'wb') outf.write(f.read()) outf.close() os.remove(tar_subfn_gz) bad_str = 'Created by module comment' snodas_fn = tar_subfn f = open(snodas_fn) output = [] for line in f: if not bad_str in line: output.append(line) f.close() f = open(snodas_fn, 'w') f.writelines(output) f.close() snodas_ds = gdal.Open(snodas_fn) return snodas_ds
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_modscag_fn_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '13']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dem_dt'}, {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'tile_list'}, {'id': '7', 'type': 'tuple', 'children': ['8', '9', '10', '11', '12']}; {'id': '8', 'type': 'string', 'children': [], 'value': "'h08v04'"}, {'id': '9', 'type': 'string', 'children': [], 'value': "'h09v04'"}; {'id': '10', 'type': 'string', 'children': [], 'value': "'h10v04'"}, {'id': '11', 'type': 'string', 'children': [], 'value': "'h08v05'"}; {'id': '12', 'type': 'string', 'children': [], 'value': "'h09v05'"}, {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'pad_days'}, {'id': '15', 'type': 'integer', 'children': [], 'value': '7'}; {'id': '16', 'type': 'block', 'children': ['17', '20', '23', '28', '36', '45', '68', '80', '98', '102', '483']}, {'id': '17', 'type': 'import_statement', 'children': ['18']}; {'id': '18', 'type': 'dotted_name', 'children': ['19']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '20', 'type': 'import_statement', 'children': ['21']}, {'id': '21', 'type': 'dotted_name', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'requests'}, {'id': '23', 'type': 'import_from_statement', 'children': ['24', '26']}; {'id': '24', 'type': 'dotted_name', 'children': ['25']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'bs4'}; {'id': '26', 'type': 'dotted_name', 'children': ['27']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'BeautifulSoup'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}, {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'auth'}, {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'iolib'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get_auth'}, {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}, {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'pad_days'}, {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'timedelta'}, {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'pad_days'}, {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'dt_list'}; {'id': '48', 'type': 'call', 'children': ['49', '52']}, {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'timelib'}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'dt_range'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '56', '64']}, {'id': '53', 'type': 'binary_operator', 'children': ['54', '55'], 'value': '-'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'dem_dt'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'pad_days'}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '60'], 'value': '+'}, {'id': '57', 'type': 'binary_operator', 'children': ['58', '59'], 'value': '+'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'dem_dt'}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'pad_days'}; {'id': '60', 'type': 'call', 'children': ['61', '62']}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}, {'id': '63', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}, {'id': '67', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}, {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'outdir'}, {'id': '71', 'type': 'call', 'children': ['72', '77']}; {'id': '72', 'type': 'attribute', 'children': ['73', '76']}, {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '77', 'type': 'argument_list', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'datadir'}, {'id': '79', 'type': 'string', 'children': [], 'value': "'modscag'"}; {'id': '80', 'type': 'if_statement', 'children': ['81', '90']}, {'id': '81', 'type': 'not_operator', 'children': ['82']}; {'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': 'exists'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'outdir'}; {'id': '90', 'type': 'block', 'children': ['91']}, {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '96']}, {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'makedirs'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'outdir'}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}, {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'out_vrt_fn_list'}, {'id': '101', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '102', 'type': 'for_statement', 'children': ['103', '104', '105']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'dt_list'}, {'id': '105', 'type': 'block', 'children': ['106', '123', '177', '181', '443']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}, {'id': '107', 'type': 'assignment', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'out_vrt_fn'}, {'id': '109', 'type': 'call', 'children': ['110', '115']}; {'id': '110', 'type': 'attribute', 'children': ['111', '114']}, {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '115', 'type': 'argument_list', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'outdir'}, {'id': '117', 'type': 'call', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'strftime'}, {'id': '121', 'type': 'argument_list', 'children': ['122']}; {'id': '122', 'type': 'string', 'children': [], 'value': "'%Y%m%d_snow_fraction.vrt'"}, {'id': '123', 'type': 'if_statement', 'children': ['124', '132']}; {'id': '124', 'type': 'call', 'children': ['125', '130']}, {'id': '125', 'type': 'attribute', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '130', 'type': 'argument_list', 'children': ['131']}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'out_vrt_fn'}; {'id': '132', 'type': 'block', 'children': ['133', '142']}, {'id': '133', 'type': 'expression_statement', 'children': ['134']}; {'id': '134', 'type': 'assignment', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'vrt_ds'}; {'id': '136', 'type': 'call', 'children': ['137', '140']}, {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'gdal'}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'Open'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'out_vrt_fn'}; {'id': '142', 'type': 'if_statement', 'children': ['143', '168']}, {'id': '143', 'type': 'call', 'children': ['144', '147']}; {'id': '144', 'type': 'attribute', 'children': ['145', '146']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'all'}, {'id': '147', 'type': 'argument_list', 'children': ['148']}; {'id': '148', 'type': 'list_comprehension', 'children': ['149', '165']}, {'id': '149', 'type': 'call', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'any'}, {'id': '153', 'type': 'argument_list', 'children': ['154']}; {'id': '154', 'type': 'list_comprehension', 'children': ['155', '158']}, {'id': '155', 'type': 'comparison_operator', 'children': ['156', '157'], 'value': 'in'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'tile'}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'sub_fn'}; {'id': '158', 'type': 'for_in_clause', 'children': ['159', '160']}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'sub_fn'}; {'id': '160', 'type': 'call', 'children': ['161', '164']}, {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'vrt_ds'}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'GetFileList'}; {'id': '164', 'type': 'argument_list', 'children': []}, {'id': '165', 'type': 'for_in_clause', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'tile'}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'tile_list'}; {'id': '168', 'type': 'block', 'children': ['169', '176']}, {'id': '169', 'type': 'expression_statement', 'children': ['170']}; {'id': '170', 'type': 'call', 'children': ['171', '174']}, {'id': '171', 'type': 'attribute', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'out_vrt_fn_list'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '174', 'type': 'argument_list', 'children': ['175']}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'out_vrt_fn'}; {'id': '176', 'type': 'continue_statement', 'children': []}, {'id': '177', 'type': 'expression_statement', 'children': ['178']}; {'id': '178', 'type': 'assignment', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'modscag_fn_list'}; {'id': '180', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '181', 'type': 'for_statement', 'children': ['182', '183', '184']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'tile'}, {'id': '183', 'type': 'identifier', 'children': [], 'value': 'tile_list'}; {'id': '184', 'type': 'block', 'children': ['185', '189', '198', '205', '217', '221', '254', '290', '323']}, {'id': '185', 'type': 'expression_statement', 'children': ['186']}; {'id': '186', 'type': 'assignment', 'children': ['187', '188']}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'modscag_url_str'}; {'id': '188', 'type': 'string', 'children': [], 'value': "'https://snow-data.jpl.nasa.gov/modscag-historic/%Y/%j/'"}, {'id': '189', 'type': 'expression_statement', 'children': ['190']}; {'id': '190', 'type': 'assignment', 'children': ['191', '192']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'modscag_url_base'}; {'id': '192', 'type': 'call', 'children': ['193', '196']}, {'id': '193', 'type': 'attribute', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'dt'}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'strftime'}; {'id': '196', 'type': 'argument_list', 'children': ['197']}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'modscag_url_str'}; {'id': '198', 'type': 'expression_statement', 'children': ['199']}, {'id': '199', 'type': 'call', 'children': ['200', '201']}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'print'}, {'id': '201', 'type': 'argument_list', 'children': ['202']}; {'id': '202', 'type': 'binary_operator', 'children': ['203', '204'], 'value': '%'}, {'id': '203', 'type': 'string', 'children': [], 'value': '"Trying: %s"'}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'modscag_url_base'}, {'id': '205', 'type': 'expression_statement', 'children': ['206']}; {'id': '206', 'type': 'assignment', 'children': ['207', '208']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '208', 'type': 'call', 'children': ['209', '212']}, {'id': '209', 'type': 'attribute', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'requests'}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '212', 'type': 'argument_list', 'children': ['213', '214']}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'modscag_url_base'}; {'id': '214', 'type': 'keyword_argument', 'children': ['215', '216']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'auth'}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'auth'}, {'id': '217', 'type': 'expression_statement', 'children': ['218']}; {'id': '218', 'type': 'assignment', 'children': ['219', '220']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'modscag_url_fn'}; {'id': '220', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '221', 'type': 'if_statement', 'children': ['222', '225']}; {'id': '222', 'type': 'attribute', 'children': ['223', '224']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'ok'}, {'id': '225', 'type': 'block', 'children': ['226', '236']}; {'id': '226', 'type': 'expression_statement', 'children': ['227']}, {'id': '227', 'type': 'assignment', 'children': ['228', '229']}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'parsed_html'}, {'id': '229', 'type': 'call', 'children': ['230', '231']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'BeautifulSoup'}, {'id': '231', 'type': 'argument_list', 'children': ['232', '235']}; {'id': '232', 'type': 'attribute', 'children': ['233', '234']}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'content'}, {'id': '235', 'type': 'string', 'children': [], 'value': '"html.parser"'}; {'id': '236', 'type': 'expression_statement', 'children': ['237']}, {'id': '237', 'type': 'assignment', 'children': ['238', '239']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'modscag_url_fn'}, {'id': '239', 'type': 'call', 'children': ['240', '243']}; {'id': '240', 'type': 'attribute', 'children': ['241', '242']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'parsed_html'}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'findAll'}, {'id': '243', 'type': 'argument_list', 'children': ['244']}; {'id': '244', 'type': 'keyword_argument', 'children': ['245', '246']}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '246', 'type': 'call', 'children': ['247', '250']}, {'id': '247', 'type': 'attribute', 'children': ['248', '249']}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 're'}, {'id': '249', 'type': 'identifier', 'children': [], 'value': 'compile'}; {'id': '250', 'type': 'argument_list', 'children': ['251']}, {'id': '251', 'type': 'binary_operator', 'children': ['252', '253'], 'value': '%'}; {'id': '252', 'type': 'string', 'children': [], 'value': "'%s.*snow_fraction.tif'"}, {'id': '253', 'type': 'identifier', 'children': [], 'value': 'tile'}; {'id': '254', 'type': 'if_statement', 'children': ['255', '257']}, {'id': '255', 'type': 'not_operator', 'children': ['256']}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'modscag_url_fn'}, {'id': '257', 'type': 'block', 'children': ['258', '262', '271', '278']}; {'id': '258', 'type': 'expression_statement', 'children': ['259']}, {'id': '259', 'type': 'assignment', 'children': ['260', '261']}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'modscag_url_str'}, {'id': '261', 'type': 'string', 'children': [], 'value': "'https://snow-data.jpl.nasa.gov/modscag/%Y/%j/'"}; {'id': '262', 'type': 'expression_statement', 'children': ['263']}, {'id': '263', 'type': 'assignment', 'children': ['264', '265']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'modscag_url_base'}, {'id': '265', 'type': 'call', 'children': ['266', '269']}; {'id': '266', 'type': 'attribute', 'children': ['267', '268']}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'strftime'}, {'id': '269', 'type': 'argument_list', 'children': ['270']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'modscag_url_str'}, {'id': '271', 'type': 'expression_statement', 'children': ['272']}; {'id': '272', 'type': 'call', 'children': ['273', '274']}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '274', 'type': 'argument_list', 'children': ['275']}, {'id': '275', 'type': 'binary_operator', 'children': ['276', '277'], 'value': '%'}; {'id': '276', 'type': 'string', 'children': [], 'value': '"Trying: %s"'}, {'id': '277', 'type': 'identifier', 'children': [], 'value': 'modscag_url_base'}; {'id': '278', 'type': 'expression_statement', 'children': ['279']}, {'id': '279', 'type': 'assignment', 'children': ['280', '281']}; {'id': '280', 'type': 'identifier', 'children': [], 'value': 'r'}, {'id': '281', 'type': 'call', 'children': ['282', '285']}; {'id': '282', 'type': 'attribute', 'children': ['283', '284']}, {'id': '283', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '284', 'type': 'identifier', 'children': [], 'value': 'get'}, {'id': '285', 'type': 'argument_list', 'children': ['286', '287']}; {'id': '286', 'type': 'identifier', 'children': [], 'value': 'modscag_url_base'}, {'id': '287', 'type': 'keyword_argument', 'children': ['288', '289']}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'auth'}, {'id': '289', 'type': 'identifier', 'children': [], 'value': 'auth'}; {'id': '290', 'type': 'if_statement', 'children': ['291', '294']}, {'id': '291', 'type': 'attribute', 'children': ['292', '293']}; {'id': '292', 'type': 'identifier', 'children': [], 'value': 'r'}, {'id': '293', 'type': 'identifier', 'children': [], 'value': 'ok'}; {'id': '294', 'type': 'block', 'children': ['295', '305']}, {'id': '295', 'type': 'expression_statement', 'children': ['296']}; {'id': '296', 'type': 'assignment', 'children': ['297', '298']}, {'id': '297', 'type': 'identifier', 'children': [], 'value': 'parsed_html'}; {'id': '298', 'type': 'call', 'children': ['299', '300']}, {'id': '299', 'type': 'identifier', 'children': [], 'value': 'BeautifulSoup'}; {'id': '300', 'type': 'argument_list', 'children': ['301', '304']}, {'id': '301', 'type': 'attribute', 'children': ['302', '303']}; {'id': '302', 'type': 'identifier', 'children': [], 'value': 'r'}, {'id': '303', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '304', 'type': 'string', 'children': [], 'value': '"html.parser"'}, {'id': '305', 'type': 'expression_statement', 'children': ['306']}; {'id': '306', 'type': 'assignment', 'children': ['307', '308']}, {'id': '307', 'type': 'identifier', 'children': [], 'value': 'modscag_url_fn'}; {'id': '308', 'type': 'call', 'children': ['309', '312']}, {'id': '309', 'type': 'attribute', 'children': ['310', '311']}; {'id': '310', 'type': 'identifier', 'children': [], 'value': 'parsed_html'}, {'id': '311', 'type': 'identifier', 'children': [], 'value': 'findAll'}; {'id': '312', 'type': 'argument_list', 'children': ['313']}, {'id': '313', 'type': 'keyword_argument', 'children': ['314', '315']}; {'id': '314', 'type': 'identifier', 'children': [], 'value': 'text'}, {'id': '315', 'type': 'call', 'children': ['316', '319']}; {'id': '316', 'type': 'attribute', 'children': ['317', '318']}, {'id': '317', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '318', 'type': 'identifier', 'children': [], 'value': 'compile'}, {'id': '319', 'type': 'argument_list', 'children': ['320']}; {'id': '320', 'type': 'binary_operator', 'children': ['321', '322'], 'value': '%'}, {'id': '321', 'type': 'string', 'children': [], 'value': "'%s.*snow_fraction.tif'"}; {'id': '322', 'type': 'identifier', 'children': [], 'value': 'tile'}, {'id': '323', 'type': 'if_statement', 'children': ['324', '326', '334']}; {'id': '324', 'type': 'not_operator', 'children': ['325']}, {'id': '325', 'type': 'identifier', 'children': [], 'value': 'modscag_url_fn'}; {'id': '326', 'type': 'block', 'children': ['327']}, {'id': '327', 'type': 'expression_statement', 'children': ['328']}; {'id': '328', 'type': 'call', 'children': ['329', '330']}, {'id': '329', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '330', 'type': 'argument_list', 'children': ['331']}, {'id': '331', 'type': 'binary_operator', 'children': ['332', '333'], 'value': '%'}; {'id': '332', 'type': 'string', 'children': [], 'value': '"Unable to fetch MODSCAG for %s"'}, {'id': '333', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '334', 'type': 'else_clause', 'children': ['335']}, {'id': '335', 'type': 'block', 'children': ['336', '346', '364']}; {'id': '336', 'type': 'expression_statement', 'children': ['337']}, {'id': '337', 'type': 'assignment', 'children': ['338', '339']}; {'id': '338', 'type': 'identifier', 'children': [], 'value': 'parsed_html'}, {'id': '339', 'type': 'call', 'children': ['340', '341']}; {'id': '340', 'type': 'identifier', 'children': [], 'value': 'BeautifulSoup'}, {'id': '341', 'type': 'argument_list', 'children': ['342', '345']}; {'id': '342', 'type': 'attribute', 'children': ['343', '344']}, {'id': '343', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '344', 'type': 'identifier', 'children': [], 'value': 'content'}, {'id': '345', 'type': 'string', 'children': [], 'value': '"html.parser"'}; {'id': '346', 'type': 'expression_statement', 'children': ['347']}, {'id': '347', 'type': 'assignment', 'children': ['348', '349']}; {'id': '348', 'type': 'identifier', 'children': [], 'value': 'modscag_url_fn'}, {'id': '349', 'type': 'call', 'children': ['350', '353']}; {'id': '350', 'type': 'attribute', 'children': ['351', '352']}, {'id': '351', 'type': 'identifier', 'children': [], 'value': 'parsed_html'}; {'id': '352', 'type': 'identifier', 'children': [], 'value': 'findAll'}, {'id': '353', 'type': 'argument_list', 'children': ['354']}; {'id': '354', 'type': 'keyword_argument', 'children': ['355', '356']}, {'id': '355', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '356', 'type': 'call', 'children': ['357', '360']}, {'id': '357', 'type': 'attribute', 'children': ['358', '359']}; {'id': '358', 'type': 'identifier', 'children': [], 'value': 're'}, {'id': '359', 'type': 'identifier', 'children': [], 'value': 'compile'}; {'id': '360', 'type': 'argument_list', 'children': ['361']}, {'id': '361', 'type': 'binary_operator', 'children': ['362', '363'], 'value': '%'}; {'id': '362', 'type': 'string', 'children': [], 'value': "'%s.*snow_fraction.tif'"}, {'id': '363', 'type': 'identifier', 'children': [], 'value': 'tile'}; {'id': '364', 'type': 'if_statement', 'children': ['365', '366']}, {'id': '365', 'type': 'identifier', 'children': [], 'value': 'modscag_url_fn'}; {'id': '366', 'type': 'block', 'children': ['367', '373', '385', '390', '412', '436']}, {'id': '367', 'type': 'expression_statement', 'children': ['368']}; {'id': '368', 'type': 'assignment', 'children': ['369', '370']}, {'id': '369', 'type': 'identifier', 'children': [], 'value': 'modscag_url_fn'}; {'id': '370', 'type': 'subscript', 'children': ['371', '372']}, {'id': '371', 'type': 'identifier', 'children': [], 'value': 'modscag_url_fn'}; {'id': '372', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '373', 'type': 'expression_statement', 'children': ['374']}; {'id': '374', 'type': 'assignment', 'children': ['375', '376']}, {'id': '375', 'type': 'identifier', 'children': [], 'value': 'modscag_url'}; {'id': '376', 'type': 'call', 'children': ['377', '382']}, {'id': '377', 'type': 'attribute', 'children': ['378', '381']}; {'id': '378', 'type': 'attribute', 'children': ['379', '380']}, {'id': '379', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '380', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '381', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '382', 'type': 'argument_list', 'children': ['383', '384']}, {'id': '383', 'type': 'identifier', 'children': [], 'value': 'modscag_url_base'}; {'id': '384', 'type': 'identifier', 'children': [], 'value': 'modscag_url_fn'}, {'id': '385', 'type': 'expression_statement', 'children': ['386']}; {'id': '386', 'type': 'call', 'children': ['387', '388']}, {'id': '387', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '388', 'type': 'argument_list', 'children': ['389']}, {'id': '389', 'type': 'identifier', 'children': [], 'value': 'modscag_url'}; {'id': '390', 'type': 'expression_statement', 'children': ['391']}, {'id': '391', 'type': 'assignment', 'children': ['392', '393']}; {'id': '392', 'type': 'identifier', 'children': [], 'value': 'modscag_fn'}, {'id': '393', 'type': 'call', 'children': ['394', '399']}; {'id': '394', 'type': 'attribute', 'children': ['395', '398']}, {'id': '395', 'type': 'attribute', 'children': ['396', '397']}; {'id': '396', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '397', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '398', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '399', 'type': 'argument_list', 'children': ['400', '401']}; {'id': '400', 'type': 'identifier', 'children': [], 'value': 'outdir'}, {'id': '401', 'type': 'subscript', 'children': ['402', '410']}; {'id': '402', 'type': 'call', 'children': ['403', '408']}, {'id': '403', 'type': 'attribute', 'children': ['404', '407']}; {'id': '404', 'type': 'attribute', 'children': ['405', '406']}, {'id': '405', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '406', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '407', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '408', 'type': 'argument_list', 'children': ['409']}, {'id': '409', 'type': 'identifier', 'children': [], 'value': 'modscag_url_fn'}; {'id': '410', 'type': 'unary_operator', 'children': ['411'], 'value': '-'}, {'id': '411', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '412', 'type': 'if_statement', 'children': ['413', '422']}, {'id': '413', 'type': 'not_operator', 'children': ['414']}; {'id': '414', 'type': 'call', 'children': ['415', '420']}, {'id': '415', 'type': 'attribute', 'children': ['416', '419']}; {'id': '416', 'type': 'attribute', 'children': ['417', '418']}, {'id': '417', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '418', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '419', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '420', 'type': 'argument_list', 'children': ['421']}, {'id': '421', 'type': 'identifier', 'children': [], 'value': 'modscag_fn'}; {'id': '422', 'type': 'block', 'children': ['423']}, {'id': '423', 'type': 'expression_statement', 'children': ['424']}; {'id': '424', 'type': 'call', 'children': ['425', '428']}, {'id': '425', 'type': 'attribute', 'children': ['426', '427']}; {'id': '426', 'type': 'identifier', 'children': [], 'value': 'iolib'}, {'id': '427', 'type': 'identifier', 'children': [], 'value': 'getfile2'}; {'id': '428', 'type': 'argument_list', 'children': ['429', '430', '433']}, {'id': '429', 'type': 'identifier', 'children': [], 'value': 'modscag_url'}; {'id': '430', 'type': 'keyword_argument', 'children': ['431', '432']}, {'id': '431', 'type': 'identifier', 'children': [], 'value': 'auth'}; {'id': '432', 'type': 'identifier', 'children': [], 'value': 'auth'}, {'id': '433', 'type': 'keyword_argument', 'children': ['434', '435']}; {'id': '434', 'type': 'identifier', 'children': [], 'value': 'outdir'}, {'id': '435', 'type': 'identifier', 'children': [], 'value': 'outdir'}; {'id': '436', 'type': 'expression_statement', 'children': ['437']}, {'id': '437', 'type': 'call', 'children': ['438', '441']}; {'id': '438', 'type': 'attribute', 'children': ['439', '440']}, {'id': '439', 'type': 'identifier', 'children': [], 'value': 'modscag_fn_list'}; {'id': '440', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '441', 'type': 'argument_list', 'children': ['442']}; {'id': '442', 'type': 'identifier', 'children': [], 'value': 'modscag_fn'}, {'id': '443', 'type': 'if_statement', 'children': ['444', '445']}; {'id': '444', 'type': 'identifier', 'children': [], 'value': 'modscag_fn_list'}, {'id': '445', 'type': 'block', 'children': ['446', '454', '461', '466', '476']}; {'id': '446', 'type': 'expression_statement', 'children': ['447']}, {'id': '447', 'type': 'assignment', 'children': ['448', '449']}; {'id': '448', 'type': 'identifier', 'children': [], 'value': 'cmd'}, {'id': '449', 'type': 'list', 'children': ['450', '451', '452', '453'], 'value': "['gdalbuildvrt', '-vrtnodata', '255', out_vrt_fn]"}; {'id': '450', 'type': 'string', 'children': [], 'value': "'gdalbuildvrt'"}, {'id': '451', 'type': 'string', 'children': [], 'value': "'-vrtnodata'"}; {'id': '452', 'type': 'string', 'children': [], 'value': "'255'"}, {'id': '453', 'type': 'identifier', 'children': [], 'value': 'out_vrt_fn'}; {'id': '454', 'type': 'expression_statement', 'children': ['455']}, {'id': '455', 'type': 'call', 'children': ['456', '459']}; {'id': '456', 'type': 'attribute', 'children': ['457', '458']}, {'id': '457', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '458', 'type': 'identifier', 'children': [], 'value': 'extend'}, {'id': '459', 'type': 'argument_list', 'children': ['460']}; {'id': '460', 'type': 'identifier', 'children': [], 'value': 'modscag_fn_list'}, {'id': '461', 'type': 'expression_statement', 'children': ['462']}; {'id': '462', 'type': 'call', 'children': ['463', '464']}, {'id': '463', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '464', 'type': 'argument_list', 'children': ['465']}, {'id': '465', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '466', 'type': 'expression_statement', 'children': ['467']}, {'id': '467', 'type': 'call', 'children': ['468', '471']}; {'id': '468', 'type': 'attribute', 'children': ['469', '470']}, {'id': '469', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '470', 'type': 'identifier', 'children': [], 'value': 'call'}, {'id': '471', 'type': 'argument_list', 'children': ['472', '473']}; {'id': '472', 'type': 'identifier', 'children': [], 'value': 'cmd'}, {'id': '473', 'type': 'keyword_argument', 'children': ['474', '475']}; {'id': '474', 'type': 'identifier', 'children': [], 'value': 'shell'}, {'id': '475', 'type': 'False', 'children': []}; {'id': '476', 'type': 'expression_statement', 'children': ['477']}, {'id': '477', 'type': 'call', 'children': ['478', '481']}; {'id': '478', 'type': 'attribute', 'children': ['479', '480']}, {'id': '479', 'type': 'identifier', 'children': [], 'value': 'out_vrt_fn_list'}; {'id': '480', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '481', 'type': 'argument_list', 'children': ['482']}; {'id': '482', 'type': 'identifier', 'children': [], 'value': 'out_vrt_fn'}, {'id': '483', 'type': 'return_statement', 'children': ['484']}
def get_modscag_fn_list(dem_dt, tile_list=('h08v04', 'h09v04', 'h10v04', 'h08v05', 'h09v05'), pad_days=7): import re import requests from bs4 import BeautifulSoup auth = iolib.get_auth() pad_days = timedelta(days=pad_days) dt_list = timelib.dt_range(dem_dt-pad_days, dem_dt+pad_days+timedelta(1), timedelta(1)) outdir = os.path.join(datadir, 'modscag') if not os.path.exists(outdir): os.makedirs(outdir) out_vrt_fn_list = [] for dt in dt_list: out_vrt_fn = os.path.join(outdir, dt.strftime('%Y%m%d_snow_fraction.vrt')) if os.path.exists(out_vrt_fn): vrt_ds = gdal.Open(out_vrt_fn) if np.all([np.any([tile in sub_fn for sub_fn in vrt_ds.GetFileList()]) for tile in tile_list]): out_vrt_fn_list.append(out_vrt_fn) continue modscag_fn_list = [] for tile in tile_list: modscag_url_str = 'https://snow-data.jpl.nasa.gov/modscag-historic/%Y/%j/' modscag_url_base = dt.strftime(modscag_url_str) print("Trying: %s" % modscag_url_base) r = requests.get(modscag_url_base, auth=auth) modscag_url_fn = [] if r.ok: parsed_html = BeautifulSoup(r.content, "html.parser") modscag_url_fn = parsed_html.findAll(text=re.compile('%s.*snow_fraction.tif' % tile)) if not modscag_url_fn: modscag_url_str = 'https://snow-data.jpl.nasa.gov/modscag/%Y/%j/' modscag_url_base = dt.strftime(modscag_url_str) print("Trying: %s" % modscag_url_base) r = requests.get(modscag_url_base, auth=auth) if r.ok: parsed_html = BeautifulSoup(r.content, "html.parser") modscag_url_fn = parsed_html.findAll(text=re.compile('%s.*snow_fraction.tif' % tile)) if not modscag_url_fn: print("Unable to fetch MODSCAG for %s" % dt) else: parsed_html = BeautifulSoup(r.content, "html.parser") modscag_url_fn = parsed_html.findAll(text=re.compile('%s.*snow_fraction.tif' % tile)) if modscag_url_fn: modscag_url_fn = modscag_url_fn[0] modscag_url = os.path.join(modscag_url_base, modscag_url_fn) print(modscag_url) modscag_fn = os.path.join(outdir, os.path.split(modscag_url_fn)[-1]) if not os.path.exists(modscag_fn): iolib.getfile2(modscag_url, auth=auth, outdir=outdir) modscag_fn_list.append(modscag_fn) if modscag_fn_list: cmd = ['gdalbuildvrt', '-vrtnodata', '255', out_vrt_fn] cmd.extend(modscag_fn_list) print(cmd) subprocess.call(cmd, shell=False) out_vrt_fn_list.append(out_vrt_fn) return out_vrt_fn_list
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_decode_record'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '9', 'type': 'block', 'children': ['10', '12', '21', '26', '93', '99', '114', '126', '132', '147', '154', '158', '170']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}, {'id': '11', 'type': 'string', 'children': [], 'value': "'''Decode one record of HEX file.\n @param s line with HEX record.\n @param line line number (for error messages).\n @raise EndOfFile if EOF record encountered.\n '''"}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}, {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'rstrip'}, {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'\\r\\n'"}, {'id': '21', 'type': 'if_statement', 'children': ['22', '24']}; {'id': '22', 'type': 'not_operator', 'children': ['23']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '24', 'type': 'block', 'children': ['25']}, {'id': '25', 'type': 'return_statement', 'children': []}; {'id': '26', 'type': 'if_statement', 'children': ['27', '32', '84']}, {'id': '27', 'type': 'comparison_operator', 'children': ['28', '31'], 'value': '=='}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '31', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '32', 'type': 'block', 'children': ['33', '65', '72']}, {'id': '33', 'type': 'try_statement', 'children': ['34', '53']}; {'id': '34', 'type': 'block', 'children': ['35']}, {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'bin'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}, {'id': '41', 'type': 'string', 'children': [], 'value': "'B'"}; {'id': '42', 'type': 'call', 'children': ['43', '44']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'unhexlify'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}, {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'asbytes'}, {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '50', 'type': 'slice', 'children': ['51', '52']}, {'id': '51', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '52', 'type': 'colon', 'children': []}, {'id': '53', 'type': 'except_clause', 'children': ['54', '57']}; {'id': '54', 'type': 'tuple', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'raise_statement', 'children': ['59']}, {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'HexRecordError'}, {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'bin'}; {'id': '72', 'type': 'if_statement', 'children': ['73', '76']}, {'id': '73', 'type': 'comparison_operator', 'children': ['74', '75'], 'value': '<'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'length'}, {'id': '75', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '76', 'type': 'block', 'children': ['77']}, {'id': '77', 'type': 'raise_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '80']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'HexRecordError'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}, {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '84', 'type': 'else_clause', 'children': ['85']}, {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'raise_statement', 'children': ['87']}, {'id': '87', 'type': 'call', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'HexRecordError'}, {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'record_length'}; {'id': '96', 'type': 'subscript', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'bin'}; {'id': '98', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '99', 'type': 'if_statement', 'children': ['100', '106']}; {'id': '100', 'type': 'comparison_operator', 'children': ['101', '102'], 'value': '!='}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '102', 'type': 'parenthesized_expression', 'children': ['103']}, {'id': '103', 'type': 'binary_operator', 'children': ['104', '105'], 'value': '+'}; {'id': '104', 'type': 'integer', 'children': [], 'value': '5'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'record_length'}; {'id': '106', 'type': 'block', 'children': ['107']}, {'id': '107', 'type': 'raise_statement', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'RecordLengthError'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}, {'id': '111', 'type': 'keyword_argument', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}, {'id': '115', 'type': 'assignment', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'addr'}, {'id': '117', 'type': 'binary_operator', 'children': ['118', '123'], 'value': '+'}; {'id': '118', 'type': 'binary_operator', 'children': ['119', '122'], 'value': '*'}, {'id': '119', 'type': 'subscript', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'bin'}, {'id': '121', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '122', 'type': 'integer', 'children': [], 'value': '256'}, {'id': '123', 'type': 'subscript', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'bin'}, {'id': '125', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}, {'id': '127', 'type': 'assignment', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'record_type'}, {'id': '129', 'type': 'subscript', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'bin'}, {'id': '131', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '132', 'type': 'if_statement', 'children': ['133', '139']}, {'id': '133', 'type': 'not_operator', 'children': ['134']}; {'id': '134', 'type': 'parenthesized_expression', 'children': ['135']}, {'id': '135', 'type': 'comparison_operator', 'children': ['136', '137', '138'], 'value': '<='}; {'id': '136', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'record_type'}; {'id': '138', 'type': 'integer', 'children': [], 'value': '5'}, {'id': '139', 'type': 'block', 'children': ['140']}; {'id': '140', 'type': 'raise_statement', 'children': ['141']}, {'id': '141', 'type': 'call', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'RecordTypeError'}, {'id': '143', 'type': 'argument_list', 'children': ['144']}; {'id': '144', 'type': 'keyword_argument', 'children': ['145', '146']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'assignment', 'children': ['149', '150']}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'crc'}; {'id': '150', 'type': 'call', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '152', 'type': 'argument_list', 'children': ['153']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'bin'}; {'id': '154', 'type': 'expression_statement', 'children': ['155']}, {'id': '155', 'type': 'augmented_assignment', 'children': ['156', '157'], 'value': '&='}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'crc'}, {'id': '157', 'type': 'integer', 'children': [], 'value': '0x0FF'}; {'id': '158', 'type': 'if_statement', 'children': ['159', '162']}, {'id': '159', 'type': 'comparison_operator', 'children': ['160', '161'], 'value': '!='}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'crc'}, {'id': '161', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '162', 'type': 'block', 'children': ['163']}, {'id': '163', 'type': 'raise_statement', 'children': ['164']}; {'id': '164', 'type': 'call', 'children': ['165', '166']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'RecordChecksumError'}; {'id': '166', 'type': 'argument_list', 'children': ['167']}, {'id': '167', 'type': 'keyword_argument', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '170', 'type': 'if_statement', 'children': ['171', '174', '229', '248', '286', '324', '385']}, {'id': '171', 'type': 'comparison_operator', 'children': ['172', '173'], 'value': '=='}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'record_type'}, {'id': '173', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '174', 'type': 'block', 'children': ['175', '181']}, {'id': '175', 'type': 'expression_statement', 'children': ['176']}; {'id': '176', 'type': 'augmented_assignment', 'children': ['177', '178'], 'value': '+='}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '178', 'type': 'attribute', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '180', 'type': 'identifier', 'children': [], 'value': '_offset'}, {'id': '181', 'type': 'for_statement', 'children': ['182', '183', '190']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '183', 'type': 'call', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'range_g'}, {'id': '185', 'type': 'argument_list', 'children': ['186', '187']}; {'id': '186', 'type': 'integer', 'children': [], 'value': '4'}, {'id': '187', 'type': 'binary_operator', 'children': ['188', '189'], 'value': '+'}; {'id': '188', 'type': 'integer', 'children': [], 'value': '4'}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'record_length'}; {'id': '190', 'type': 'block', 'children': ['191', '215', '225']}, {'id': '191', 'type': 'if_statement', 'children': ['192', '204']}; {'id': '192', 'type': 'not_operator', 'children': ['193']}, {'id': '193', 'type': 'comparison_operator', 'children': ['194', '203'], 'value': 'is'}; {'id': '194', 'type': 'call', 'children': ['195', '200']}, {'id': '195', 'type': 'attribute', 'children': ['196', '199']}; {'id': '196', 'type': 'attribute', 'children': ['197', '198']}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '198', 'type': 'identifier', 'children': [], 'value': '_buf'}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '200', 'type': 'argument_list', 'children': ['201', '202']}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '202', 'type': 'None', 'children': []}, {'id': '203', 'type': 'None', 'children': []}; {'id': '204', 'type': 'block', 'children': ['205']}, {'id': '205', 'type': 'raise_statement', 'children': ['206']}; {'id': '206', 'type': 'call', 'children': ['207', '208']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'AddressOverlapError'}; {'id': '208', 'type': 'argument_list', 'children': ['209', '212']}, {'id': '209', 'type': 'keyword_argument', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'address'}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '212', 'type': 'keyword_argument', 'children': ['213', '214']}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '215', 'type': 'expression_statement', 'children': ['216']}; {'id': '216', 'type': 'assignment', 'children': ['217', '222']}, {'id': '217', 'type': 'subscript', 'children': ['218', '221']}; {'id': '218', 'type': 'attribute', 'children': ['219', '220']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '220', 'type': 'identifier', 'children': [], 'value': '_buf'}, {'id': '221', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '222', 'type': 'subscript', 'children': ['223', '224']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'bin'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '225', 'type': 'expression_statement', 'children': ['226']}; {'id': '226', 'type': 'augmented_assignment', 'children': ['227', '228'], 'value': '+='}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '228', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '229', 'type': 'elif_clause', 'children': ['230', '233']}; {'id': '230', 'type': 'comparison_operator', 'children': ['231', '232'], 'value': '=='}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'record_type'}; {'id': '232', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '233', 'type': 'block', 'children': ['234', '246']}; {'id': '234', 'type': 'if_statement', 'children': ['235', '238']}, {'id': '235', 'type': 'comparison_operator', 'children': ['236', '237'], 'value': '!='}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'record_length'}, {'id': '237', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '238', 'type': 'block', 'children': ['239']}, {'id': '239', 'type': 'raise_statement', 'children': ['240']}; {'id': '240', 'type': 'call', 'children': ['241', '242']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'EOFRecordError'}; {'id': '242', 'type': 'argument_list', 'children': ['243']}, {'id': '243', 'type': 'keyword_argument', 'children': ['244', '245']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '246', 'type': 'raise_statement', 'children': ['247']}, {'id': '247', 'type': 'identifier', 'children': [], 'value': '_EndOfFile'}; {'id': '248', 'type': 'elif_clause', 'children': ['249', '252']}, {'id': '249', 'type': 'comparison_operator', 'children': ['250', '251'], 'value': '=='}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'record_type'}, {'id': '251', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '252', 'type': 'block', 'children': ['253', '269']}, {'id': '253', 'type': 'if_statement', 'children': ['254', '261']}; {'id': '254', 'type': 'boolean_operator', 'children': ['255', '258'], 'value': 'or'}, {'id': '255', 'type': 'comparison_operator', 'children': ['256', '257'], 'value': '!='}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'record_length'}, {'id': '257', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '258', 'type': 'comparison_operator', 'children': ['259', '260'], 'value': '!='}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '260', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '261', 'type': 'block', 'children': ['262']}; {'id': '262', 'type': 'raise_statement', 'children': ['263']}, {'id': '263', 'type': 'call', 'children': ['264', '265']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'ExtendedSegmentAddressRecordError'}, {'id': '265', 'type': 'argument_list', 'children': ['266']}; {'id': '266', 'type': 'keyword_argument', 'children': ['267', '268']}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '269', 'type': 'expression_statement', 'children': ['270']}; {'id': '270', 'type': 'assignment', 'children': ['271', '274']}, {'id': '271', 'type': 'attribute', 'children': ['272', '273']}; {'id': '272', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '273', 'type': 'identifier', 'children': [], 'value': '_offset'}; {'id': '274', 'type': 'binary_operator', 'children': ['275', '285'], 'value': '*'}, {'id': '275', 'type': 'parenthesized_expression', 'children': ['276']}; {'id': '276', 'type': 'binary_operator', 'children': ['277', '282'], 'value': '+'}, {'id': '277', 'type': 'binary_operator', 'children': ['278', '281'], 'value': '*'}; {'id': '278', 'type': 'subscript', 'children': ['279', '280']}, {'id': '279', 'type': 'identifier', 'children': [], 'value': 'bin'}; {'id': '280', 'type': 'integer', 'children': [], 'value': '4'}, {'id': '281', 'type': 'integer', 'children': [], 'value': '256'}; {'id': '282', 'type': 'subscript', 'children': ['283', '284']}, {'id': '283', 'type': 'identifier', 'children': [], 'value': 'bin'}; {'id': '284', 'type': 'integer', 'children': [], 'value': '5'}, {'id': '285', 'type': 'integer', 'children': [], 'value': '16'}; {'id': '286', 'type': 'elif_clause', 'children': ['287', '290']}, {'id': '287', 'type': 'comparison_operator', 'children': ['288', '289'], 'value': '=='}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'record_type'}, {'id': '289', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '290', 'type': 'block', 'children': ['291', '307']}, {'id': '291', 'type': 'if_statement', 'children': ['292', '299']}; {'id': '292', 'type': 'boolean_operator', 'children': ['293', '296'], 'value': 'or'}, {'id': '293', 'type': 'comparison_operator', 'children': ['294', '295'], 'value': '!='}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'record_length'}, {'id': '295', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '296', 'type': 'comparison_operator', 'children': ['297', '298'], 'value': '!='}, {'id': '297', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '298', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '299', 'type': 'block', 'children': ['300']}; {'id': '300', 'type': 'raise_statement', 'children': ['301']}, {'id': '301', 'type': 'call', 'children': ['302', '303']}; {'id': '302', 'type': 'identifier', 'children': [], 'value': 'ExtendedLinearAddressRecordError'}, {'id': '303', 'type': 'argument_list', 'children': ['304']}; {'id': '304', 'type': 'keyword_argument', 'children': ['305', '306']}, {'id': '305', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '306', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '307', 'type': 'expression_statement', 'children': ['308']}; {'id': '308', 'type': 'assignment', 'children': ['309', '312']}, {'id': '309', 'type': 'attribute', 'children': ['310', '311']}; {'id': '310', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '311', 'type': 'identifier', 'children': [], 'value': '_offset'}; {'id': '312', 'type': 'binary_operator', 'children': ['313', '323'], 'value': '*'}, {'id': '313', 'type': 'parenthesized_expression', 'children': ['314']}; {'id': '314', 'type': 'binary_operator', 'children': ['315', '320'], 'value': '+'}, {'id': '315', 'type': 'binary_operator', 'children': ['316', '319'], 'value': '*'}; {'id': '316', 'type': 'subscript', 'children': ['317', '318']}, {'id': '317', 'type': 'identifier', 'children': [], 'value': 'bin'}; {'id': '318', 'type': 'integer', 'children': [], 'value': '4'}, {'id': '319', 'type': 'integer', 'children': [], 'value': '256'}; {'id': '320', 'type': 'subscript', 'children': ['321', '322']}, {'id': '321', 'type': 'identifier', 'children': [], 'value': 'bin'}; {'id': '322', 'type': 'integer', 'children': [], 'value': '5'}, {'id': '323', 'type': 'integer', 'children': [], 'value': '65536'}; {'id': '324', 'type': 'elif_clause', 'children': ['325', '328']}, {'id': '325', 'type': 'comparison_operator', 'children': ['326', '327'], 'value': '=='}; {'id': '326', 'type': 'identifier', 'children': [], 'value': 'record_type'}, {'id': '327', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '328', 'type': 'block', 'children': ['329', '345', '357']}, {'id': '329', 'type': 'if_statement', 'children': ['330', '337']}; {'id': '330', 'type': 'boolean_operator', 'children': ['331', '334'], 'value': 'or'}, {'id': '331', 'type': 'comparison_operator', 'children': ['332', '333'], 'value': '!='}; {'id': '332', 'type': 'identifier', 'children': [], 'value': 'record_length'}, {'id': '333', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '334', 'type': 'comparison_operator', 'children': ['335', '336'], 'value': '!='}, {'id': '335', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '336', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '337', 'type': 'block', 'children': ['338']}; {'id': '338', 'type': 'raise_statement', 'children': ['339']}, {'id': '339', 'type': 'call', 'children': ['340', '341']}; {'id': '340', 'type': 'identifier', 'children': [], 'value': 'StartSegmentAddressRecordError'}, {'id': '341', 'type': 'argument_list', 'children': ['342']}; {'id': '342', 'type': 'keyword_argument', 'children': ['343', '344']}, {'id': '343', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '344', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '345', 'type': 'if_statement', 'children': ['346', '349']}; {'id': '346', 'type': 'attribute', 'children': ['347', '348']}, {'id': '347', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '348', 'type': 'identifier', 'children': [], 'value': 'start_addr'}, {'id': '349', 'type': 'block', 'children': ['350']}; {'id': '350', 'type': 'raise_statement', 'children': ['351']}, {'id': '351', 'type': 'call', 'children': ['352', '353']}; {'id': '352', 'type': 'identifier', 'children': [], 'value': 'DuplicateStartAddressRecordError'}, {'id': '353', 'type': 'argument_list', 'children': ['354']}; {'id': '354', 'type': 'keyword_argument', 'children': ['355', '356']}, {'id': '355', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '356', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '357', 'type': 'expression_statement', 'children': ['358']}; {'id': '358', 'type': 'assignment', 'children': ['359', '362']}, {'id': '359', 'type': 'attribute', 'children': ['360', '361']}; {'id': '360', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '361', 'type': 'identifier', 'children': [], 'value': 'start_addr'}; {'id': '362', 'type': 'dictionary', 'children': ['363', '374']}, {'id': '363', 'type': 'pair', 'children': ['364', '365']}; {'id': '364', 'type': 'string', 'children': [], 'value': "'CS'"}, {'id': '365', 'type': 'binary_operator', 'children': ['366', '371'], 'value': '+'}; {'id': '366', 'type': 'binary_operator', 'children': ['367', '370'], 'value': '*'}, {'id': '367', 'type': 'subscript', 'children': ['368', '369']}; {'id': '368', 'type': 'identifier', 'children': [], 'value': 'bin'}, {'id': '369', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '370', 'type': 'integer', 'children': [], 'value': '256'}, {'id': '371', 'type': 'subscript', 'children': ['372', '373']}; {'id': '372', 'type': 'identifier', 'children': [], 'value': 'bin'}, {'id': '373', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '374', 'type': 'pair', 'children': ['375', '376']}, {'id': '375', 'type': 'string', 'children': [], 'value': "'IP'"}; {'id': '376', 'type': 'binary_operator', 'children': ['377', '382'], 'value': '+'}, {'id': '377', 'type': 'binary_operator', 'children': ['378', '381'], 'value': '*'}; {'id': '378', 'type': 'subscript', 'children': ['379', '380']}, {'id': '379', 'type': 'identifier', 'children': [], 'value': 'bin'}; {'id': '380', 'type': 'integer', 'children': [], 'value': '6'}, {'id': '381', 'type': 'integer', 'children': [], 'value': '256'}; {'id': '382', 'type': 'subscript', 'children': ['383', '384']}, {'id': '383', 'type': 'identifier', 'children': [], 'value': 'bin'}; {'id': '384', 'type': 'integer', 'children': [], 'value': '7'}, {'id': '385', 'type': 'elif_clause', 'children': ['386', '389']}; {'id': '386', 'type': 'comparison_operator', 'children': ['387', '388'], 'value': '=='}, {'id': '387', 'type': 'identifier', 'children': [], 'value': 'record_type'}; {'id': '388', 'type': 'integer', 'children': [], 'value': '5'}, {'id': '389', 'type': 'block', 'children': ['390', '406', '418']}; {'id': '390', 'type': 'if_statement', 'children': ['391', '398']}, {'id': '391', 'type': 'boolean_operator', 'children': ['392', '395'], 'value': 'or'}; {'id': '392', 'type': 'comparison_operator', 'children': ['393', '394'], 'value': '!='}, {'id': '393', 'type': 'identifier', 'children': [], 'value': 'record_length'}; {'id': '394', 'type': 'integer', 'children': [], 'value': '4'}, {'id': '395', 'type': 'comparison_operator', 'children': ['396', '397'], 'value': '!='}; {'id': '396', 'type': 'identifier', 'children': [], 'value': 'addr'}, {'id': '397', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '398', 'type': 'block', 'children': ['399']}, {'id': '399', 'type': 'raise_statement', 'children': ['400']}; {'id': '400', 'type': 'call', 'children': ['401', '402']}, {'id': '401', 'type': 'identifier', 'children': [], 'value': 'StartLinearAddressRecordError'}; {'id': '402', 'type': 'argument_list', 'children': ['403']}, {'id': '403', 'type': 'keyword_argument', 'children': ['404', '405']}; {'id': '404', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '405', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '406', 'type': 'if_statement', 'children': ['407', '410']}, {'id': '407', 'type': 'attribute', 'children': ['408', '409']}; {'id': '408', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '409', 'type': 'identifier', 'children': [], 'value': 'start_addr'}; {'id': '410', 'type': 'block', 'children': ['411']}, {'id': '411', 'type': 'raise_statement', 'children': ['412']}; {'id': '412', 'type': 'call', 'children': ['413', '414']}, {'id': '413', 'type': 'identifier', 'children': [], 'value': 'DuplicateStartAddressRecordError'}; {'id': '414', 'type': 'argument_list', 'children': ['415']}, {'id': '415', 'type': 'keyword_argument', 'children': ['416', '417']}; {'id': '416', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '417', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '418', 'type': 'expression_statement', 'children': ['419']}, {'id': '419', 'type': 'assignment', 'children': ['420', '423']}; {'id': '420', 'type': 'attribute', 'children': ['421', '422']}, {'id': '421', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '422', 'type': 'identifier', 'children': [], 'value': 'start_addr'}, {'id': '423', 'type': 'dictionary', 'children': ['424']}; {'id': '424', 'type': 'pair', 'children': ['425', '426']}, {'id': '425', 'type': 'string', 'children': [], 'value': "'EIP'"}; {'id': '426', 'type': 'parenthesized_expression', 'children': ['427']}, {'id': '427', 'type': 'binary_operator', 'children': ['428', '445'], 'value': '+'}; {'id': '428', 'type': 'binary_operator', 'children': ['429', '440'], 'value': '+'}, {'id': '429', 'type': 'binary_operator', 'children': ['430', '435'], 'value': '+'}; {'id': '430', 'type': 'binary_operator', 'children': ['431', '434'], 'value': '*'}, {'id': '431', 'type': 'subscript', 'children': ['432', '433']}; {'id': '432', 'type': 'identifier', 'children': [], 'value': 'bin'}, {'id': '433', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '434', 'type': 'integer', 'children': [], 'value': '16777216'}, {'id': '435', 'type': 'binary_operator', 'children': ['436', '439'], 'value': '*'}; {'id': '436', 'type': 'subscript', 'children': ['437', '438']}, {'id': '437', 'type': 'identifier', 'children': [], 'value': 'bin'}; {'id': '438', 'type': 'integer', 'children': [], 'value': '5'}, {'id': '439', 'type': 'integer', 'children': [], 'value': '65536'}; {'id': '440', 'type': 'binary_operator', 'children': ['441', '444'], 'value': '*'}, {'id': '441', 'type': 'subscript', 'children': ['442', '443']}; {'id': '442', 'type': 'identifier', 'children': [], 'value': 'bin'}, {'id': '443', 'type': 'integer', 'children': [], 'value': '6'}; {'id': '444', 'type': 'integer', 'children': [], 'value': '256'}, {'id': '445', 'type': 'subscript', 'children': ['446', '447']}; {'id': '446', 'type': 'identifier', 'children': [], 'value': 'bin'}, {'id': '447', 'type': 'integer', 'children': [], 'value': '7'}
def _decode_record(self, s, line=0): '''Decode one record of HEX file. @param s line with HEX record. @param line line number (for error messages). @raise EndOfFile if EOF record encountered. ''' s = s.rstrip('\r\n') if not s: return if s[0] == ':': try: bin = array('B', unhexlify(asbytes(s[1:]))) except (TypeError, ValueError): raise HexRecordError(line=line) length = len(bin) if length < 5: raise HexRecordError(line=line) else: raise HexRecordError(line=line) record_length = bin[0] if length != (5 + record_length): raise RecordLengthError(line=line) addr = bin[1]*256 + bin[2] record_type = bin[3] if not (0 <= record_type <= 5): raise RecordTypeError(line=line) crc = sum(bin) crc &= 0x0FF if crc != 0: raise RecordChecksumError(line=line) if record_type == 0: addr += self._offset for i in range_g(4, 4+record_length): if not self._buf.get(addr, None) is None: raise AddressOverlapError(address=addr, line=line) self._buf[addr] = bin[i] addr += 1 elif record_type == 1: if record_length != 0: raise EOFRecordError(line=line) raise _EndOfFile elif record_type == 2: if record_length != 2 or addr != 0: raise ExtendedSegmentAddressRecordError(line=line) self._offset = (bin[4]*256 + bin[5]) * 16 elif record_type == 4: if record_length != 2 or addr != 0: raise ExtendedLinearAddressRecordError(line=line) self._offset = (bin[4]*256 + bin[5]) * 65536 elif record_type == 3: if record_length != 4 or addr != 0: raise StartSegmentAddressRecordError(line=line) if self.start_addr: raise DuplicateStartAddressRecordError(line=line) self.start_addr = {'CS': bin[4]*256 + bin[5], 'IP': bin[6]*256 + bin[7], } elif record_type == 5: if record_length != 4 or addr != 0: raise StartLinearAddressRecordError(line=line) if self.start_addr: raise DuplicateStartAddressRecordError(line=line) self.start_addr = {'EIP': (bin[4]*16777216 + bin[5]*65536 + bin[6]*256 + bin[7]), }
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_start_end'}, {'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': 'start'}, {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '10', 'type': 'None', 'children': []}, {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'size'}, {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '32', '148']}, {'id': '15', 'type': 'if_statement', 'children': ['16', '29']}; {'id': '16', 'type': 'boolean_operator', 'children': ['17', '24'], 'value': 'and'}, {'id': '17', 'type': 'comparison_operator', 'children': ['18', '21'], 'value': '=='}; {'id': '18', 'type': 'tuple', 'children': ['19', '20']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'end'}, {'id': '21', 'type': 'tuple', 'children': ['22', '23']}; {'id': '22', 'type': 'None', 'children': []}, {'id': '23', 'type': 'None', 'children': []}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '28'], 'value': '=='}, {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '27', 'type': 'identifier', 'children': [], 'value': '_buf'}; {'id': '28', 'type': 'dictionary', 'children': []}, {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'raise_statement', 'children': ['31']}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'EmptyIntelHexError'}; {'id': '32', 'type': 'if_statement', 'children': ['33', '36', '107']}, {'id': '33', 'type': 'comparison_operator', 'children': ['34', '35'], 'value': 'is'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'size'}, {'id': '35', 'type': 'None', 'children': []}; {'id': '36', 'type': 'block', 'children': ['37', '51', '68']}, {'id': '37', 'type': 'if_statement', 'children': ['38', '43']}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '40'], 'value': 'not'}, {'id': '39', 'type': 'None', 'children': []}; {'id': '40', 'type': 'tuple', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'end'}, {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'raise_statement', 'children': ['45']}, {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'concatenated_string', 'children': ['49', '50']}, {'id': '49', 'type': 'string', 'children': [], 'value': '"tobinarray: you can\'t use start,end and size"'}; {'id': '50', 'type': 'string', 'children': [], 'value': '" arguments in the same time"'}, {'id': '51', 'type': 'if_statement', 'children': ['52', '59']}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '56'], 'value': '=='}, {'id': '53', 'type': 'tuple', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'start'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '56', 'type': 'tuple', 'children': ['57', '58']}, {'id': '57', 'type': 'None', 'children': []}; {'id': '58', 'type': 'None', 'children': []}, {'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': 'start'}, {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'minaddr'}, {'id': '67', 'type': 'argument_list', 'children': []}; {'id': '68', 'type': 'if_statement', 'children': ['69', '72', '81']}, {'id': '69', 'type': 'comparison_operator', 'children': ['70', '71'], 'value': 'is'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'start'}, {'id': '71', 'type': 'None', 'children': []}; {'id': '72', 'type': 'block', 'children': ['73']}, {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '76', 'type': 'binary_operator', 'children': ['77', '80'], 'value': '-'}, {'id': '77', 'type': 'binary_operator', 'children': ['78', '79'], 'value': '+'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'start'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '80', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '81', 'type': 'else_clause', 'children': ['82']}; {'id': '82', 'type': 'block', 'children': ['83', '91']}, {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '86', 'type': 'binary_operator', 'children': ['87', '90'], 'value': '+'}, {'id': '87', 'type': 'binary_operator', 'children': ['88', '89'], 'value': '-'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'end'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '90', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '91', 'type': 'if_statement', 'children': ['92', '95']}; {'id': '92', 'type': 'comparison_operator', 'children': ['93', '94'], 'value': '<'}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '94', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'raise_statement', 'children': ['97']}, {'id': '97', 'type': 'call', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'binary_operator', 'children': ['101', '104'], 'value': '%'}, {'id': '101', 'type': 'concatenated_string', 'children': ['102', '103']}; {'id': '102', 'type': 'string', 'children': [], 'value': '"tobinarray: invalid size (%d) "'}, {'id': '103', 'type': 'string', 'children': [], 'value': '"for given end address (%d)"'}; {'id': '104', 'type': 'tuple', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'end'}, {'id': '107', 'type': 'else_clause', 'children': ['108']}; {'id': '108', 'type': 'block', 'children': ['109', '122', '135']}, {'id': '109', 'type': 'if_statement', 'children': ['110', '113']}; {'id': '110', 'type': 'comparison_operator', 'children': ['111', '112'], 'value': 'is'}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '112', 'type': 'None', 'children': []}, {'id': '113', 'type': 'block', 'children': ['114']}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}, {'id': '115', 'type': 'assignment', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'start'}, {'id': '117', 'type': 'call', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'minaddr'}, {'id': '121', 'type': 'argument_list', 'children': []}; {'id': '122', 'type': 'if_statement', 'children': ['123', '126']}, {'id': '123', 'type': 'comparison_operator', 'children': ['124', '125'], 'value': 'is'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'end'}, {'id': '125', 'type': 'None', 'children': []}; {'id': '126', 'type': 'block', 'children': ['127']}, {'id': '127', 'type': 'expression_statement', 'children': ['128']}; {'id': '128', 'type': 'assignment', 'children': ['129', '130']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '130', 'type': 'call', 'children': ['131', '134']}, {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'maxaddr'}; {'id': '134', 'type': 'argument_list', 'children': []}, {'id': '135', 'type': 'if_statement', 'children': ['136', '139']}; {'id': '136', 'type': 'comparison_operator', 'children': ['137', '138'], 'value': '>'}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'end'}, {'id': '139', 'type': 'block', 'children': ['140']}; {'id': '140', 'type': 'expression_statement', 'children': ['141']}, {'id': '141', 'type': 'assignment', 'children': ['142', '145']}; {'id': '142', 'type': 'pattern_list', 'children': ['143', '144']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'end'}, {'id': '145', 'type': 'expression_list', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'end'}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '148', 'type': 'return_statement', 'children': ['149']}, {'id': '149', 'type': 'expression_list', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'start'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'end'}
def _get_start_end(self, start=None, end=None, size=None): if (start,end) == (None,None) and self._buf == {}: raise EmptyIntelHexError if size is not None: if None not in (start, end): raise ValueError("tobinarray: you can't use start,end and size" " arguments in the same time") if (start, end) == (None, None): start = self.minaddr() if start is not None: end = start + size - 1 else: start = end - size + 1 if start < 0: raise ValueError("tobinarray: invalid size (%d) " "for given end address (%d)" % (size,end)) else: if start is None: start = self.minaddr() if end is None: end = self.maxaddr() if start > end: start, end = end, start return start, end
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dump'}, {'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': 'tofile'}, {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '16'}, {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'withpadding'}, {'id': '13', 'type': 'False', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '32', '39', '50', '147', '156']}, {'id': '15', 'type': 'if_statement', 'children': ['16', '26']}; {'id': '16', 'type': 'boolean_operator', 'children': ['17', '23'], 'value': 'or'}, {'id': '17', 'type': 'not_operator', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'int'}, {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': '<'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'width'}, {'id': '25', 'type': 'integer', 'children': [], 'value': '1'}; {'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': 'ValueError'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}, {'id': '31', 'type': 'string', 'children': [], 'value': "'width must be a positive integer.'"}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}, {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'width'}, {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'int'}, {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'width'}, {'id': '39', 'type': 'if_statement', 'children': ['40', '43']}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '42'], 'value': 'is'}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'tofile'}; {'id': '42', 'type': 'None', 'children': []}, {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}, {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'tofile'}, {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'sys'}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '50', 'type': 'if_statement', 'children': ['51', '56']}, {'id': '51', 'type': 'comparison_operator', 'children': ['52', '55'], 'value': 'is'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'start_addr'}, {'id': '55', 'type': 'None', 'children': []}; {'id': '56', 'type': 'block', 'children': ['57', '68', '79', '90']}, {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'cs'}; {'id': '60', 'type': 'call', 'children': ['61', '66']}, {'id': '61', 'type': 'attribute', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'start_addr'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}, {'id': '67', 'type': 'string', 'children': [], 'value': "'CS'"}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}, {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'ip'}, {'id': '71', 'type': 'call', 'children': ['72', '77']}; {'id': '72', 'type': 'attribute', 'children': ['73', '76']}, {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'start_addr'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'get'}, {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'string', 'children': [], 'value': "'IP'"}, {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'eip'}; {'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': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'start_addr'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}, {'id': '89', 'type': 'string', 'children': [], 'value': "'EIP'"}; {'id': '90', 'type': 'if_statement', 'children': ['91', '102', '112', '136']}, {'id': '91', 'type': 'boolean_operator', 'children': ['92', '99'], 'value': 'and'}; {'id': '92', 'type': 'boolean_operator', 'children': ['93', '96'], 'value': 'and'}, {'id': '93', 'type': 'comparison_operator', 'children': ['94', '95'], 'value': 'is'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'eip'}, {'id': '95', 'type': 'None', 'children': []}; {'id': '96', 'type': 'comparison_operator', 'children': ['97', '98'], 'value': 'is'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'cs'}; {'id': '98', 'type': 'None', 'children': []}, {'id': '99', 'type': 'comparison_operator', 'children': ['100', '101'], 'value': 'is'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'ip'}, {'id': '101', 'type': 'None', 'children': []}; {'id': '102', 'type': 'block', 'children': ['103']}, {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '108']}, {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'tofile'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}, {'id': '109', 'type': 'binary_operator', 'children': ['110', '111'], 'value': '%'}; {'id': '110', 'type': 'string', 'children': [], 'value': "'EIP = 0x%08X\\n'"}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'eip'}; {'id': '112', 'type': 'elif_clause', 'children': ['113', '124']}, {'id': '113', 'type': 'boolean_operator', 'children': ['114', '121'], 'value': 'and'}; {'id': '114', 'type': 'boolean_operator', 'children': ['115', '118'], 'value': 'and'}, {'id': '115', 'type': 'comparison_operator', 'children': ['116', '117'], 'value': 'is'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'eip'}, {'id': '117', 'type': 'None', 'children': []}; {'id': '118', 'type': 'comparison_operator', 'children': ['119', '120'], 'value': 'is'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'cs'}; {'id': '120', 'type': 'None', 'children': []}, {'id': '121', 'type': 'comparison_operator', 'children': ['122', '123'], 'value': 'is'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'ip'}, {'id': '123', 'type': 'None', 'children': []}; {'id': '124', 'type': 'block', 'children': ['125']}, {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'call', 'children': ['127', '130']}, {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'tofile'}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '130', 'type': 'argument_list', 'children': ['131']}, {'id': '131', 'type': 'binary_operator', 'children': ['132', '133'], 'value': '%'}; {'id': '132', 'type': 'string', 'children': [], 'value': "'CS = 0x%04X, IP = 0x%04X\\n'"}, {'id': '133', 'type': 'tuple', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'cs'}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'ip'}; {'id': '136', 'type': 'else_clause', 'children': ['137']}, {'id': '137', 'type': 'block', 'children': ['138']}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}, {'id': '139', 'type': 'call', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'tofile'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'write'}, {'id': '143', 'type': 'argument_list', 'children': ['144']}; {'id': '144', 'type': 'binary_operator', 'children': ['145', '146'], 'value': '%'}, {'id': '145', 'type': 'string', 'children': [], 'value': "'start_addr = %r\\n'"}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'start_addr'}, {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'assignment', 'children': ['149', '150']}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'addresses'}; {'id': '150', 'type': 'call', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'dict_keys'}; {'id': '152', 'type': 'argument_list', 'children': ['153']}, {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '155', 'type': 'identifier', 'children': [], 'value': '_buf'}; {'id': '156', 'type': 'if_statement', 'children': ['157', '158']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'addresses'}; {'id': '158', 'type': 'block', 'children': ['159', '165', '171', '178', '187', '199', '215', '221', '228', '243']}, {'id': '159', 'type': 'expression_statement', 'children': ['160']}; {'id': '160', 'type': 'call', 'children': ['161', '164']}, {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'addresses'}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '164', 'type': 'argument_list', 'children': []}, {'id': '165', 'type': 'expression_statement', 'children': ['166']}; {'id': '166', 'type': 'assignment', 'children': ['167', '168']}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'minaddr'}; {'id': '168', 'type': 'subscript', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'addresses'}; {'id': '170', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '171', 'type': 'expression_statement', 'children': ['172']}; {'id': '172', 'type': 'assignment', 'children': ['173', '174']}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'maxaddr'}; {'id': '174', 'type': 'subscript', 'children': ['175', '176']}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'addresses'}; {'id': '176', 'type': 'unary_operator', 'children': ['177'], 'value': '-'}, {'id': '177', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '178', 'type': 'expression_statement', 'children': ['179']}, {'id': '179', 'type': 'assignment', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'startaddr'}, {'id': '181', 'type': 'binary_operator', 'children': ['182', '186'], 'value': '*'}; {'id': '182', 'type': 'parenthesized_expression', 'children': ['183']}, {'id': '183', 'type': 'binary_operator', 'children': ['184', '185'], 'value': '//'}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'minaddr'}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'width'}, {'id': '187', 'type': 'expression_statement', 'children': ['188']}; {'id': '188', 'type': 'assignment', 'children': ['189', '190']}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'endaddr'}; {'id': '190', 'type': 'binary_operator', 'children': ['191', '198'], 'value': '*'}, {'id': '191', 'type': 'parenthesized_expression', 'children': ['192']}; {'id': '192', 'type': 'binary_operator', 'children': ['193', '197'], 'value': '+'}, {'id': '193', 'type': 'parenthesized_expression', 'children': ['194']}; {'id': '194', 'type': 'binary_operator', 'children': ['195', '196'], 'value': '//'}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'maxaddr'}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'width'}, {'id': '197', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'width'}, {'id': '199', 'type': 'expression_statement', 'children': ['200']}; {'id': '200', 'type': 'assignment', 'children': ['201', '202']}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'maxdigits'}; {'id': '202', 'type': 'call', 'children': ['203', '204']}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '204', 'type': 'argument_list', 'children': ['205', '214']}, {'id': '205', 'type': 'binary_operator', 'children': ['206', '213'], 'value': '-'}; {'id': '206', 'type': 'call', 'children': ['207', '208']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '208', 'type': 'argument_list', 'children': ['209']}, {'id': '209', 'type': 'call', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'hex'}, {'id': '211', 'type': 'argument_list', 'children': ['212']}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'endaddr'}, {'id': '213', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '214', 'type': 'integer', 'children': [], 'value': '4'}, {'id': '215', 'type': 'expression_statement', 'children': ['216']}; {'id': '216', 'type': 'assignment', 'children': ['217', '218']}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'templa'}; {'id': '218', 'type': 'binary_operator', 'children': ['219', '220'], 'value': '%'}, {'id': '219', 'type': 'string', 'children': [], 'value': "'%%0%dX'"}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'maxdigits'}, {'id': '221', 'type': 'expression_statement', 'children': ['222']}; {'id': '222', 'type': 'assignment', 'children': ['223', '224']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'rangewidth'}; {'id': '224', 'type': 'call', 'children': ['225', '226']}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'range_l'}; {'id': '226', 'type': 'argument_list', 'children': ['227']}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '228', 'type': 'if_statement', 'children': ['229', '230', '237']}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'withpadding'}; {'id': '230', 'type': 'block', 'children': ['231']}, {'id': '231', 'type': 'expression_statement', 'children': ['232']}; {'id': '232', 'type': 'assignment', 'children': ['233', '234']}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'pad'}; {'id': '234', 'type': 'attribute', 'children': ['235', '236']}, {'id': '235', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'padding'}, {'id': '237', 'type': 'else_clause', 'children': ['238']}; {'id': '238', 'type': 'block', 'children': ['239']}, {'id': '239', 'type': 'expression_statement', 'children': ['240']}; {'id': '240', 'type': 'assignment', 'children': ['241', '242']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'pad'}; {'id': '242', 'type': 'None', 'children': []}, {'id': '243', 'type': 'for_statement', 'children': ['244', '245', '251']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '245', 'type': 'call', 'children': ['246', '247']}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'range_g'}, {'id': '247', 'type': 'argument_list', 'children': ['248', '249', '250']}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 'startaddr'}, {'id': '249', 'type': 'identifier', 'children': [], 'value': 'endaddr'}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'width'}, {'id': '251', 'type': 'block', 'children': ['252', '261', '268', '272', '345']}; {'id': '252', 'type': 'expression_statement', 'children': ['253']}, {'id': '253', 'type': 'call', 'children': ['254', '257']}; {'id': '254', 'type': 'attribute', 'children': ['255', '256']}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'tofile'}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'write'}, {'id': '257', 'type': 'argument_list', 'children': ['258']}; {'id': '258', 'type': 'binary_operator', 'children': ['259', '260'], 'value': '%'}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'templa'}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '261', 'type': 'expression_statement', 'children': ['262']}; {'id': '262', 'type': 'call', 'children': ['263', '266']}, {'id': '263', 'type': 'attribute', 'children': ['264', '265']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'tofile'}, {'id': '265', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '266', 'type': 'argument_list', 'children': ['267']}, {'id': '267', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '268', 'type': 'expression_statement', 'children': ['269']}, {'id': '269', 'type': 'assignment', 'children': ['270', '271']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '271', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '272', 'type': 'for_statement', 'children': ['273', '274', '275']}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'rangewidth'}, {'id': '275', 'type': 'block', 'children': ['276', '290']}; {'id': '276', 'type': 'expression_statement', 'children': ['277']}, {'id': '277', 'type': 'assignment', 'children': ['278', '279']}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '279', 'type': 'call', 'children': ['280', '285']}; {'id': '280', 'type': 'attribute', 'children': ['281', '284']}, {'id': '281', 'type': 'attribute', 'children': ['282', '283']}; {'id': '282', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '283', 'type': 'identifier', 'children': [], 'value': '_buf'}; {'id': '284', 'type': 'identifier', 'children': [], 'value': 'get'}, {'id': '285', 'type': 'argument_list', 'children': ['286', '289']}; {'id': '286', 'type': 'binary_operator', 'children': ['287', '288'], 'value': '+'}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'j'}, {'id': '289', 'type': 'identifier', 'children': [], 'value': 'pad'}; {'id': '290', 'type': 'if_statement', 'children': ['291', '294', '329']}, {'id': '291', 'type': 'comparison_operator', 'children': ['292', '293'], 'value': 'is'}; {'id': '292', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '293', 'type': 'None', 'children': []}; {'id': '294', 'type': 'block', 'children': ['295', '304']}, {'id': '295', 'type': 'expression_statement', 'children': ['296']}; {'id': '296', 'type': 'call', 'children': ['297', '300']}, {'id': '297', 'type': 'attribute', 'children': ['298', '299']}; {'id': '298', 'type': 'identifier', 'children': [], 'value': 'tofile'}, {'id': '299', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '300', 'type': 'argument_list', 'children': ['301']}, {'id': '301', 'type': 'binary_operator', 'children': ['302', '303'], 'value': '%'}; {'id': '302', 'type': 'string', 'children': [], 'value': "' %02X'"}, {'id': '303', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '304', 'type': 'if_statement', 'children': ['305', '309', '320']}, {'id': '305', 'type': 'comparison_operator', 'children': ['306', '307', '308'], 'value': '<='}; {'id': '306', 'type': 'integer', 'children': [], 'value': '32'}, {'id': '307', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '308', 'type': 'integer', 'children': [], 'value': '127'}, {'id': '309', 'type': 'block', 'children': ['310']}; {'id': '310', 'type': 'expression_statement', 'children': ['311']}, {'id': '311', 'type': 'call', 'children': ['312', '315']}; {'id': '312', 'type': 'attribute', 'children': ['313', '314']}, {'id': '313', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '314', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '315', 'type': 'argument_list', 'children': ['316']}; {'id': '316', 'type': 'call', 'children': ['317', '318']}, {'id': '317', 'type': 'identifier', 'children': [], 'value': 'chr'}; {'id': '318', 'type': 'argument_list', 'children': ['319']}, {'id': '319', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '320', 'type': 'else_clause', 'children': ['321']}, {'id': '321', 'type': 'block', 'children': ['322']}; {'id': '322', 'type': 'expression_statement', 'children': ['323']}, {'id': '323', 'type': 'call', 'children': ['324', '327']}; {'id': '324', 'type': 'attribute', 'children': ['325', '326']}, {'id': '325', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '326', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '327', 'type': 'argument_list', 'children': ['328']}; {'id': '328', 'type': 'string', 'children': [], 'value': "'.'"}, {'id': '329', 'type': 'else_clause', 'children': ['330']}; {'id': '330', 'type': 'block', 'children': ['331', '338']}, {'id': '331', 'type': 'expression_statement', 'children': ['332']}; {'id': '332', 'type': 'call', 'children': ['333', '336']}, {'id': '333', 'type': 'attribute', 'children': ['334', '335']}; {'id': '334', 'type': 'identifier', 'children': [], 'value': 'tofile'}, {'id': '335', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '336', 'type': 'argument_list', 'children': ['337']}, {'id': '337', 'type': 'string', 'children': [], 'value': "' --'"}; {'id': '338', 'type': 'expression_statement', 'children': ['339']}, {'id': '339', 'type': 'call', 'children': ['340', '343']}; {'id': '340', 'type': 'attribute', 'children': ['341', '342']}, {'id': '341', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '342', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '343', 'type': 'argument_list', 'children': ['344']}; {'id': '344', 'type': 'string', 'children': [], 'value': "' '"}, {'id': '345', 'type': 'expression_statement', 'children': ['346']}; {'id': '346', 'type': 'call', 'children': ['347', '350']}, {'id': '347', 'type': 'attribute', 'children': ['348', '349']}; {'id': '348', 'type': 'identifier', 'children': [], 'value': 'tofile'}, {'id': '349', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '350', 'type': 'argument_list', 'children': ['351']}, {'id': '351', 'type': 'binary_operator', 'children': ['352', '360'], 'value': '+'}; {'id': '352', 'type': 'binary_operator', 'children': ['353', '354'], 'value': '+'}, {'id': '353', 'type': 'string', 'children': [], 'value': "' |'"}; {'id': '354', 'type': 'call', 'children': ['355', '358']}, {'id': '355', 'type': 'attribute', 'children': ['356', '357']}; {'id': '356', 'type': 'string', 'children': [], 'value': "''"}, {'id': '357', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '358', 'type': 'argument_list', 'children': ['359']}, {'id': '359', 'type': 'identifier', 'children': [], 'value': 's'}
def dump(self, tofile=None, width=16, withpadding=False): if not isinstance(width,int) or width < 1: raise ValueError('width must be a positive integer.') width = int(width) if tofile is None: tofile = sys.stdout if self.start_addr is not None: cs = self.start_addr.get('CS') ip = self.start_addr.get('IP') eip = self.start_addr.get('EIP') if eip is not None and cs is None and ip is None: tofile.write('EIP = 0x%08X\n' % eip) elif eip is None and cs is not None and ip is not None: tofile.write('CS = 0x%04X, IP = 0x%04X\n' % (cs, ip)) else: tofile.write('start_addr = %r\n' % start_addr) addresses = dict_keys(self._buf) if addresses: addresses.sort() minaddr = addresses[0] maxaddr = addresses[-1] startaddr = (minaddr // width) * width endaddr = ((maxaddr // width) + 1) * width maxdigits = max(len(hex(endaddr)) - 2, 4) templa = '%%0%dX' % maxdigits rangewidth = range_l(width) if withpadding: pad = self.padding else: pad = None for i in range_g(startaddr, endaddr, width): tofile.write(templa % i) tofile.write(' ') s = [] for j in rangewidth: x = self._buf.get(i+j, pad) if x is not None: tofile.write(' %02X' % x) if 32 <= x < 127: s.append(chr(x)) else: s.append('.') else: tofile.write(' --') s.append(' ') tofile.write(' |' + ''.join(s) + '|\n')
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_recipe_folder'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'recipe_folder'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'whitelist'}; {'id': '8', 'type': 'None', 'children': []}, {'id': '9', 'type': 'block', 'children': ['10', '22', '31', '94']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '14']}, {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': 'is'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'whitelist'}, {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15']}, {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'whitelist'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'whitelist'}; {'id': '22', 'type': 'if_statement', 'children': ['23', '26']}, {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': '=='}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'recipe_folder'}, {'id': '25', 'type': 'string', 'children': [], 'value': "''"}; {'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': 'recipe_folder'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'.'"}, {'id': '31', 'type': 'for_statement', 'children': ['32', '33', '50']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'yaml_file'}, {'id': '33', 'type': 'list_comprehension', 'children': ['34', '35', '43']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '35', 'type': 'for_in_clause', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'listdir'}, {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'recipe_folder'}, {'id': '43', 'type': 'if_clause', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}, {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}, {'id': '49', 'type': 'string', 'children': [], 'value': "'.yaml'"}; {'id': '50', 'type': 'block', 'children': ['51', '61', '84']}, {'id': '51', 'type': 'if_statement', 'children': ['52', '59']}; {'id': '52', 'type': 'boolean_operator', 'children': ['53', '56'], 'value': 'and'}, {'id': '53', 'type': 'comparison_operator', 'children': ['54', '55'], 'value': 'is'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'whitelist'}, {'id': '55', 'type': 'None', 'children': []}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '58'], 'value': 'not'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'yaml_file'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'whitelist'}, {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'continue_statement', 'children': []}, {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'recipe'}; {'id': '64', 'type': 'call', 'children': ['65', '68']}, {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'RecipeObject'}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'FromFile'}; {'id': '68', 'type': 'argument_list', 'children': ['69', '78', '81']}, {'id': '69', 'type': 'call', 'children': ['70', '75']}; {'id': '70', 'type': 'attribute', 'children': ['71', '74']}, {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '75', 'type': 'argument_list', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'recipe_folder'}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'yaml_file'}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': '_recipe_actions'}, {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': '_recipe_resources'}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}, {'id': '85', 'type': 'assignment', 'children': ['86', '93']}; {'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': '_recipes'}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'recipe'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'recipe'}; {'id': '94', 'type': 'for_statement', 'children': ['95', '96', '113']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'ship_file'}; {'id': '96', 'type': 'list_comprehension', 'children': ['97', '98', '106']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '98', 'type': 'for_in_clause', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '100', 'type': 'call', 'children': ['101', '104']}, {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'listdir'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'recipe_folder'}; {'id': '106', 'type': 'if_clause', 'children': ['107']}, {'id': '107', 'type': 'call', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'endswith'}, {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'string', 'children': [], 'value': "'.ship'"}, {'id': '113', 'type': 'block', 'children': ['114', '124', '147']}; {'id': '114', 'type': 'if_statement', 'children': ['115', '122']}, {'id': '115', 'type': 'boolean_operator', 'children': ['116', '119'], 'value': 'and'}; {'id': '116', 'type': 'comparison_operator', 'children': ['117', '118'], 'value': 'is'}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'whitelist'}; {'id': '118', 'type': 'None', 'children': []}, {'id': '119', 'type': 'comparison_operator', 'children': ['120', '121'], 'value': 'not'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'ship_file'}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'whitelist'}; {'id': '122', 'type': 'block', 'children': ['123']}, {'id': '123', 'type': 'continue_statement', 'children': []}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}, {'id': '125', 'type': 'assignment', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'recipe'}, {'id': '127', 'type': 'call', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'RecipeObject'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'FromArchive'}, {'id': '131', 'type': 'argument_list', 'children': ['132', '141', '144']}; {'id': '132', 'type': 'call', 'children': ['133', '138']}, {'id': '133', 'type': 'attribute', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '138', 'type': 'argument_list', 'children': ['139', '140']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'recipe_folder'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'ship_file'}, {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '143', 'type': 'identifier', 'children': [], 'value': '_recipe_actions'}; {'id': '144', 'type': 'attribute', 'children': ['145', '146']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': '_recipe_resources'}, {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'assignment', 'children': ['149', '156']}, {'id': '149', 'type': 'subscript', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': '_recipes'}, {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'recipe'}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'name'}
def add_recipe_folder(self, recipe_folder, whitelist=None): if whitelist is not None: whitelist = set(whitelist) if recipe_folder == '': recipe_folder = '.' for yaml_file in [x for x in os.listdir(recipe_folder) if x.endswith('.yaml')]: if whitelist is not None and yaml_file not in whitelist: continue recipe = RecipeObject.FromFile(os.path.join(recipe_folder, yaml_file), self._recipe_actions, self._recipe_resources) self._recipes[recipe.name] = recipe for ship_file in [x for x in os.listdir(recipe_folder) if x.endswith('.ship')]: if whitelist is not None and ship_file not in whitelist: continue recipe = RecipeObject.FromArchive(os.path.join(recipe_folder, ship_file), self._recipe_actions, self._recipe_resources) self._recipes[recipe.name] = recipe
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}, {'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': 'include_reset'}, {'id': '7', 'type': 'True', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'accelerated'}; {'id': '10', 'type': 'True', 'children': []}, {'id': '11', 'type': 'block', 'children': ['12', '20', '31', '35', '39', '92', '113']}; {'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': '_start_tick'}, {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'tick_count'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '29']}, {'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': '_check_stop_conditions'}, {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'sensor_graph'}, {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'return_statement', 'children': []}, {'id': '31', 'type': 'if_statement', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'include_reset'}, {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'pass_statement', 'children': []}, {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '38', 'type': 'None', 'children': []}, {'id': '39', 'type': 'for_statement', 'children': ['40', '43', '49']}; {'id': '40', 'type': 'pattern_list', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'stim'}, {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'enumerate'}, {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'stimuli'}, {'id': '49', 'type': 'block', 'children': ['50', '58', '77']}; {'id': '50', 'type': 'if_statement', 'children': ['51', '56']}, {'id': '51', 'type': 'comparison_operator', 'children': ['52', '55'], 'value': '!='}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'stim'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'time'}, {'id': '55', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '56', 'type': 'block', 'children': ['57']}, {'id': '57', 'type': 'break_statement', 'children': []}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}, {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'reading'}, {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'IOTileReading'}, {'id': '63', 'type': 'argument_list', 'children': ['64', '67', '74']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'tick_count'}, {'id': '67', 'type': 'call', 'children': ['68', '73']}; {'id': '68', 'type': 'attribute', 'children': ['69', '72']}, {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'stim'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'encode'}, {'id': '73', 'type': 'argument_list', 'children': []}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'stim'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '84']}, {'id': '79', 'type': 'attribute', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'sensor_graph'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'process_input'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '88', '89']}, {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'stim'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'reading'}, {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'rpc_executor'}; {'id': '92', 'type': 'if_statement', 'children': ['93', '100']}, {'id': '93', 'type': 'boolean_operator', 'children': ['94', '97'], 'value': 'and'}; {'id': '94', 'type': 'comparison_operator', 'children': ['95', '96'], 'value': 'is'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '96', 'type': 'None', 'children': []}, {'id': '97', 'type': 'comparison_operator', 'children': ['98', '99'], 'value': '>'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '99', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '100', 'type': 'block', 'children': ['101']}, {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '106']}, {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'stimuli'}; {'id': '106', 'type': 'subscript', 'children': ['107', '110']}, {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'stimuli'}; {'id': '110', 'type': 'slice', 'children': ['111', '112']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '112', 'type': 'colon', 'children': []}, {'id': '113', 'type': 'while_statement', 'children': ['114', '123']}; {'id': '114', 'type': 'not_operator', 'children': ['115']}, {'id': '115', 'type': 'call', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': '_check_stop_conditions'}, {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'sensor_graph'}, {'id': '123', 'type': 'block', 'children': ['124', '130', '136', '142', '146', '201', '222', '231', '306', '312']}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}, {'id': '125', 'type': 'assignment', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'now'}, {'id': '127', 'type': 'call', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'monotonic'}, {'id': '129', 'type': 'argument_list', 'children': []}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}, {'id': '131', 'type': 'assignment', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'next_tick'}, {'id': '133', 'type': 'binary_operator', 'children': ['134', '135'], 'value': '+'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'now'}, {'id': '135', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}, {'id': '137', 'type': 'augmented_assignment', 'children': ['138', '141'], 'value': '+='}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'tick_count'}, {'id': '141', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '142', 'type': 'expression_statement', 'children': ['143']}, {'id': '143', 'type': 'assignment', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '145', 'type': 'None', 'children': []}; {'id': '146', 'type': 'for_statement', 'children': ['147', '150', '156']}, {'id': '147', 'type': 'pattern_list', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'stim'}; {'id': '150', 'type': 'call', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '152', 'type': 'argument_list', 'children': ['153']}, {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'stimuli'}; {'id': '156', 'type': 'block', 'children': ['157', '167', '186']}, {'id': '157', 'type': 'if_statement', 'children': ['158', '165']}; {'id': '158', 'type': 'comparison_operator', 'children': ['159', '162'], 'value': '!='}, {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'stim'}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'tick_count'}, {'id': '165', 'type': 'block', 'children': ['166']}; {'id': '166', 'type': 'break_statement', 'children': []}, {'id': '167', 'type': 'expression_statement', 'children': ['168']}; {'id': '168', 'type': 'assignment', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'reading'}; {'id': '170', 'type': 'call', 'children': ['171', '172']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'IOTileReading'}; {'id': '172', 'type': 'argument_list', 'children': ['173', '176', '183']}, {'id': '173', 'type': 'attribute', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'tick_count'}; {'id': '176', 'type': 'call', 'children': ['177', '182']}, {'id': '177', 'type': 'attribute', 'children': ['178', '181']}; {'id': '178', 'type': 'attribute', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'stim'}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'stream'}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '182', 'type': 'argument_list', 'children': []}, {'id': '183', 'type': 'attribute', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'stim'}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '186', 'type': 'expression_statement', 'children': ['187']}, {'id': '187', 'type': 'call', 'children': ['188', '193']}; {'id': '188', 'type': 'attribute', 'children': ['189', '192']}, {'id': '189', 'type': 'attribute', 'children': ['190', '191']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'sensor_graph'}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'process_input'}, {'id': '193', 'type': 'argument_list', 'children': ['194', '197', '198']}; {'id': '194', 'type': 'attribute', 'children': ['195', '196']}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'stim'}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'stream'}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'reading'}; {'id': '198', 'type': 'attribute', 'children': ['199', '200']}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'rpc_executor'}, {'id': '201', 'type': 'if_statement', 'children': ['202', '209']}; {'id': '202', 'type': 'boolean_operator', 'children': ['203', '206'], 'value': 'and'}, {'id': '203', 'type': 'comparison_operator', 'children': ['204', '205'], 'value': 'is'}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '205', 'type': 'None', 'children': []}; {'id': '206', 'type': 'comparison_operator', 'children': ['207', '208'], 'value': '>'}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '208', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '209', 'type': 'block', 'children': ['210']}; {'id': '210', 'type': 'expression_statement', 'children': ['211']}, {'id': '211', 'type': 'assignment', 'children': ['212', '215']}; {'id': '212', 'type': 'attribute', 'children': ['213', '214']}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'stimuli'}, {'id': '215', 'type': 'subscript', 'children': ['216', '219']}; {'id': '216', 'type': 'attribute', 'children': ['217', '218']}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'stimuli'}, {'id': '219', 'type': 'slice', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '221', 'type': 'colon', 'children': []}; {'id': '222', 'type': 'expression_statement', 'children': ['223']}, {'id': '223', 'type': 'call', 'children': ['224', '227']}; {'id': '224', 'type': 'attribute', 'children': ['225', '226']}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '226', 'type': 'identifier', 'children': [], 'value': '_check_additional_ticks'}, {'id': '227', 'type': 'argument_list', 'children': ['228']}; {'id': '228', 'type': 'attribute', 'children': ['229', '230']}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'tick_count'}, {'id': '231', 'type': 'if_statement', 'children': ['232', '240']}; {'id': '232', 'type': 'comparison_operator', 'children': ['233', '239'], 'value': '=='}, {'id': '233', 'type': 'parenthesized_expression', 'children': ['234']}; {'id': '234', 'type': 'binary_operator', 'children': ['235', '238'], 'value': '%'}, {'id': '235', 'type': 'attribute', 'children': ['236', '237']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '237', 'type': 'identifier', 'children': [], 'value': 'tick_count'}; {'id': '238', 'type': 'integer', 'children': [], 'value': '10'}, {'id': '239', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '240', 'type': 'block', 'children': ['241', '258', '271', '293']}, {'id': '241', 'type': 'expression_statement', 'children': ['242']}; {'id': '242', 'type': 'assignment', 'children': ['243', '244']}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'reading'}; {'id': '244', 'type': 'call', 'children': ['245', '246']}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'IOTileReading'}; {'id': '246', 'type': 'argument_list', 'children': ['247', '250', '255']}, {'id': '247', 'type': 'attribute', 'children': ['248', '249']}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '249', 'type': 'identifier', 'children': [], 'value': 'tick_count'}; {'id': '250', 'type': 'call', 'children': ['251', '254']}, {'id': '251', 'type': 'attribute', 'children': ['252', '253']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'system_tick'}, {'id': '253', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '254', 'type': 'argument_list', 'children': []}, {'id': '255', 'type': 'attribute', 'children': ['256', '257']}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '257', 'type': 'identifier', 'children': [], 'value': 'tick_count'}; {'id': '258', 'type': 'expression_statement', 'children': ['259']}, {'id': '259', 'type': 'call', 'children': ['260', '265']}; {'id': '260', 'type': 'attribute', 'children': ['261', '264']}, {'id': '261', 'type': 'attribute', 'children': ['262', '263']}; {'id': '262', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '263', 'type': 'identifier', 'children': [], 'value': 'sensor_graph'}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'process_input'}, {'id': '265', 'type': 'argument_list', 'children': ['266', '267', '268']}; {'id': '266', 'type': 'identifier', 'children': [], 'value': 'system_tick'}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'reading'}; {'id': '268', 'type': 'attribute', 'children': ['269', '270']}, {'id': '269', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'rpc_executor'}, {'id': '271', 'type': 'expression_statement', 'children': ['272']}; {'id': '272', 'type': 'assignment', 'children': ['273', '274']}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'reading'}; {'id': '274', 'type': 'call', 'children': ['275', '276']}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 'IOTileReading'}; {'id': '276', 'type': 'argument_list', 'children': ['277', '280', '285']}, {'id': '277', 'type': 'attribute', 'children': ['278', '279']}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '279', 'type': 'identifier', 'children': [], 'value': 'tick_count'}; {'id': '280', 'type': 'call', 'children': ['281', '284']}, {'id': '281', 'type': 'attribute', 'children': ['282', '283']}; {'id': '282', 'type': 'identifier', 'children': [], 'value': 'battery_voltage'}, {'id': '283', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '284', 'type': 'argument_list', 'children': []}, {'id': '285', 'type': 'call', 'children': ['286', '287']}; {'id': '286', 'type': 'identifier', 'children': [], 'value': 'int'}, {'id': '287', 'type': 'argument_list', 'children': ['288']}; {'id': '288', 'type': 'binary_operator', 'children': ['289', '292'], 'value': '*'}, {'id': '289', 'type': 'attribute', 'children': ['290', '291']}; {'id': '290', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '291', 'type': 'identifier', 'children': [], 'value': 'voltage'}; {'id': '292', 'type': 'integer', 'children': [], 'value': '65536'}, {'id': '293', 'type': 'expression_statement', 'children': ['294']}; {'id': '294', 'type': 'call', 'children': ['295', '300']}, {'id': '295', 'type': 'attribute', 'children': ['296', '299']}; {'id': '296', 'type': 'attribute', 'children': ['297', '298']}, {'id': '297', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '298', 'type': 'identifier', 'children': [], 'value': 'sensor_graph'}, {'id': '299', 'type': 'identifier', 'children': [], 'value': 'process_input'}; {'id': '300', 'type': 'argument_list', 'children': ['301', '302', '303']}, {'id': '301', 'type': 'identifier', 'children': [], 'value': 'battery_voltage'}; {'id': '302', 'type': 'identifier', 'children': [], 'value': 'reading'}, {'id': '303', 'type': 'attribute', 'children': ['304', '305']}; {'id': '304', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '305', 'type': 'identifier', 'children': [], 'value': 'rpc_executor'}; {'id': '306', 'type': 'expression_statement', 'children': ['307']}, {'id': '307', 'type': 'assignment', 'children': ['308', '309']}; {'id': '308', 'type': 'identifier', 'children': [], 'value': 'now'}, {'id': '309', 'type': 'call', 'children': ['310', '311']}; {'id': '310', 'type': 'identifier', 'children': [], 'value': 'monotonic'}, {'id': '311', 'type': 'argument_list', 'children': []}; {'id': '312', 'type': 'if_statement', 'children': ['313', '321']}, {'id': '313', 'type': 'boolean_operator', 'children': ['314', '317'], 'value': 'and'}; {'id': '314', 'type': 'parenthesized_expression', 'children': ['315']}, {'id': '315', 'type': 'not_operator', 'children': ['316']}; {'id': '316', 'type': 'identifier', 'children': [], 'value': 'accelerated'}, {'id': '317', 'type': 'parenthesized_expression', 'children': ['318']}; {'id': '318', 'type': 'comparison_operator', 'children': ['319', '320'], 'value': '<'}, {'id': '319', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '320', 'type': 'identifier', 'children': [], 'value': 'next_tick'}, {'id': '321', 'type': 'block', 'children': ['322']}; {'id': '322', 'type': 'expression_statement', 'children': ['323']}, {'id': '323', 'type': 'call', 'children': ['324', '327']}; {'id': '324', 'type': 'attribute', 'children': ['325', '326']}, {'id': '325', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '326', 'type': 'identifier', 'children': [], 'value': 'sleep'}, {'id': '327', 'type': 'argument_list', 'children': ['328']}; {'id': '328', 'type': 'binary_operator', 'children': ['329', '330'], 'value': '-'}, {'id': '329', 'type': 'identifier', 'children': [], 'value': 'next_tick'}
def run(self, include_reset=True, accelerated=True): self._start_tick = self.tick_count if self._check_stop_conditions(self.sensor_graph): return if include_reset: pass i = None for i, stim in enumerate(self.stimuli): if stim.time != 0: break reading = IOTileReading(self.tick_count, stim.stream.encode(), stim.value) self.sensor_graph.process_input(stim.stream, reading, self.rpc_executor) if i is not None and i > 0: self.stimuli = self.stimuli[i:] while not self._check_stop_conditions(self.sensor_graph): now = monotonic() next_tick = now + 1.0 self.tick_count += 1 i = None for i, stim in enumerate(self.stimuli): if stim.time != self.tick_count: break reading = IOTileReading(self.tick_count, stim.stream.encode(), stim.value) self.sensor_graph.process_input(stim.stream, reading, self.rpc_executor) if i is not None and i > 0: self.stimuli = self.stimuli[i:] self._check_additional_ticks(self.tick_count) if (self.tick_count % 10) == 0: reading = IOTileReading(self.tick_count, system_tick.encode(), self.tick_count) self.sensor_graph.process_input(system_tick, reading, self.rpc_executor) reading = IOTileReading(self.tick_count, battery_voltage.encode(), int(self.voltage * 65536)) self.sensor_graph.process_input(battery_voltage, reading, self.rpc_executor) now = monotonic() if (not accelerated) and (now < next_tick): time.sleep(next_tick - now)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_default_value'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '45', '73', '85', '99']}, {'id': '7', 'type': 'if_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'is'}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '10', 'type': 'None', 'children': []}, {'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', '20']}, {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'isinstance'}, {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'default'}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '20', 'type': 'block', 'children': ['21', '37']}, {'id': '21', 'type': 'if_statement', 'children': ['22', '27']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '26'], 'value': '=='}, {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'special_type'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'string'"}, {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'return_statement', 'children': ['29']}, {'id': '29', 'type': 'binary_operator', 'children': ['30', '36'], 'value': '+'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}, {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'default'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}, {'id': '35', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '36', 'type': 'string', 'children': [], 'value': "b'\\0'"}, {'id': '37', 'type': 'raise_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'DataError'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}, {'id': '41', 'type': 'string', 'children': [], 'value': '"You can only pass a unicode string if you are declaring a string type config variable"'}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'default'}, {'id': '45', 'type': 'if_statement', 'children': ['46', '53']}; {'id': '46', 'type': 'call', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '50', 'type': 'tuple', 'children': ['51', '52']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'bytearray'}, {'id': '53', 'type': 'block', 'children': ['54', '71']}; {'id': '54', 'type': 'if_statement', 'children': ['55', '66']}, {'id': '55', 'type': 'boolean_operator', 'children': ['56', '61'], 'value': 'and'}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '60'], 'value': '=='}, {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'special_type'}; {'id': '60', 'type': 'string', 'children': [], 'value': "'string'"}, {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'isinstance'}, {'id': '63', 'type': 'argument_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'default'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '66', 'type': 'block', 'children': ['67']}, {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'augmented_assignment', 'children': ['69', '70'], 'value': '+='}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '70', 'type': 'string', 'children': [], 'value': "b'\\0'"}, {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'default'}, {'id': '73', 'type': 'if_statement', 'children': ['74', '79']}; {'id': '74', 'type': 'call', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '76', 'type': 'argument_list', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'int'}, {'id': '79', 'type': 'block', 'children': ['80']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}, {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'default'}, {'id': '83', 'type': 'list', 'children': ['84'], 'value': '[default]'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'default'}, {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'format_string'}; {'id': '88', 'type': 'binary_operator', 'children': ['89', '90'], 'value': '+'}, {'id': '89', 'type': 'string', 'children': [], 'value': '"<"'}; {'id': '90', 'type': 'parenthesized_expression', 'children': ['91']}, {'id': '91', 'type': 'binary_operator', 'children': ['92', '95'], 'value': '*'}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'base_type'}, {'id': '95', 'type': 'call', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'default'}, {'id': '99', 'type': 'return_statement', 'children': ['100']}; {'id': '100', 'type': 'call', 'children': ['101', '104']}, {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'struct'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '104', 'type': 'argument_list', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'format_string'}; {'id': '106', 'type': 'list_splat', 'children': ['107']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'default'}
def _convert_default_value(self, default): if default is None: return None if isinstance(default, str): if self.special_type == 'string': return default.encode('utf-8') + b'\0' raise DataError("You can only pass a unicode string if you are declaring a string type config variable", default=default) if isinstance(default, (bytes, bytearray)): if self.special_type == 'string' and isinstance(default, bytes): default += b'\0' return default if isinstance(default, int): default = [default] format_string = "<" + (self.base_type*len(default)) return struct.pack(format_string, *default)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'latch'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6', '26', '39', '53', '102', '123', '135', '169']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '15']}, {'id': '7', 'type': 'comparison_operator', 'children': ['8', '14'], 'value': '=='}; {'id': '8', 'type': 'call', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}, {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'current_value'}; {'id': '14', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'raise_statement', 'children': ['17']}, {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'DataError'}, {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"There was no data in a config variable during latching"'}, {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}, {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'remaining'}, {'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': 'current_value'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'unit_size'}, {'id': '39', 'type': 'if_statement', 'children': ['40', '43']}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '42'], 'value': '>'}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'remaining'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}, {'id': '45', 'type': 'augmented_assignment', 'children': ['46', '49'], 'value': '+='}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'current_value'}, {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'bytearray'}, {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'remaining'}, {'id': '53', 'type': 'if_statement', 'children': ['54', '59']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '58'], 'value': '=='}, {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'special_type'}; {'id': '58', 'type': 'string', 'children': [], 'value': "'string'"}, {'id': '59', 'type': 'block', 'children': ['60', '85']}; {'id': '60', 'type': 'if_statement', 'children': ['61', '69']}, {'id': '61', 'type': 'comparison_operator', 'children': ['62', '68'], 'value': '!='}; {'id': '62', 'type': 'subscript', 'children': ['63', '66']}, {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'current_value'}; {'id': '66', 'type': 'unary_operator', 'children': ['67'], 'value': '-'}, {'id': '67', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'raise_statement', 'children': ['71']}, {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'DataError'}, {'id': '73', 'type': 'argument_list', 'children': ['74', '75', '80']}; {'id': '74', 'type': 'string', 'children': [], 'value': '"String type was specified by data did not end with a null byte"'}, {'id': '75', 'type': 'keyword_argument', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'data'}, {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'current_value'}; {'id': '80', 'type': 'keyword_argument', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '85', 'type': 'return_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '100']}, {'id': '87', 'type': 'attribute', 'children': ['88', '99']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}, {'id': '91', 'type': 'subscript', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'current_value'}, {'id': '95', 'type': 'slice', 'children': ['96', '97']}; {'id': '96', 'type': 'colon', 'children': []}, {'id': '97', 'type': 'unary_operator', 'children': ['98'], 'value': '-'}; {'id': '98', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '100', 'type': 'argument_list', 'children': ['101']}, {'id': '101', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}, {'id': '103', 'type': 'assignment', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'fmt_code'}, {'id': '105', 'type': 'binary_operator', 'children': ['106', '107'], 'value': '+'}; {'id': '106', 'type': 'string', 'children': [], 'value': '"<"'}, {'id': '107', 'type': 'parenthesized_expression', 'children': ['108']}; {'id': '108', 'type': 'binary_operator', 'children': ['109', '112'], 'value': '*'}, {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'base_type'}; {'id': '112', 'type': 'parenthesized_expression', 'children': ['113']}, {'id': '113', 'type': 'binary_operator', 'children': ['114', '120'], 'value': '//'}; {'id': '114', 'type': 'call', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}, {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'current_value'}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'unit_size'}, {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '126', 'type': 'call', 'children': ['127', '130']}, {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'struct'}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'unpack'}; {'id': '130', 'type': 'argument_list', 'children': ['131', '132']}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'fmt_code'}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'current_value'}, {'id': '135', 'type': 'if_statement', 'children': ['136', '139', '147']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'variable'}, {'id': '139', 'type': 'block', 'children': ['140']}; {'id': '140', 'type': 'expression_statement', 'children': ['141']}, {'id': '141', 'type': 'assignment', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'data'}, {'id': '143', 'type': 'call', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'list'}, {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'data'}, {'id': '147', 'type': 'else_clause', 'children': ['148']}; {'id': '148', 'type': 'block', 'children': ['149', '155']}, {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'assignment', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '152', 'type': 'subscript', 'children': ['153', '154']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '154', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '155', 'type': 'if_statement', 'children': ['156', '161']}; {'id': '156', 'type': 'comparison_operator', 'children': ['157', '160'], 'value': '=='}, {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'special_type'}; {'id': '160', 'type': 'string', 'children': [], 'value': "'bool'"}, {'id': '161', 'type': 'block', 'children': ['162']}; {'id': '162', 'type': 'expression_statement', 'children': ['163']}, {'id': '163', 'type': 'assignment', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'data'}, {'id': '165', 'type': 'call', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'bool'}, {'id': '167', 'type': 'argument_list', 'children': ['168']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'data'}, {'id': '169', 'type': 'return_statement', 'children': ['170']}
def latch(self): if len(self.current_value) == 0: raise DataError("There was no data in a config variable during latching", name=self.name) remaining = len(self.current_value) % self.unit_size if remaining > 0: self.current_value += bytearray(remaining) if self.special_type == 'string': if self.current_value[-1] != 0: raise DataError("String type was specified by data did not end with a null byte", data=self.current_value, name=self.name) return bytes(self.current_value[:-1]).decode('utf-8') fmt_code = "<" + (self.base_type * (len(self.current_value) // self.unit_size)) data = struct.unpack(fmt_code, self.current_value) if self.variable: data = list(data) else: data = data[0] if self.special_type == 'bool': data = bool(data) return data
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_contents_dir'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '5', 'type': 'block', 'children': ['6', '10', '46']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}, {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'contents'}, {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '28']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '20']}, {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'children'}, {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '22', 'type': 'lambda', 'children': ['23', '25']}, {'id': '23', 'type': 'lambda_parameters', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '28', 'type': 'block', 'children': ['29']}, {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}, {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'contents'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}, {'id': '35', 'type': 'binary_operator', 'children': ['36', '37'], 'value': '%'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'%s %s\\n'"}, {'id': '37', 'type': 'tuple', 'children': ['38', '43']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}, {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'get_csig'}; {'id': '42', 'type': 'argument_list', 'children': []}, {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '46', 'type': 'return_statement', 'children': ['47']}, {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}, {'id': '49', 'type': 'string', 'children': [], 'value': "''"}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '51', 'type': 'argument_list', 'children': ['52']}
def get_contents_dir(node): contents = [] for n in sorted(node.children(), key=lambda t: t.name): contents.append('%s %s\n' % (n.get_csig(), n.name)) return ''.join(contents)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prepare'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6', '43', '80']}; {'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': 'depends'}, {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}, {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '18']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'd'}, {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'depends'}; {'id': '18', 'type': 'block', 'children': ['19']}, {'id': '19', 'type': 'if_statement', 'children': ['20', '25']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}, {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'd'}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'missing'}; {'id': '24', 'type': 'argument_list', 'children': []}, {'id': '25', 'type': 'block', 'children': ['26', '30']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}, {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '29', 'type': 'string', 'children': [], 'value': '"Explicit dependency `%s\' not found, needed by target `%s\'."'}; {'id': '30', 'type': 'raise_statement', 'children': ['31']}, {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}, {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'Errors'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'StopError'}, {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '40'], 'value': '%'}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '40', 'type': 'tuple', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '43', 'type': 'if_statement', 'children': ['44', '49']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '48'], 'value': 'is'}, {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'implicit'}; {'id': '48', 'type': 'None', 'children': []}, {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'for_statement', 'children': ['51', '52', '55']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'implicit'}, {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'if_statement', 'children': ['57', '62']}, {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'missing'}, {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'block', 'children': ['63', '67']}, {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '66', 'type': 'string', 'children': [], 'value': '"Implicit dependency `%s\' not found, needed by target `%s\'."'}, {'id': '67', 'type': 'raise_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': 'SCons'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'Errors'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'StopError'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}, {'id': '75', 'type': 'binary_operator', 'children': ['76', '77'], 'value': '%'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '77', 'type': 'tuple', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}, {'id': '81', 'type': 'assignment', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'binfo'}, {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'get_binfo'}, {'id': '89', 'type': 'argument_list', 'children': []}
def prepare(self): if self.depends is not None: for d in self.depends: if d.missing(): msg = "Explicit dependency `%s' not found, needed by target `%s'." raise SCons.Errors.StopError(msg % (d, self)) if self.implicit is not None: for i in self.implicit: if i.missing(): msg = "Implicit dependency `%s' not found, needed by target `%s'." raise SCons.Errors.StopError(msg % (i, self)) self.binfo = self.get_binfo()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scan'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6', '14', '20', '28', '34', '43', '51', '59', '125', '136', '144']}; {'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': 'implicit'}, {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}, {'id': '13', 'type': 'return_statement', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}, {'id': '15', 'type': 'assignment', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'implicit'}, {'id': '19', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}, {'id': '21', 'type': 'assignment', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'implicit_set'}, {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'set'}, {'id': '27', 'type': 'argument_list', 'children': []}; {'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': '_children_reset'}, {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'if_statement', 'children': ['35', '41']}, {'id': '35', 'type': 'not_operator', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}, {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'has_builder'}; {'id': '40', 'type': 'argument_list', 'children': []}, {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'return_statement', 'children': []}, {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'build_env'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}, {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'get_build_env'}; {'id': '50', 'type': 'argument_list', 'children': []}, {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'executor'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}, {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'get_executor'}; {'id': '58', 'type': 'argument_list', 'children': []}, {'id': '59', 'type': 'if_statement', 'children': ['60', '64']}; {'id': '60', 'type': 'boolean_operator', 'children': ['61', '62'], 'value': 'and'}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'implicit_cache'}; {'id': '62', 'type': 'not_operator', 'children': ['63']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'implicit_deps_changed'}; {'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': 'implicit'}; {'id': '68', 'type': 'call', 'children': ['69', '72']}, {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'get_stored_implicit'}; {'id': '72', 'type': 'argument_list', 'children': []}, {'id': '73', 'type': 'if_statement', 'children': ['74', '77']}; {'id': '74', 'type': 'comparison_operator', 'children': ['75', '76'], 'value': 'is'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'implicit'}; {'id': '76', 'type': 'None', 'children': []}, {'id': '77', 'type': 'block', 'children': ['78', '93', '103']}; {'id': '78', 'type': 'for_statement', 'children': ['79', '80', '85']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'tgt'}; {'id': '80', 'type': 'call', 'children': ['81', '84']}, {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'executor'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'get_all_targets'}; {'id': '84', 'type': 'argument_list', 'children': []}, {'id': '85', 'type': 'block', 'children': ['86']}; {'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': 'tgt'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'add_to_implicit'}, {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'implicit'}, {'id': '93', 'type': 'if_statement', 'children': ['94', '101']}; {'id': '94', 'type': 'boolean_operator', 'children': ['95', '96'], 'value': 'or'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'implicit_deps_unchanged'}; {'id': '96', 'type': 'call', 'children': ['97', '100']}, {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'is_up_to_date'}; {'id': '100', 'type': 'argument_list', 'children': []}, {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'return_statement', 'children': []}, {'id': '103', 'type': 'for_statement', 'children': ['104', '105', '110']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'tgt'}, {'id': '105', 'type': 'call', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'executor'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'get_all_targets'}, {'id': '109', 'type': 'argument_list', 'children': []}; {'id': '110', 'type': 'block', 'children': ['111', '117']}, {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'assignment', 'children': ['113', '116']}, {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'tgt'}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'implicit'}; {'id': '116', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'assignment', 'children': ['119', '122']}, {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'tgt'}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'implicit_set'}; {'id': '122', 'type': 'call', 'children': ['123', '124']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '124', 'type': 'argument_list', 'children': []}, {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'call', 'children': ['127', '130']}, {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'executor'}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'scan_sources'}; {'id': '130', 'type': 'argument_list', 'children': ['131']}, {'id': '131', 'type': 'attribute', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'builder'}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'source_scanner'}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}, {'id': '137', 'type': 'assignment', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'scanner'}, {'id': '139', 'type': 'call', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'get_target_scanner'}, {'id': '143', 'type': 'argument_list', 'children': []}; {'id': '144', 'type': 'if_statement', 'children': ['145', '146']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'scanner'}; {'id': '146', 'type': 'block', 'children': ['147']}, {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'call', 'children': ['149', '152']}, {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'executor'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'scan_targets'}; {'id': '152', 'type': 'argument_list', 'children': ['153']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'scanner'}
def scan(self): if self.implicit is not None: return self.implicit = [] self.implicit_set = set() self._children_reset() if not self.has_builder(): return build_env = self.get_build_env() executor = self.get_executor() if implicit_cache and not implicit_deps_changed: implicit = self.get_stored_implicit() if implicit is not None: for tgt in executor.get_all_targets(): tgt.add_to_implicit(implicit) if implicit_deps_unchanged or self.is_up_to_date(): return for tgt in executor.get_all_targets(): tgt.implicit = [] tgt.implicit_set = set() executor.scan_sources(self.builder.source_scanner) scanner = self.get_target_scanner() if scanner: executor.scan_targets(scanner)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_binfo'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6', '16', '24', '30', '38', '44', '77', '111', '117', '139', '155', '163', '183', '193', '213']}; {'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': 'binfo'}; {'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', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'binfo'}, {'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': 'new_binfo'}, {'id': '23', 'type': 'argument_list', 'children': []}; {'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': 'binfo'}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'binfo'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}, {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'executor'}, {'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': 'get_executor'}, {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}, {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ignore_set'}, {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'ignore_set'}; {'id': '44', 'type': 'if_statement', 'children': ['45', '50']}, {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'has_builder'}, {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'block', 'children': ['51', '60']}, {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '56']}, {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'binfo'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'bact'}; {'id': '56', 'type': 'call', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'executor'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}, {'id': '61', 'type': 'assignment', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'binfo'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'bactsig'}, {'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': 'SCons'}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'MD5signature'}, {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}, {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'executor'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'get_contents'}; {'id': '76', 'type': 'argument_list', 'children': []}, {'id': '77', 'type': 'if_statement', 'children': ['78', '81', '97']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': '_specific_sources'}, {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}, {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'sources'}, {'id': '85', 'type': 'list_comprehension', 'children': ['86', '87', '92']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '87', 'type': 'for_in_clause', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'sources'}; {'id': '92', 'type': 'if_clause', 'children': ['93']}, {'id': '93', 'type': 'not_operator', 'children': ['94']}; {'id': '94', 'type': 'comparison_operator', 'children': ['95', '96'], 'value': 'in'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'ignore_set'}, {'id': '97', 'type': 'else_clause', 'children': ['98']}; {'id': '98', 'type': 'block', 'children': ['99']}, {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '102']}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'sources'}; {'id': '102', 'type': 'call', 'children': ['103', '106']}, {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'executor'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'get_unignored_sources'}; {'id': '106', 'type': 'argument_list', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'ignore'}, {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'assignment', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'seen'}; {'id': '114', 'type': 'call', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '116', 'type': 'argument_list', 'children': []}, {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'assignment', 'children': ['119', '122']}, {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'binfo'}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'bsources'}; {'id': '122', 'type': 'list_comprehension', 'children': ['123', '124', '127']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '124', 'type': 'for_in_clause', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'sources'}, {'id': '127', 'type': 'if_clause', 'children': ['128']}; {'id': '128', 'type': 'boolean_operator', 'children': ['129', '132'], 'value': 'and'}, {'id': '129', 'type': 'comparison_operator', 'children': ['130', '131'], 'value': 'not'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'seen'}; {'id': '132', 'type': 'not_operator', 'children': ['133']}, {'id': '133', 'type': 'call', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'seen'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'add'}, {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'assignment', 'children': ['141', '144']}, {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'binfo'}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'bsourcesigs'}; {'id': '144', 'type': 'list_comprehension', 'children': ['145', '150']}, {'id': '145', 'type': 'call', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'get_ninfo'}, {'id': '149', 'type': 'argument_list', 'children': []}; {'id': '150', 'type': 'for_in_clause', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'binfo'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'bsources'}, {'id': '155', 'type': 'expression_statement', 'children': ['156']}; {'id': '156', 'type': 'assignment', 'children': ['157', '160']}, {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'binfo'}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'bdepends'}; {'id': '160', 'type': 'attribute', 'children': ['161', '162']}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'depends'}, {'id': '163', 'type': 'expression_statement', 'children': ['164']}; {'id': '164', 'type': 'assignment', 'children': ['165', '168']}, {'id': '165', 'type': 'attribute', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'binfo'}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'bdependsigs'}; {'id': '168', 'type': 'list_comprehension', 'children': ['169', '174', '179']}, {'id': '169', 'type': 'call', 'children': ['170', '173']}; {'id': '170', 'type': 'attribute', 'children': ['171', '172']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'get_ninfo'}, {'id': '173', 'type': 'argument_list', 'children': []}; {'id': '174', 'type': 'for_in_clause', 'children': ['175', '176']}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '176', 'type': 'attribute', 'children': ['177', '178']}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'depends'}, {'id': '179', 'type': 'if_clause', 'children': ['180']}; {'id': '180', 'type': 'comparison_operator', 'children': ['181', '182'], 'value': 'not'}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'ignore_set'}, {'id': '183', 'type': 'expression_statement', 'children': ['184']}; {'id': '184', 'type': 'assignment', 'children': ['185', '188']}, {'id': '185', 'type': 'attribute', 'children': ['186', '187']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'binfo'}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'bimplicit'}; {'id': '188', 'type': 'boolean_operator', 'children': ['189', '192'], 'value': 'or'}, {'id': '189', 'type': 'attribute', 'children': ['190', '191']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'implicit'}; {'id': '192', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '193', 'type': 'expression_statement', 'children': ['194']}; {'id': '194', 'type': 'assignment', 'children': ['195', '198']}, {'id': '195', 'type': 'attribute', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'binfo'}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'bimplicitsigs'}; {'id': '198', 'type': 'list_comprehension', 'children': ['199', '204', '209']}, {'id': '199', 'type': 'call', 'children': ['200', '203']}; {'id': '200', 'type': 'attribute', 'children': ['201', '202']}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'get_ninfo'}, {'id': '203', 'type': 'argument_list', 'children': []}; {'id': '204', 'type': 'for_in_clause', 'children': ['205', '206']}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '206', 'type': 'attribute', 'children': ['207', '208']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'binfo'}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'bimplicit'}, {'id': '209', 'type': 'if_clause', 'children': ['210']}; {'id': '210', 'type': 'comparison_operator', 'children': ['211', '212'], 'value': 'not'}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'ignore_set'}, {'id': '213', 'type': 'return_statement', 'children': ['214']}
def get_binfo(self): try: return self.binfo except AttributeError: pass binfo = self.new_binfo() self.binfo = binfo executor = self.get_executor() ignore_set = self.ignore_set if self.has_builder(): binfo.bact = str(executor) binfo.bactsig = SCons.Util.MD5signature(executor.get_contents()) if self._specific_sources: sources = [ s for s in self.sources if not s in ignore_set] else: sources = executor.get_unignored_sources(self, self.ignore) seen = set() binfo.bsources = [s for s in sources if s not in seen and not seen.add(s)] binfo.bsourcesigs = [s.get_ninfo() for s in binfo.bsources] binfo.bdepends = self.depends binfo.bdependsigs = [d.get_ninfo() for d in self.depends if d not in ignore_set] binfo.bimplicit = self.implicit or [] binfo.bimplicitsigs = [i.get_ninfo() for i in binfo.bimplicit if i not in ignore_set] return binfo
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '6', 'type': 'None', 'children': []}, {'id': '7', 'type': 'block', 'children': ['8', '23', '30', '36', '42', '46', '54', '89', '96', '104', '112', '120', '126', '134', '152', '156', '215', '230', '235', '361']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12']}, {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'is'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'argv'}, {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}, {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '16', 'type': 'subscript', 'children': ['17', '20']}, {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'sys'}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '20', 'type': 'slice', 'children': ['21', '22']}, {'id': '21', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '22', 'type': 'colon', 'children': []}, {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'parse_global_args'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'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': 'type_system'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'interactive'}, {'id': '35', 'type': 'True', 'children': []}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}, {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}, {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'timeout_thread'}, {'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': 'timeout_stop_event'}, {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'threading'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'Event'}, {'id': '53', 'type': 'argument_list', 'children': []}; {'id': '54', 'type': 'if_statement', 'children': ['55', '58']}, {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '58', 'type': 'block', 'children': ['59', '77', '83']}, {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'timeout_thread'}; {'id': '62', 'type': 'call', 'children': ['63', '66']}, {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'threading'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'Thread'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '70']}, {'id': '67', 'type': 'keyword_argument', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'timeout_thread_handler'}; {'id': '70', 'type': 'keyword_argument', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '72', 'type': 'tuple', 'children': ['73', '76']}, {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'timeout_stop_event'}, {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '82']}, {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'timeout_thread'}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'daemon'}; {'id': '82', 'type': 'True', 'children': []}, {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '88']}, {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'timeout_thread'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '88', 'type': 'argument_list', 'children': []}, {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'shell'}; {'id': '92', 'type': 'call', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'HierarchicalShell'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}, {'id': '95', 'type': 'string', 'children': [], 'value': "'iotile'"}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}, {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'shell'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'root_add'}, {'id': '101', 'type': 'argument_list', 'children': ['102', '103']}; {'id': '102', 'type': 'string', 'children': [], 'value': '"registry"'}, {'id': '103', 'type': 'string', 'children': [], 'value': '"iotile.core.dev.annotated_registry,registry"'}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}, {'id': '105', 'type': 'call', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'shell'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'root_add'}, {'id': '109', 'type': 'argument_list', 'children': ['110', '111']}; {'id': '110', 'type': 'string', 'children': [], 'value': '"config"'}, {'id': '111', 'type': 'string', 'children': [], 'value': '"iotile.core.dev.config,ConfigManager"'}; {'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': 'shell'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'root_add'}, {'id': '117', 'type': 'argument_list', 'children': ['118', '119']}; {'id': '118', 'type': 'string', 'children': [], 'value': "'hw'"}, {'id': '119', 'type': 'string', 'children': [], 'value': '"iotile.core.hw.hwmanager,HardwareManager"'}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}, {'id': '121', 'type': 'assignment', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'reg'}, {'id': '123', 'type': 'call', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'ComponentRegistry'}, {'id': '125', 'type': 'argument_list', 'children': []}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}, {'id': '127', 'type': 'assignment', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'plugins'}, {'id': '129', 'type': 'call', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'reg'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'list_plugins'}, {'id': '133', 'type': 'argument_list', 'children': []}; {'id': '134', 'type': 'for_statement', 'children': ['135', '138', '143']}, {'id': '135', 'type': 'pattern_list', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '138', 'type': 'call', 'children': ['139', '142']}, {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'plugins'}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '142', 'type': 'argument_list', 'children': []}, {'id': '143', 'type': 'block', 'children': ['144']}; {'id': '144', 'type': 'expression_statement', 'children': ['145']}, {'id': '145', 'type': 'call', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'shell'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'root_add'}, {'id': '149', 'type': 'argument_list', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '152', 'type': 'expression_statement', 'children': ['153']}, {'id': '153', 'type': 'assignment', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'finished'}, {'id': '155', 'type': 'False', 'children': []}; {'id': '156', 'type': 'try_statement', 'children': ['157', '175', '198']}, {'id': '157', 'type': 'block', 'children': ['158']}; {'id': '158', 'type': 'if_statement', 'children': ['159', '165']}, {'id': '159', 'type': 'comparison_operator', 'children': ['160', '164'], 'value': '>'}; {'id': '160', 'type': 'call', 'children': ['161', '162']}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '162', 'type': 'argument_list', 'children': ['163']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '164', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '165', 'type': 'block', 'children': ['166']}; {'id': '166', 'type': 'expression_statement', 'children': ['167']}, {'id': '167', 'type': 'assignment', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'finished'}, {'id': '169', 'type': 'call', 'children': ['170', '173']}; {'id': '170', 'type': 'attribute', 'children': ['171', '172']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'shell'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'invoke'}, {'id': '173', 'type': 'argument_list', 'children': ['174']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '175', 'type': 'except_clause', 'children': ['176', '180']}; {'id': '176', 'type': 'as_pattern', 'children': ['177', '178']}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'IOTileException'}; {'id': '178', 'type': 'as_pattern_target', 'children': ['179']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '180', 'type': 'block', 'children': ['181', '190', '196']}, {'id': '181', 'type': 'expression_statement', 'children': ['182']}; {'id': '182', 'type': 'call', 'children': ['183', '184']}, {'id': '183', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '184', 'type': 'argument_list', 'children': ['185']}, {'id': '185', 'type': 'call', 'children': ['186', '189']}; {'id': '186', 'type': 'attribute', 'children': ['187', '188']}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'format'}, {'id': '189', 'type': 'argument_list', 'children': []}; {'id': '190', 'type': 'expression_statement', 'children': ['191']}, {'id': '191', 'type': 'call', 'children': ['192', '195']}; {'id': '192', 'type': 'attribute', 'children': ['193', '194']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'SharedLoop'}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'stop'}, {'id': '195', 'type': 'argument_list', 'children': []}; {'id': '196', 'type': 'return_statement', 'children': ['197']}, {'id': '197', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '198', 'type': 'except_clause', 'children': ['199', '200']}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '200', 'type': 'block', 'children': ['201', '207', '213']}, {'id': '201', 'type': 'expression_statement', 'children': ['202']}; {'id': '202', 'type': 'call', 'children': ['203', '206']}, {'id': '203', 'type': 'attribute', 'children': ['204', '205']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'traceback'}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'print_exc'}; {'id': '206', 'type': 'argument_list', 'children': []}, {'id': '207', 'type': 'expression_statement', 'children': ['208']}; {'id': '208', 'type': 'call', 'children': ['209', '212']}, {'id': '209', 'type': 'attribute', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'SharedLoop'}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '212', 'type': 'argument_list', 'children': []}, {'id': '213', 'type': 'return_statement', 'children': ['214']}; {'id': '214', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '215', 'type': 'if_statement', 'children': ['216', '221']}; {'id': '216', 'type': 'boolean_operator', 'children': ['217', '220'], 'value': 'or'}, {'id': '217', 'type': 'attribute', 'children': ['218', '219']}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'quit'}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'finished'}, {'id': '221', 'type': 'block', 'children': ['222', '228']}; {'id': '222', 'type': 'expression_statement', 'children': ['223']}, {'id': '223', 'type': 'call', 'children': ['224', '227']}; {'id': '224', 'type': 'attribute', 'children': ['225', '226']}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'SharedLoop'}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'stop'}, {'id': '227', 'type': 'argument_list', 'children': []}; {'id': '228', 'type': 'return_statement', 'children': ['229']}, {'id': '229', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '230', 'type': 'expression_statement', 'children': ['231']}, {'id': '231', 'type': 'call', 'children': ['232', '233']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'setup_completion'}, {'id': '233', 'type': 'argument_list', 'children': ['234']}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'shell'}, {'id': '235', 'type': 'try_statement', 'children': ['236', '337', '345', '353']}; {'id': '236', 'type': 'block', 'children': ['237']}, {'id': '237', 'type': 'while_statement', 'children': ['238', '239']}; {'id': '238', 'type': 'True', 'children': []}, {'id': '239', 'type': 'block', 'children': ['240', '278', '329']}; {'id': '240', 'type': 'try_statement', 'children': ['241', '269']}, {'id': '241', 'type': 'block', 'children': ['242', '255']}; {'id': '242', 'type': 'expression_statement', 'children': ['243']}, {'id': '243', 'type': 'assignment', 'children': ['244', '245']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'linebuf'}, {'id': '245', 'type': 'call', 'children': ['246', '247']}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'input'}, {'id': '247', 'type': 'argument_list', 'children': ['248']}; {'id': '248', 'type': 'binary_operator', 'children': ['249', '250'], 'value': '%'}, {'id': '249', 'type': 'string', 'children': [], 'value': '"(%s) "'}; {'id': '250', 'type': 'call', 'children': ['251', '254']}, {'id': '251', 'type': 'attribute', 'children': ['252', '253']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'shell'}, {'id': '253', 'type': 'identifier', 'children': [], 'value': 'context_name'}; {'id': '254', 'type': 'argument_list', 'children': []}, {'id': '255', 'type': 'ERROR', 'children': ['256']}; {'id': '256', 'type': 'boolean_operator', 'children': ['257', '263'], 'value': 'and'}, {'id': '257', 'type': 'comparison_operator', 'children': ['258', '262'], 'value': '>'}; {'id': '258', 'type': 'call', 'children': ['259', '260']}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '260', 'type': 'argument_list', 'children': ['261']}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'linebuf'}; {'id': '262', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '263', 'type': 'comparison_operator', 'children': ['264', '267', '268'], 'value': '=='}; {'id': '264', 'type': 'subscript', 'children': ['265', '266']}, {'id': '265', 'type': 'identifier', 'children': [], 'value': 'linebuf'}; {'id': '266', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '267', 'type': 'ERROR', 'children': []}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'continue'}, {'id': '269', 'type': 'except_clause', 'children': ['270', '271']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'KeyboardInterrupt'}, {'id': '271', 'type': 'block', 'children': ['272', '277']}; {'id': '272', 'type': 'expression_statement', 'children': ['273']}, {'id': '273', 'type': 'call', 'children': ['274', '275']}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'print'}, {'id': '275', 'type': 'argument_list', 'children': ['276']}; {'id': '276', 'type': 'string', 'children': [], 'value': '""'}, {'id': '277', 'type': 'continue_statement', 'children': []}; {'id': '278', 'type': 'try_statement', 'children': ['279', '289', '305', '320']}, {'id': '279', 'type': 'block', 'children': ['280']}; {'id': '280', 'type': 'expression_statement', 'children': ['281']}, {'id': '281', 'type': 'assignment', 'children': ['282', '283']}; {'id': '282', 'type': 'identifier', 'children': [], 'value': 'finished'}, {'id': '283', 'type': 'call', 'children': ['284', '287']}; {'id': '284', 'type': 'attribute', 'children': ['285', '286']}, {'id': '285', 'type': 'identifier', 'children': [], 'value': 'shell'}; {'id': '286', 'type': 'identifier', 'children': [], 'value': 'invoke_string'}, {'id': '287', 'type': 'argument_list', 'children': ['288']}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'linebuf'}, {'id': '289', 'type': 'except_clause', 'children': ['290', '291']}; {'id': '290', 'type': 'identifier', 'children': [], 'value': 'KeyboardInterrupt'}, {'id': '291', 'type': 'block', 'children': ['292', '297']}; {'id': '292', 'type': 'expression_statement', 'children': ['293']}, {'id': '293', 'type': 'call', 'children': ['294', '295']}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'print'}, {'id': '295', 'type': 'argument_list', 'children': ['296']}; {'id': '296', 'type': 'string', 'children': [], 'value': '""'}, {'id': '297', 'type': 'if_statement', 'children': ['298', '303']}; {'id': '298', 'type': 'call', 'children': ['299', '302']}, {'id': '299', 'type': 'attribute', 'children': ['300', '301']}; {'id': '300', 'type': 'identifier', 'children': [], 'value': 'timeout_stop_event'}, {'id': '301', 'type': 'identifier', 'children': [], 'value': 'is_set'}; {'id': '302', 'type': 'argument_list', 'children': []}, {'id': '303', 'type': 'block', 'children': ['304']}; {'id': '304', 'type': 'break_statement', 'children': []}, {'id': '305', 'type': 'except_clause', 'children': ['306', '310']}; {'id': '306', 'type': 'as_pattern', 'children': ['307', '308']}, {'id': '307', 'type': 'identifier', 'children': [], 'value': 'IOTileException'}; {'id': '308', 'type': 'as_pattern_target', 'children': ['309']}, {'id': '309', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '310', 'type': 'block', 'children': ['311']}, {'id': '311', 'type': 'expression_statement', 'children': ['312']}; {'id': '312', 'type': 'call', 'children': ['313', '314']}, {'id': '313', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '314', 'type': 'argument_list', 'children': ['315']}, {'id': '315', 'type': 'call', 'children': ['316', '319']}; {'id': '316', 'type': 'attribute', 'children': ['317', '318']}, {'id': '317', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '318', 'type': 'identifier', 'children': [], 'value': 'format'}, {'id': '319', 'type': 'argument_list', 'children': []}; {'id': '320', 'type': 'except_clause', 'children': ['321', '322']}, {'id': '321', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '322', 'type': 'block', 'children': ['323']}, {'id': '323', 'type': 'expression_statement', 'children': ['324']}; {'id': '324', 'type': 'call', 'children': ['325', '328']}, {'id': '325', 'type': 'attribute', 'children': ['326', '327']}; {'id': '326', 'type': 'identifier', 'children': [], 'value': 'traceback'}, {'id': '327', 'type': 'identifier', 'children': [], 'value': 'print_exc'}; {'id': '328', 'type': 'argument_list', 'children': []}, {'id': '329', 'type': 'if_statement', 'children': ['330', '335']}; {'id': '330', 'type': 'call', 'children': ['331', '334']}, {'id': '331', 'type': 'attribute', 'children': ['332', '333']}; {'id': '332', 'type': 'identifier', 'children': [], 'value': 'shell'}, {'id': '333', 'type': 'identifier', 'children': [], 'value': 'finished'}; {'id': '334', 'type': 'argument_list', 'children': []}, {'id': '335', 'type': 'block', 'children': ['336']}; {'id': '336', 'type': 'break_statement', 'children': []}, {'id': '337', 'type': 'except_clause', 'children': ['338', '339']}; {'id': '338', 'type': 'identifier', 'children': [], 'value': 'EOFError'}, {'id': '339', 'type': 'block', 'children': ['340']}; {'id': '340', 'type': 'expression_statement', 'children': ['341']}, {'id': '341', 'type': 'call', 'children': ['342', '343']}; {'id': '342', 'type': 'identifier', 'children': [], 'value': 'print'}, {'id': '343', 'type': 'argument_list', 'children': ['344']}; {'id': '344', 'type': 'string', 'children': [], 'value': '""'}, {'id': '345', 'type': 'except_clause', 'children': ['346', '347']}; {'id': '346', 'type': 'identifier', 'children': [], 'value': 'KeyboardInterrupt'}, {'id': '347', 'type': 'block', 'children': ['348']}; {'id': '348', 'type': 'expression_statement', 'children': ['349']}, {'id': '349', 'type': 'call', 'children': ['350', '351']}; {'id': '350', 'type': 'identifier', 'children': [], 'value': 'print'}, {'id': '351', 'type': 'argument_list', 'children': ['352']}; {'id': '352', 'type': 'string', 'children': [], 'value': '""'}, {'id': '353', 'type': 'finally_clause', 'children': ['354']}; {'id': '354', 'type': 'block', 'children': ['355']}, {'id': '355', 'type': 'expression_statement', 'children': ['356']}; {'id': '356', 'type': 'call', 'children': ['357', '360']}, {'id': '357', 'type': 'attribute', 'children': ['358', '359']}; {'id': '358', 'type': 'identifier', 'children': [], 'value': 'SharedLoop'}, {'id': '359', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '360', 'type': 'argument_list', 'children': []}, {'id': '361', 'type': 'if_statement', 'children': ['362', '365']}; {'id': '362', 'type': 'comparison_operator', 'children': ['363', '364'], 'value': 'is'}, {'id': '363', 'type': 'identifier', 'children': [], 'value': 'timeout_thread'}; {'id': '364', 'type': 'None', 'children': []}, {'id': '365', 'type': 'block', 'children': ['366', '372']}; {'id': '366', 'type': 'expression_statement', 'children': ['367']}, {'id': '367', 'type': 'call', 'children': ['368', '371']}; {'id': '368', 'type': 'attribute', 'children': ['369', '370']}, {'id': '369', 'type': 'identifier', 'children': [], 'value': 'timeout_stop_event'}; {'id': '370', 'type': 'identifier', 'children': [], 'value': 'set'}, {'id': '371', 'type': 'argument_list', 'children': []}; {'id': '372', 'type': 'expression_statement', 'children': ['373']}, {'id': '373', 'type': 'call', 'children': ['374', '377']}; {'id': '374', 'type': 'attribute', 'children': ['375', '376']}, {'id': '375', 'type': 'identifier', 'children': [], 'value': 'timeout_thread'}; {'id': '376', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '377', 'type': 'argument_list', 'children': []}
def main(argv=None): if argv is None: argv = sys.argv[1:] args = parse_global_args(argv) type_system.interactive = True line = args.commands timeout_thread = None timeout_stop_event = threading.Event() if args.timeout: timeout_thread = threading.Thread(target=timeout_thread_handler, args=(args.timeout, timeout_stop_event)) timeout_thread.daemon = True timeout_thread.start() shell = HierarchicalShell('iotile') shell.root_add("registry", "iotile.core.dev.annotated_registry,registry") shell.root_add("config", "iotile.core.dev.config,ConfigManager") shell.root_add('hw', "iotile.core.hw.hwmanager,HardwareManager") reg = ComponentRegistry() plugins = reg.list_plugins() for key, val in plugins.items(): shell.root_add(key, val) finished = False try: if len(line) > 0: finished = shell.invoke(line) except IOTileException as exc: print(exc.format()) SharedLoop.stop() return 1 except Exception: traceback.print_exc() SharedLoop.stop() return 1 if args.quit or finished: SharedLoop.stop() return 0 setup_completion(shell) try: while True: try: linebuf = input("(%s) " % shell.context_name()) if len(linebuf) > 0 and linebuf[0] == ' continue except KeyboardInterrupt: print("") continue try: finished = shell.invoke_string(linebuf) except KeyboardInterrupt: print("") if timeout_stop_event.is_set(): break except IOTileException as exc: print(exc.format()) except Exception: traceback.print_exc() if shell.finished(): break except EOFError: print("") except KeyboardInterrupt: print("") finally: SharedLoop.stop() if timeout_thread is not None: timeout_stop_event.set() timeout_thread.join()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'DialectAddToEnv'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'suffixes'}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'ppsuffixes'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'support_module'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '11', 'type': 'block', 'children': ['12', '18', '33', '51', '62', '74', '87', '123', '159', '181', '205', '220', '235', '248']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}, {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ComputeFortranSuffixes'}, {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'suffixes'}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ppsuffixes'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}, {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'fscan'}, {'id': '21', 'type': 'call', 'children': ['22', '29']}; {'id': '22', 'type': 'attribute', 'children': ['23', '28']}, {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'Scanner'}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'Fortran'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'FortranScan'}, {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'binary_operator', 'children': ['31', '32'], 'value': '%'}, {'id': '31', 'type': 'string', 'children': [], 'value': '"%sPATH"'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '33', 'type': 'for_statement', 'children': ['34', '35', '38']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'suffix'}, {'id': '35', 'type': 'binary_operator', 'children': ['36', '37'], 'value': '+'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'suffixes'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ppsuffixes'}; {'id': '38', 'type': 'block', 'children': ['39']}, {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '48']}, {'id': '41', 'type': 'attribute', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}, {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'Tool'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'SourceFileScanner'}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'add_scanner'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'fscan'}, {'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': 'env'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'AppendUnique'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}, {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'FORTRANSUFFIXES'}, {'id': '59', 'type': 'binary_operator', 'children': ['60', '61'], 'value': '+'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'suffixes'}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'ppsuffixes'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}, {'id': '63', 'type': 'assignment', 'children': ['64', '69', '70']}; {'id': '64', 'type': 'pattern_list', 'children': ['65', '66', '67', '68']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'compaction'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'compppaction'}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'shcompaction'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'shcompppaction'}, {'id': '69', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'CreateDialectActions'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}, {'id': '75', 'type': 'assignment', 'children': ['76', '79']}; {'id': '76', 'type': 'pattern_list', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'static_obj'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'shared_obj'}, {'id': '79', 'type': 'call', 'children': ['80', '85']}; {'id': '80', 'type': 'attribute', 'children': ['81', '84']}, {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'Tool'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'createObjBuilders'}, {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '87', 'type': 'for_statement', 'children': ['88', '89', '90']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'suffix'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'suffixes'}; {'id': '90', 'type': 'block', 'children': ['91', '99', '107', '115']}, {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '96']}, {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'static_obj'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'add_action'}; {'id': '96', 'type': 'argument_list', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'compaction'}, {'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': 'shared_obj'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'add_action'}; {'id': '104', 'type': 'argument_list', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'shcompaction'}, {'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': 'static_obj'}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'add_emitter'}; {'id': '112', 'type': 'argument_list', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'FortranEmitter'}, {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '120']}, {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'shared_obj'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'add_emitter'}; {'id': '120', 'type': 'argument_list', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'ShFortranEmitter'}, {'id': '123', 'type': 'for_statement', 'children': ['124', '125', '126']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'suffix'}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'ppsuffixes'}; {'id': '126', 'type': 'block', 'children': ['127', '135', '143', '151']}, {'id': '127', 'type': 'expression_statement', 'children': ['128']}; {'id': '128', 'type': 'call', 'children': ['129', '132']}, {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'static_obj'}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'add_action'}; {'id': '132', 'type': 'argument_list', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'compppaction'}, {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'call', 'children': ['137', '140']}, {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'shared_obj'}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'add_action'}; {'id': '140', 'type': 'argument_list', 'children': ['141', '142']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'shcompppaction'}, {'id': '143', 'type': 'expression_statement', 'children': ['144']}; {'id': '144', 'type': 'call', 'children': ['145', '148']}, {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'static_obj'}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'add_emitter'}; {'id': '148', 'type': 'argument_list', 'children': ['149', '150']}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'FortranEmitter'}, {'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': 'shared_obj'}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'add_emitter'}; {'id': '156', 'type': 'argument_list', 'children': ['157', '158']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'ShFortranEmitter'}, {'id': '159', 'type': 'if_statement', 'children': ['160', '165']}; {'id': '160', 'type': 'comparison_operator', 'children': ['161', '164'], 'value': 'not'}, {'id': '161', 'type': 'binary_operator', 'children': ['162', '163'], 'value': '%'}; {'id': '162', 'type': 'string', 'children': [], 'value': "'%sFLAGS'"}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '165', 'type': 'block', 'children': ['166']}; {'id': '166', 'type': 'expression_statement', 'children': ['167']}, {'id': '167', 'type': 'assignment', 'children': ['168', '173']}; {'id': '168', 'type': 'subscript', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '170', 'type': 'binary_operator', 'children': ['171', '172'], 'value': '%'}, {'id': '171', 'type': 'string', 'children': [], 'value': "'%sFLAGS'"}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '173', 'type': 'call', 'children': ['174', '179']}; {'id': '174', 'type': 'attribute', 'children': ['175', '178']}, {'id': '175', 'type': 'attribute', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'CLVar'}, {'id': '179', 'type': 'argument_list', 'children': ['180']}; {'id': '180', 'type': 'string', 'children': [], 'value': "''"}, {'id': '181', 'type': 'if_statement', 'children': ['182', '187']}; {'id': '182', 'type': 'comparison_operator', 'children': ['183', '186'], 'value': 'not'}, {'id': '183', 'type': 'binary_operator', 'children': ['184', '185'], 'value': '%'}; {'id': '184', 'type': 'string', 'children': [], 'value': "'SH%sFLAGS'"}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '187', 'type': 'block', 'children': ['188']}; {'id': '188', 'type': 'expression_statement', 'children': ['189']}, {'id': '189', 'type': 'assignment', 'children': ['190', '195']}; {'id': '190', 'type': 'subscript', 'children': ['191', '192']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '192', 'type': 'binary_operator', 'children': ['193', '194'], 'value': '%'}, {'id': '193', 'type': 'string', 'children': [], 'value': "'SH%sFLAGS'"}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '195', 'type': 'call', 'children': ['196', '201']}; {'id': '196', 'type': 'attribute', 'children': ['197', '200']}, {'id': '197', 'type': 'attribute', 'children': ['198', '199']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'CLVar'}, {'id': '201', 'type': 'argument_list', 'children': ['202']}; {'id': '202', 'type': 'binary_operator', 'children': ['203', '204'], 'value': '%'}, {'id': '203', 'type': 'string', 'children': [], 'value': "'$%sFLAGS'"}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '205', 'type': 'if_statement', 'children': ['206', '211']}; {'id': '206', 'type': 'comparison_operator', 'children': ['207', '210'], 'value': 'not'}, {'id': '207', 'type': 'binary_operator', 'children': ['208', '209'], 'value': '%'}; {'id': '208', 'type': 'string', 'children': [], 'value': "'INC%sPREFIX'"}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '211', 'type': 'block', 'children': ['212']}; {'id': '212', 'type': 'expression_statement', 'children': ['213']}, {'id': '213', 'type': 'assignment', 'children': ['214', '219']}; {'id': '214', 'type': 'subscript', 'children': ['215', '216']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '216', 'type': 'binary_operator', 'children': ['217', '218'], 'value': '%'}, {'id': '217', 'type': 'string', 'children': [], 'value': "'INC%sPREFIX'"}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '219', 'type': 'string', 'children': [], 'value': "'$INCPREFIX'"}; {'id': '220', 'type': 'if_statement', 'children': ['221', '226']}, {'id': '221', 'type': 'comparison_operator', 'children': ['222', '225'], 'value': 'not'}; {'id': '222', 'type': 'binary_operator', 'children': ['223', '224'], 'value': '%'}, {'id': '223', 'type': 'string', 'children': [], 'value': "'INC%sSUFFIX'"}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '226', 'type': 'block', 'children': ['227']}, {'id': '227', 'type': 'expression_statement', 'children': ['228']}; {'id': '228', 'type': 'assignment', 'children': ['229', '234']}, {'id': '229', 'type': 'subscript', 'children': ['230', '231']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '231', 'type': 'binary_operator', 'children': ['232', '233'], 'value': '%'}; {'id': '232', 'type': 'string', 'children': [], 'value': "'INC%sSUFFIX'"}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '234', 'type': 'string', 'children': [], 'value': "'$INCSUFFIX'"}, {'id': '235', 'type': 'expression_statement', 'children': ['236']}; {'id': '236', 'type': 'assignment', 'children': ['237', '242']}, {'id': '237', 'type': 'subscript', 'children': ['238', '239']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '239', 'type': 'binary_operator', 'children': ['240', '241'], 'value': '%'}; {'id': '240', 'type': 'string', 'children': [], 'value': "'_%sINCFLAGS'"}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '242', 'type': 'binary_operator', 'children': ['243', '244'], 'value': '%'}, {'id': '243', 'type': 'string', 'children': [], 'value': "'$( ${_concat(INC%sPREFIX, %sPATH, INC%sSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'"}; {'id': '244', 'type': 'tuple', 'children': ['245', '246', '247']}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '248', 'type': 'if_statement', 'children': ['249', '252', '305']}, {'id': '249', 'type': 'comparison_operator', 'children': ['250', '251'], 'value': '=='}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'support_module'}, {'id': '251', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '252', 'type': 'block', 'children': ['253', '266', '279', '292']}, {'id': '253', 'type': 'expression_statement', 'children': ['254']}; {'id': '254', 'type': 'assignment', 'children': ['255', '260']}, {'id': '255', 'type': 'subscript', 'children': ['256', '257']}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '257', 'type': 'binary_operator', 'children': ['258', '259'], 'value': '%'}; {'id': '258', 'type': 'string', 'children': [], 'value': "'%sCOM'"}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '260', 'type': 'binary_operator', 'children': ['261', '262'], 'value': '%'}, {'id': '261', 'type': 'string', 'children': [], 'value': "'$%s -o $TARGET -c $%sFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES'"}; {'id': '262', 'type': 'tuple', 'children': ['263', '264', '265']}, {'id': '263', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '265', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '266', 'type': 'expression_statement', 'children': ['267']}, {'id': '267', 'type': 'assignment', 'children': ['268', '273']}; {'id': '268', 'type': 'subscript', 'children': ['269', '270']}, {'id': '269', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '270', 'type': 'binary_operator', 'children': ['271', '272'], 'value': '%'}, {'id': '271', 'type': 'string', 'children': [], 'value': "'%sPPCOM'"}; {'id': '272', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '273', 'type': 'binary_operator', 'children': ['274', '275'], 'value': '%'}; {'id': '274', 'type': 'string', 'children': [], 'value': "'$%s -o $TARGET -c $%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES'"}, {'id': '275', 'type': 'tuple', 'children': ['276', '277', '278']}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '277', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '279', 'type': 'expression_statement', 'children': ['280']}; {'id': '280', 'type': 'assignment', 'children': ['281', '286']}, {'id': '281', 'type': 'subscript', 'children': ['282', '283']}; {'id': '282', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '283', 'type': 'binary_operator', 'children': ['284', '285'], 'value': '%'}; {'id': '284', 'type': 'string', 'children': [], 'value': "'SH%sCOM'"}, {'id': '285', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '286', 'type': 'binary_operator', 'children': ['287', '288'], 'value': '%'}, {'id': '287', 'type': 'string', 'children': [], 'value': "'$SH%s -o $TARGET -c $SH%sFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES'"}; {'id': '288', 'type': 'tuple', 'children': ['289', '290', '291']}, {'id': '289', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '290', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '291', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '292', 'type': 'expression_statement', 'children': ['293']}, {'id': '293', 'type': 'assignment', 'children': ['294', '299']}; {'id': '294', 'type': 'subscript', 'children': ['295', '296']}, {'id': '295', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '296', 'type': 'binary_operator', 'children': ['297', '298'], 'value': '%'}, {'id': '297', 'type': 'string', 'children': [], 'value': "'SH%sPPCOM'"}; {'id': '298', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '299', 'type': 'binary_operator', 'children': ['300', '301'], 'value': '%'}; {'id': '300', 'type': 'string', 'children': [], 'value': "'$SH%s -o $TARGET -c $SH%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES'"}, {'id': '301', 'type': 'tuple', 'children': ['302', '303', '304']}; {'id': '302', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '303', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '304', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '305', 'type': 'else_clause', 'children': ['306']}; {'id': '306', 'type': 'block', 'children': ['307', '320', '333', '346']}, {'id': '307', 'type': 'expression_statement', 'children': ['308']}; {'id': '308', 'type': 'assignment', 'children': ['309', '314']}, {'id': '309', 'type': 'subscript', 'children': ['310', '311']}; {'id': '310', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '311', 'type': 'binary_operator', 'children': ['312', '313'], 'value': '%'}; {'id': '312', 'type': 'string', 'children': [], 'value': "'%sCOM'"}, {'id': '313', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '314', 'type': 'binary_operator', 'children': ['315', '316'], 'value': '%'}, {'id': '315', 'type': 'string', 'children': [], 'value': "'$%s -o $TARGET -c $%sFLAGS $_%sINCFLAGS $SOURCES'"}; {'id': '316', 'type': 'tuple', 'children': ['317', '318', '319']}, {'id': '317', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '318', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '319', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '320', 'type': 'expression_statement', 'children': ['321']}, {'id': '321', 'type': 'assignment', 'children': ['322', '327']}; {'id': '322', 'type': 'subscript', 'children': ['323', '324']}, {'id': '323', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '324', 'type': 'binary_operator', 'children': ['325', '326'], 'value': '%'}, {'id': '325', 'type': 'string', 'children': [], 'value': "'%sPPCOM'"}; {'id': '326', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '327', 'type': 'binary_operator', 'children': ['328', '329'], 'value': '%'}; {'id': '328', 'type': 'string', 'children': [], 'value': "'$%s -o $TARGET -c $%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $SOURCES'"}, {'id': '329', 'type': 'tuple', 'children': ['330', '331', '332']}; {'id': '330', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '331', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '332', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '333', 'type': 'expression_statement', 'children': ['334']}; {'id': '334', 'type': 'assignment', 'children': ['335', '340']}, {'id': '335', 'type': 'subscript', 'children': ['336', '337']}; {'id': '336', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '337', 'type': 'binary_operator', 'children': ['338', '339'], 'value': '%'}; {'id': '338', 'type': 'string', 'children': [], 'value': "'SH%sCOM'"}, {'id': '339', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '340', 'type': 'binary_operator', 'children': ['341', '342'], 'value': '%'}, {'id': '341', 'type': 'string', 'children': [], 'value': "'$SH%s -o $TARGET -c $SH%sFLAGS $_%sINCFLAGS $SOURCES'"}; {'id': '342', 'type': 'tuple', 'children': ['343', '344', '345']}, {'id': '343', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '344', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '345', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '346', 'type': 'expression_statement', 'children': ['347']}, {'id': '347', 'type': 'assignment', 'children': ['348', '353']}; {'id': '348', 'type': 'subscript', 'children': ['349', '350']}, {'id': '349', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '350', 'type': 'binary_operator', 'children': ['351', '352'], 'value': '%'}, {'id': '351', 'type': 'string', 'children': [], 'value': "'SH%sPPCOM'"}; {'id': '352', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '353', 'type': 'binary_operator', 'children': ['354', '355'], 'value': '%'}; {'id': '354', 'type': 'string', 'children': [], 'value': "'$SH%s -o $TARGET -c $SH%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $SOURCES'"}, {'id': '355', 'type': 'tuple', 'children': ['356', '357', '358']}; {'id': '356', 'type': 'identifier', 'children': [], 'value': 'dialect'}, {'id': '357', 'type': 'identifier', 'children': [], 'value': 'dialect'}
def DialectAddToEnv(env, dialect, suffixes, ppsuffixes, support_module = 0): ComputeFortranSuffixes(suffixes, ppsuffixes) fscan = SCons.Scanner.Fortran.FortranScan("%sPATH" % dialect) for suffix in suffixes + ppsuffixes: SCons.Tool.SourceFileScanner.add_scanner(suffix, fscan) env.AppendUnique(FORTRANSUFFIXES = suffixes + ppsuffixes) compaction, compppaction, shcompaction, shcompppaction = \ CreateDialectActions(dialect) static_obj, shared_obj = SCons.Tool.createObjBuilders(env) for suffix in suffixes: static_obj.add_action(suffix, compaction) shared_obj.add_action(suffix, shcompaction) static_obj.add_emitter(suffix, FortranEmitter) shared_obj.add_emitter(suffix, ShFortranEmitter) for suffix in ppsuffixes: static_obj.add_action(suffix, compppaction) shared_obj.add_action(suffix, shcompppaction) static_obj.add_emitter(suffix, FortranEmitter) shared_obj.add_emitter(suffix, ShFortranEmitter) if '%sFLAGS' % dialect not in env: env['%sFLAGS' % dialect] = SCons.Util.CLVar('') if 'SH%sFLAGS' % dialect not in env: env['SH%sFLAGS' % dialect] = SCons.Util.CLVar('$%sFLAGS' % dialect) if 'INC%sPREFIX' % dialect not in env: env['INC%sPREFIX' % dialect] = '$INCPREFIX' if 'INC%sSUFFIX' % dialect not in env: env['INC%sSUFFIX' % dialect] = '$INCSUFFIX' env['_%sINCFLAGS' % dialect] = '$( ${_concat(INC%sPREFIX, %sPATH, INC%sSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)' % (dialect, dialect, dialect) if support_module == 1: env['%sCOM' % dialect] = '$%s -o $TARGET -c $%sFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES' % (dialect, dialect, dialect) env['%sPPCOM' % dialect] = '$%s -o $TARGET -c $%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES' % (dialect, dialect, dialect) env['SH%sCOM' % dialect] = '$SH%s -o $TARGET -c $SH%sFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES' % (dialect, dialect, dialect) env['SH%sPPCOM' % dialect] = '$SH%s -o $TARGET -c $SH%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES' % (dialect, dialect, dialect) else: env['%sCOM' % dialect] = '$%s -o $TARGET -c $%sFLAGS $_%sINCFLAGS $SOURCES' % (dialect, dialect, dialect) env['%sPPCOM' % dialect] = '$%s -o $TARGET -c $%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $SOURCES' % (dialect, dialect, dialect) env['SH%sCOM' % dialect] = '$SH%s -o $TARGET -c $SH%sFLAGS $_%sINCFLAGS $SOURCES' % (dialect, dialect, dialect) env['SH%sPPCOM' % dialect] = '$SH%s -o $TARGET -c $SH%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $SOURCES' % (dialect, dialect, dialect)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'MergeFlags'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'unique'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'dict'}, {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '22', '42', '56', '203']}, {'id': '13', 'type': 'if_statement', 'children': ['14', '17']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '16'], 'value': 'is'}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '16', 'type': 'None', 'children': []}, {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}, {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'dict'}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'if_statement', 'children': ['23', '32']}, {'id': '23', 'type': 'not_operator', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '30']}, {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Util'}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'is_Dict'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '32', 'type': 'block', 'children': ['33']}, {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}, {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ParseFlags'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '45']}, {'id': '43', 'type': 'not_operator', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'unique'}, {'id': '45', 'type': 'block', 'children': ['46', '54']}; {'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': 'Append'}, {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'dictionary_splat', 'children': ['53']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '54', 'type': 'return_statement', 'children': ['55']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'for_statement', 'children': ['57', '60', '65']}, {'id': '57', 'type': 'pattern_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '60', 'type': 'call', 'children': ['61', '64']}, {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '64', 'type': 'argument_list', 'children': []}, {'id': '65', 'type': 'block', 'children': ['66', '71', '142', '146', '197']}; {'id': '66', 'type': 'if_statement', 'children': ['67', '69']}, {'id': '67', 'type': 'not_operator', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'continue_statement', 'children': []}, {'id': '71', 'type': 'try_statement', 'children': ['72', '79', '86']}; {'id': '72', 'type': 'block', 'children': ['73']}, {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '76', 'type': 'subscript', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '79', 'type': 'except_clause', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'KeyError'}, {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}, {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '86', 'type': 'else_clause', 'children': ['87']}, {'id': '87', 'type': 'block', 'children': ['88']}; {'id': '88', 'type': 'if_statement', 'children': ['89', '91', '96']}, {'id': '89', 'type': 'not_operator', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'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': 'orig'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '96', 'type': 'elif_clause', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '98', 'type': 'block', 'children': ['99']}, {'id': '99', 'type': 'try_statement', 'children': ['100', '107']}; {'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': 'orig'}; {'id': '104', 'type': 'binary_operator', 'children': ['105', '106'], 'value': '+'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '107', 'type': 'except_clause', 'children': ['108', '111']}; {'id': '108', 'type': 'tuple', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'TypeError'}, {'id': '111', 'type': 'block', 'children': ['112']}; {'id': '112', 'type': 'try_statement', 'children': ['113', '120', '135']}, {'id': '113', 'type': 'block', 'children': ['114']}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}, {'id': '115', 'type': 'assignment', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'add_to_orig'}, {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '120', 'type': 'except_clause', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '122', 'type': 'block', 'children': ['123', '131']}, {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '128']}, {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '128', 'type': 'argument_list', 'children': ['129', '130']}, {'id': '129', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'assignment', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '135', 'type': 'else_clause', 'children': ['136']}; {'id': '136', 'type': 'block', 'children': ['137']}, {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '140']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'add_to_orig'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '142', 'type': 'expression_statement', 'children': ['143']}, {'id': '143', 'type': 'assignment', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '145', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '146', 'type': 'if_statement', 'children': ['147', '155', '172']}, {'id': '147', 'type': 'comparison_operator', 'children': ['148', '154'], 'value': '=='}; {'id': '148', 'type': 'subscript', 'children': ['149', '150']}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '150', 'type': 'slice', 'children': ['151', '153']}, {'id': '151', 'type': 'unary_operator', 'children': ['152'], 'value': '-'}; {'id': '152', 'type': 'integer', 'children': [], 'value': '4'}, {'id': '153', 'type': 'colon', 'children': []}; {'id': '154', 'type': 'string', 'children': [], 'value': "'PATH'"}, {'id': '155', 'type': 'block', 'children': ['156']}; {'id': '156', 'type': 'for_statement', 'children': ['157', '158', '159']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '159', 'type': 'block', 'children': ['160']}; {'id': '160', 'type': 'if_statement', 'children': ['161', '164']}, {'id': '161', 'type': 'comparison_operator', 'children': ['162', '163'], 'value': 'not'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '164', 'type': 'block', 'children': ['165']}, {'id': '165', 'type': 'expression_statement', 'children': ['166']}; {'id': '166', 'type': 'call', 'children': ['167', '170']}, {'id': '167', 'type': 'attribute', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '170', 'type': 'argument_list', 'children': ['171']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '172', 'type': 'else_clause', 'children': ['173']}, {'id': '173', 'type': 'block', 'children': ['174', '180']}; {'id': '174', 'type': 'expression_statement', 'children': ['175']}, {'id': '175', 'type': 'call', 'children': ['176', '179']}; {'id': '176', 'type': 'attribute', 'children': ['177', '178']}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'reverse'}, {'id': '179', 'type': 'argument_list', 'children': []}; {'id': '180', 'type': 'for_statement', 'children': ['181', '182', '183']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '183', 'type': 'block', 'children': ['184']}; {'id': '184', 'type': 'if_statement', 'children': ['185', '188']}, {'id': '185', 'type': 'comparison_operator', 'children': ['186', '187'], 'value': 'not'}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '188', 'type': 'block', 'children': ['189']}, {'id': '189', 'type': 'expression_statement', 'children': ['190']}; {'id': '190', 'type': 'call', 'children': ['191', '194']}, {'id': '191', 'type': 'attribute', 'children': ['192', '193']}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '194', 'type': 'argument_list', 'children': ['195', '196']}, {'id': '195', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '197', 'type': 'expression_statement', 'children': ['198']}; {'id': '198', 'type': 'assignment', 'children': ['199', '202']}, {'id': '199', 'type': 'subscript', 'children': ['200', '201']}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '203', 'type': 'return_statement', 'children': ['204']}
def MergeFlags(self, args, unique=1, dict=None): if dict is None: dict = self if not SCons.Util.is_Dict(args): args = self.ParseFlags(args) if not unique: self.Append(**args) return self for key, value in args.items(): if not value: continue try: orig = self[key] except KeyError: orig = value else: if not orig: orig = value elif value: try: orig = orig + value except (KeyError, TypeError): try: add_to_orig = orig.append except AttributeError: value.insert(0, orig) orig = value else: add_to_orig(value) t = [] if key[-4:] == 'PATH': for v in orig: if v not in t: t.append(v) else: orig.reverse() for v in orig: if v not in t: t.insert(0, v) self[key] = t return self
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Append'}, {'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': 'kw'}, {'id': '7', 'type': 'block', 'children': ['8', '15', '304']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}, {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'copy_non_reserved_keywords'}, {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '15', 'type': 'for_statement', 'children': ['16', '19', '24']}; {'id': '16', 'type': 'pattern_list', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'items'}, {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'block', 'children': ['25']}, {'id': '25', 'type': 'try_statement', 'children': ['26', '66', '102']}; {'id': '26', 'type': 'block', 'children': ['27', '58']}, {'id': '27', 'type': 'if_statement', 'children': ['28', '44']}; {'id': '28', 'type': 'boolean_operator', 'children': ['29', '32'], 'value': 'and'}, {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': '=='}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '31', 'type': 'string', 'children': [], 'value': "'CPPDEFINES'"}; {'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': 'SCons'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'Util'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'is_String'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}, {'id': '39', 'type': 'subscript', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '_dict'}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '44', 'type': 'block', 'children': ['45']}, {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '52']}, {'id': '47', 'type': 'subscript', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': '_dict'}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '52', 'type': 'list', 'children': ['53'], 'value': '[self._dict[key]]'}, {'id': '53', 'type': 'subscript', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_dict'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}, {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '61', 'type': 'subscript', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '_dict'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '66', 'type': 'except_clause', 'children': ['67', '68']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '68', 'type': 'block', 'children': ['69']}, {'id': '69', 'type': 'if_statement', 'children': ['70', '82', '92']}; {'id': '70', 'type': 'boolean_operator', 'children': ['71', '74'], 'value': 'and'}, {'id': '71', 'type': 'comparison_operator', 'children': ['72', '73'], 'value': '=='}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '73', 'type': 'string', 'children': [], 'value': "'CPPDEFINES'"}; {'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': 'SCons'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'Util'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'is_String'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '82', 'type': 'block', 'children': ['83']}, {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '90']}, {'id': '85', 'type': 'subscript', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': '_dict'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '90', 'type': 'list', 'children': ['91'], 'value': '[val]'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '92', 'type': 'else_clause', 'children': ['93']}, {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}, {'id': '95', 'type': 'assignment', 'children': ['96', '101']}; {'id': '96', 'type': 'subscript', 'children': ['97', '100']}, {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '99', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '102', 'type': 'else_clause', 'children': ['103']}, {'id': '103', 'type': 'block', 'children': ['104']}; {'id': '104', 'type': 'try_statement', 'children': ['105', '112', '172']}, {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}, {'id': '107', 'type': 'assignment', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'update_dict'}, {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '112', 'type': 'except_clause', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '114', 'type': 'block', 'children': ['115']}, {'id': '115', 'type': 'try_statement', 'children': ['116', '127']}; {'id': '116', 'type': 'block', 'children': ['117']}, {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'assignment', 'children': ['119', '124']}, {'id': '119', 'type': 'subscript', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': '_dict'}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '124', 'type': 'binary_operator', 'children': ['125', '126'], 'value': '+'}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '127', 'type': 'except_clause', 'children': ['128', '131']}; {'id': '128', 'type': 'tuple', 'children': ['129', '130']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'TypeError'}, {'id': '131', 'type': 'block', 'children': ['132']}; {'id': '132', 'type': 'try_statement', 'children': ['133', '140', '162']}, {'id': '133', 'type': 'block', 'children': ['134']}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}, {'id': '135', 'type': 'assignment', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'add_to_orig'}, {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '140', 'type': 'except_clause', 'children': ['141', '142']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '142', 'type': 'block', 'children': ['143', '154']}, {'id': '143', 'type': 'if_statement', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '145', 'type': 'block', 'children': ['146']}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}, {'id': '147', 'type': 'call', 'children': ['148', '151']}; {'id': '148', 'type': 'attribute', 'children': ['149', '150']}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'insert'}, {'id': '151', 'type': 'argument_list', 'children': ['152', '153']}; {'id': '152', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '154', 'type': 'expression_statement', 'children': ['155']}, {'id': '155', 'type': 'assignment', 'children': ['156', '161']}; {'id': '156', 'type': 'subscript', 'children': ['157', '160']}, {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '159', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '162', 'type': 'else_clause', 'children': ['163']}, {'id': '163', 'type': 'block', 'children': ['164']}; {'id': '164', 'type': 'if_statement', 'children': ['165', '166']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '166', 'type': 'block', 'children': ['167']}, {'id': '167', 'type': 'expression_statement', 'children': ['168']}; {'id': '168', 'type': 'call', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'add_to_orig'}; {'id': '170', 'type': 'argument_list', 'children': ['171']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '172', 'type': 'else_clause', 'children': ['173']}, {'id': '173', 'type': 'block', 'children': ['174']}; {'id': '174', 'type': 'if_statement', 'children': ['175', '183', '255']}, {'id': '175', 'type': 'call', 'children': ['176', '181']}; {'id': '176', 'type': 'attribute', 'children': ['177', '180']}, {'id': '177', 'type': 'attribute', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'is_List'}, {'id': '181', 'type': 'argument_list', 'children': ['182']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '183', 'type': 'block', 'children': ['184']}; {'id': '184', 'type': 'if_statement', 'children': ['185', '188', '243']}, {'id': '185', 'type': 'comparison_operator', 'children': ['186', '187'], 'value': '=='}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '187', 'type': 'string', 'children': [], 'value': "'CPPDEFINES'"}; {'id': '188', 'type': 'block', 'children': ['189', '193', '227', '231', '235']}, {'id': '189', 'type': 'expression_statement', 'children': ['190']}; {'id': '190', 'type': 'assignment', 'children': ['191', '192']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'tmp'}; {'id': '192', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '193', 'type': 'for_statement', 'children': ['194', '197', '202']}; {'id': '194', 'type': 'tuple_pattern', 'children': ['195', '196']}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '197', 'type': 'call', 'children': ['198', '201']}; {'id': '198', 'type': 'attribute', 'children': ['199', '200']}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'items'}, {'id': '201', 'type': 'argument_list', 'children': []}; {'id': '202', 'type': 'block', 'children': ['203']}, {'id': '203', 'type': 'if_statement', 'children': ['204', '207', '217']}; {'id': '204', 'type': 'comparison_operator', 'children': ['205', '206'], 'value': 'is'}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '206', 'type': 'None', 'children': []}, {'id': '207', 'type': 'block', 'children': ['208']}; {'id': '208', 'type': 'expression_statement', 'children': ['209']}, {'id': '209', 'type': 'call', 'children': ['210', '213']}; {'id': '210', 'type': 'attribute', 'children': ['211', '212']}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'tmp'}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '213', 'type': 'argument_list', 'children': ['214']}; {'id': '214', 'type': 'tuple', 'children': ['215', '216']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '217', 'type': 'else_clause', 'children': ['218']}; {'id': '218', 'type': 'block', 'children': ['219']}, {'id': '219', 'type': 'expression_statement', 'children': ['220']}; {'id': '220', 'type': 'call', 'children': ['221', '224']}, {'id': '221', 'type': 'attribute', 'children': ['222', '223']}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'tmp'}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '224', 'type': 'argument_list', 'children': ['225']}, {'id': '225', 'type': 'tuple', 'children': ['226']}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'k'}, {'id': '227', 'type': 'expression_statement', 'children': ['228']}; {'id': '228', 'type': 'assignment', 'children': ['229', '230']}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'tmp'}, {'id': '231', 'type': 'expression_statement', 'children': ['232']}; {'id': '232', 'type': 'augmented_assignment', 'children': ['233', '234'], 'value': '+='}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '235', 'type': 'expression_statement', 'children': ['236']}; {'id': '236', 'type': 'assignment', 'children': ['237', '242']}, {'id': '237', 'type': 'subscript', 'children': ['238', '241']}; {'id': '238', 'type': 'attribute', 'children': ['239', '240']}, {'id': '239', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '240', 'type': 'identifier', 'children': [], 'value': '_dict'}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '243', 'type': 'else_clause', 'children': ['244']}; {'id': '244', 'type': 'block', 'children': ['245']}, {'id': '245', 'type': 'for_statement', 'children': ['246', '247', '248']}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '248', 'type': 'block', 'children': ['249']}, {'id': '249', 'type': 'expression_statement', 'children': ['250']}; {'id': '250', 'type': 'assignment', 'children': ['251', '254']}, {'id': '251', 'type': 'subscript', 'children': ['252', '253']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '253', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '254', 'type': 'None', 'children': []}, {'id': '255', 'type': 'else_clause', 'children': ['256']}; {'id': '256', 'type': 'block', 'children': ['257']}, {'id': '257', 'type': 'try_statement', 'children': ['258', '264']}; {'id': '258', 'type': 'block', 'children': ['259']}, {'id': '259', 'type': 'expression_statement', 'children': ['260']}; {'id': '260', 'type': 'call', 'children': ['261', '262']}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'update_dict'}; {'id': '262', 'type': 'argument_list', 'children': ['263']}, {'id': '263', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '264', 'type': 'except_clause', 'children': ['265', '269']}, {'id': '265', 'type': 'tuple', 'children': ['266', '267', '268']}; {'id': '266', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '269', 'type': 'block', 'children': ['270']}; {'id': '270', 'type': 'if_statement', 'children': ['271', '279', '296']}, {'id': '271', 'type': 'call', 'children': ['272', '277']}; {'id': '272', 'type': 'attribute', 'children': ['273', '276']}, {'id': '273', 'type': 'attribute', 'children': ['274', '275']}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'is_Dict'}, {'id': '277', 'type': 'argument_list', 'children': ['278']}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '279', 'type': 'block', 'children': ['280']}; {'id': '280', 'type': 'for_statement', 'children': ['281', '284', '289']}, {'id': '281', 'type': 'pattern_list', 'children': ['282', '283']}; {'id': '282', 'type': 'identifier', 'children': [], 'value': 'k'}, {'id': '283', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '284', 'type': 'call', 'children': ['285', '288']}, {'id': '285', 'type': 'attribute', 'children': ['286', '287']}; {'id': '286', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '288', 'type': 'argument_list', 'children': []}, {'id': '289', 'type': 'block', 'children': ['290']}; {'id': '290', 'type': 'expression_statement', 'children': ['291']}, {'id': '291', 'type': 'assignment', 'children': ['292', '295']}; {'id': '292', 'type': 'subscript', 'children': ['293', '294']}, {'id': '293', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'k'}, {'id': '295', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '296', 'type': 'else_clause', 'children': ['297']}, {'id': '297', 'type': 'block', 'children': ['298']}; {'id': '298', 'type': 'expression_statement', 'children': ['299']}, {'id': '299', 'type': 'assignment', 'children': ['300', '303']}; {'id': '300', 'type': 'subscript', 'children': ['301', '302']}, {'id': '301', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '302', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '303', 'type': 'None', 'children': []}; {'id': '304', 'type': 'expression_statement', 'children': ['305']}, {'id': '305', 'type': 'call', 'children': ['306', '309']}; {'id': '306', 'type': 'attribute', 'children': ['307', '308']}, {'id': '307', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '308', 'type': 'identifier', 'children': [], 'value': 'scanner_map_delete'}, {'id': '309', 'type': 'argument_list', 'children': ['310']}
def Append(self, **kw): kw = copy_non_reserved_keywords(kw) for key, val in kw.items(): try: if key == 'CPPDEFINES' and SCons.Util.is_String(self._dict[key]): self._dict[key] = [self._dict[key]] orig = self._dict[key] except KeyError: if key == 'CPPDEFINES' and SCons.Util.is_String(val): self._dict[key] = [val] else: self._dict[key] = val else: try: update_dict = orig.update except AttributeError: try: self._dict[key] = orig + val except (KeyError, TypeError): try: add_to_orig = orig.append except AttributeError: if orig: val.insert(0, orig) self._dict[key] = val else: if val: add_to_orig(val) else: if SCons.Util.is_List(val): if key == 'CPPDEFINES': tmp = [] for (k, v) in orig.items(): if v is not None: tmp.append((k, v)) else: tmp.append((k,)) orig = tmp orig += val self._dict[key] = orig else: for v in val: orig[v] = None else: try: update_dict(val) except (AttributeError, TypeError, ValueError): if SCons.Util.is_Dict(val): for k, v in val.items(): orig[k] = v else: orig[val] = None self.scanner_map_delete(kw)
{'id': '0', 'type': 'module', 'children': ['1', '95', '115', '156']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12', '93']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ParseDepends'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'must_exist'}; {'id': '8', 'type': 'None', 'children': []}, {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'only_one'}, {'id': '11', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '12', 'type': 'ERROR', 'children': ['13', '22', '40', '55', '88']}, {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'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': 'subst'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '22', 'type': 'try_statement', 'children': ['23', '32']}, {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}, {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'fp'}, {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'open'}, {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'filename'}, {'id': '31', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '32', 'type': 'except_clause', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '34', 'type': 'block', 'children': ['35', '39']}, {'id': '35', 'type': 'if_statement', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'must_exist'}, {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'raise_statement', 'children': []}, {'id': '39', 'type': 'return_statement', 'children': []}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}, {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'lines'}, {'id': '43', 'type': 'call', 'children': ['44', '54']}; {'id': '44', 'type': 'attribute', 'children': ['45', '53']}, {'id': '45', 'type': 'call', 'children': ['46', '51']}; {'id': '46', 'type': 'attribute', 'children': ['47', '50']}, {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'LogicalLines'}, {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'fp'}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'readlines'}; {'id': '54', 'type': 'argument_list', 'children': []}, {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '81']}, {'id': '57', 'type': 'pattern_list', 'children': ['58', '59', '80']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'lines'}, {'id': '59', 'type': 'ERROR', 'children': ['60', '61', '64', '72', '73', '74']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'l'}, {'id': '61', 'type': 'for_in_clause', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'l'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '64', 'type': 'if_clause', 'children': ['65']}, {'id': '65', 'type': 'comparison_operator', 'children': ['66', '69', '71'], 'value': '!='}; {'id': '66', 'type': 'subscript', 'children': ['67', '68']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '69', 'type': 'ERROR', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'tdlist'}, {'id': '71', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'line'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '74', 'type': 'type', 'children': ['75']}, {'id': '75', 'type': 'constrained_type', 'children': ['76', '78']}; {'id': '76', 'type': 'type', 'children': ['77']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'try'}; {'id': '78', 'type': 'type', 'children': ['79']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'depends'}, {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'split'}, {'id': '85', 'type': 'argument_list', 'children': ['86', '87']}; {'id': '86', 'type': 'string', 'children': [], 'value': "':'"}, {'id': '87', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '88', 'type': 'call', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'except'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'ValueError'}, {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'pass_statement', 'children': []}, {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'else'}; {'id': '98', 'type': 'type', 'children': ['99']}, {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'tdlist'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'tuple', 'children': ['105', '110']}, {'id': '105', 'type': 'call', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'split'}, {'id': '109', 'type': 'argument_list', 'children': []}; {'id': '110', 'type': 'call', 'children': ['111', '114']}, {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'depends'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '114', 'type': 'argument_list', 'children': []}, {'id': '115', 'type': 'if_statement', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'only_one'}, {'id': '117', 'type': 'block', 'children': ['118', '122', '135']}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}, {'id': '119', 'type': 'assignment', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'targets'}, {'id': '121', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '122', 'type': 'for_statement', 'children': ['123', '124', '125']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'td'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'tdlist'}, {'id': '125', 'type': 'block', 'children': ['126']}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}, {'id': '127', 'type': 'call', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'targets'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'extend'}, {'id': '131', 'type': 'argument_list', 'children': ['132']}; {'id': '132', 'type': 'subscript', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'td'}; {'id': '134', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '135', 'type': 'if_statement', 'children': ['136', '142']}; {'id': '136', 'type': 'comparison_operator', 'children': ['137', '141'], 'value': '>'}, {'id': '137', 'type': 'call', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '139', 'type': 'argument_list', 'children': ['140']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'targets'}, {'id': '141', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '142', 'type': 'block', 'children': ['143']}, {'id': '143', 'type': 'raise_statement', 'children': ['144']}; {'id': '144', 'type': 'call', 'children': ['145', '150']}, {'id': '145', 'type': 'attribute', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'Errors'}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'UserError'}; {'id': '150', 'type': 'argument_list', 'children': ['151']}, {'id': '151', 'type': 'binary_operator', 'children': ['152', '153'], 'value': '%'}; {'id': '152', 'type': 'string', 'children': [], 'value': '"More than one dependency target found in `%s\': %s"'}, {'id': '153', 'type': 'tuple', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'filename'}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'targets'}; {'id': '156', 'type': 'for_statement', 'children': ['157', '160', '161', '171']}, {'id': '157', 'type': 'pattern_list', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'depends'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'tdlist'}, {'id': '161', 'type': 'ERROR', 'children': ['162']}; {'id': '162', 'type': 'block', 'children': ['163']}, {'id': '163', 'type': 'expression_statement', 'children': ['164']}; {'id': '164', 'type': 'call', 'children': ['165', '168']}, {'id': '165', 'type': 'attribute', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'Depends'}; {'id': '168', 'type': 'argument_list', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'depends'}, {'id': '171', 'type': 'block', 'children': [], 'value': ''}
def ParseDepends(self, filename, must_exist=None, only_one=0): filename = self.subst(filename) try: fp = open(filename, 'r') except IOError: if must_exist: raise return lines = SCons.Util.LogicalLines(fp).readlines() lines = [l for l in lines if l[0] != ' tdlist = [] for line in lines: try: target, depends = line.split(':', 1) except (AttributeError, ValueError): pass else: tdlist.append((target.split(), depends.split())) if only_one: targets = [] for td in tdlist: targets.extend(td[0]) if len(targets) > 1: raise SCons.Errors.UserError( "More than one dependency target found in `%s': %s" % (filename, targets)) for target, depends in tdlist: self.Depends(target, depends)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Prepend'}, {'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': 'kw'}, {'id': '7', 'type': 'block', 'children': ['8', '15', '187']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}, {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'copy_non_reserved_keywords'}, {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '15', 'type': 'for_statement', 'children': ['16', '19', '24']}; {'id': '16', 'type': 'pattern_list', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'items'}, {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'block', 'children': ['25']}, {'id': '25', 'type': 'try_statement', 'children': ['26', '35', '46']}; {'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': 'orig'}; {'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': '_dict'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '35', 'type': 'except_clause', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'KeyError'}, {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}, {'id': '39', 'type': 'assignment', 'children': ['40', '45']}; {'id': '40', 'type': 'subscript', 'children': ['41', '44']}, {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '43', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '46', 'type': 'else_clause', 'children': ['47']}, {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'try_statement', 'children': ['49', '56', '116']}, {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}, {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'update_dict'}, {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '56', 'type': 'except_clause', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '58', 'type': 'block', 'children': ['59']}, {'id': '59', 'type': 'try_statement', 'children': ['60', '71']}; {'id': '60', 'type': 'block', 'children': ['61']}, {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '68']}, {'id': '63', 'type': 'subscript', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '_dict'}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '68', 'type': 'binary_operator', 'children': ['69', '70'], 'value': '+'}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '71', 'type': 'except_clause', 'children': ['72', '75']}; {'id': '72', 'type': 'tuple', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'TypeError'}, {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'try_statement', 'children': ['77', '84', '98']}, {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}, {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'add_to_val'}, {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '84', 'type': 'except_clause', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '86', 'type': 'block', 'children': ['87']}, {'id': '87', 'type': 'if_statement', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'val'}, {'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': 'orig'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'insert'}, {'id': '95', 'type': 'argument_list', 'children': ['96', '97']}; {'id': '96', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '98', 'type': 'else_clause', 'children': ['99']}, {'id': '99', 'type': 'block', 'children': ['100', '108']}; {'id': '100', 'type': 'if_statement', 'children': ['101', '102']}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '102', 'type': 'block', 'children': ['103']}, {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'add_to_val'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}, {'id': '109', 'type': 'assignment', 'children': ['110', '115']}; {'id': '110', 'type': 'subscript', 'children': ['111', '114']}, {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '116', 'type': 'else_clause', 'children': ['117']}, {'id': '117', 'type': 'block', 'children': ['118']}; {'id': '118', 'type': 'if_statement', 'children': ['119', '127', '138']}, {'id': '119', 'type': 'call', 'children': ['120', '125']}; {'id': '120', 'type': 'attribute', 'children': ['121', '124']}, {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'is_List'}, {'id': '125', 'type': 'argument_list', 'children': ['126']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '127', 'type': 'block', 'children': ['128']}; {'id': '128', 'type': 'for_statement', 'children': ['129', '130', '131']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '131', 'type': 'block', 'children': ['132']}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}, {'id': '133', 'type': 'assignment', 'children': ['134', '137']}; {'id': '134', 'type': 'subscript', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '137', 'type': 'None', 'children': []}; {'id': '138', 'type': 'else_clause', 'children': ['139']}, {'id': '139', 'type': 'block', 'children': ['140']}; {'id': '140', 'type': 'try_statement', 'children': ['141', '147']}, {'id': '141', 'type': 'block', 'children': ['142']}; {'id': '142', 'type': 'expression_statement', 'children': ['143']}, {'id': '143', 'type': 'call', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'update_dict'}, {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '147', 'type': 'except_clause', 'children': ['148', '152']}; {'id': '148', 'type': 'tuple', 'children': ['149', '150', '151']}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'TypeError'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '152', 'type': 'block', 'children': ['153']}, {'id': '153', 'type': 'if_statement', 'children': ['154', '162', '179']}; {'id': '154', 'type': 'call', 'children': ['155', '160']}, {'id': '155', 'type': 'attribute', 'children': ['156', '159']}; {'id': '156', 'type': 'attribute', 'children': ['157', '158']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'Util'}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'is_Dict'}; {'id': '160', 'type': 'argument_list', 'children': ['161']}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '162', 'type': 'block', 'children': ['163']}, {'id': '163', 'type': 'for_statement', 'children': ['164', '167', '172']}; {'id': '164', 'type': 'pattern_list', 'children': ['165', '166']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '167', 'type': 'call', 'children': ['168', '171']}; {'id': '168', 'type': 'attribute', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'items'}, {'id': '171', 'type': 'argument_list', 'children': []}; {'id': '172', 'type': 'block', 'children': ['173']}, {'id': '173', 'type': 'expression_statement', 'children': ['174']}; {'id': '174', 'type': 'assignment', 'children': ['175', '178']}, {'id': '175', 'type': 'subscript', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '179', 'type': 'else_clause', 'children': ['180']}; {'id': '180', 'type': 'block', 'children': ['181']}, {'id': '181', 'type': 'expression_statement', 'children': ['182']}; {'id': '182', 'type': 'assignment', 'children': ['183', '186']}, {'id': '183', 'type': 'subscript', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'orig'}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '186', 'type': 'None', 'children': []}, {'id': '187', 'type': 'expression_statement', 'children': ['188']}; {'id': '188', 'type': 'call', 'children': ['189', '192']}, {'id': '189', 'type': 'attribute', 'children': ['190', '191']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'scanner_map_delete'}; {'id': '192', 'type': 'argument_list', 'children': ['193']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'kw'}
def Prepend(self, **kw): kw = copy_non_reserved_keywords(kw) for key, val in kw.items(): try: orig = self._dict[key] except KeyError: self._dict[key] = val else: try: update_dict = orig.update except AttributeError: try: self._dict[key] = val + orig except (KeyError, TypeError): try: add_to_val = val.append except AttributeError: if val: orig.insert(0, val) else: if orig: add_to_val(orig) self._dict[key] = val else: if SCons.Util.is_List(val): for v in val: orig[v] = None else: try: update_dict(val) except (AttributeError, TypeError, ValueError): if SCons.Util.is_Dict(val): for k, v in val.items(): orig[k] = v else: orig[val] = None self.scanner_map_delete(kw)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'PrependUnique'}, {'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': 'delete_existing'}, {'id': '7', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '10', 'type': 'block', 'children': ['11', '18', '272']}, {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'copy_non_reserved_keywords'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '18', 'type': 'for_statement', 'children': ['19', '22', '27']}, {'id': '19', 'type': 'pattern_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}, {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '26', 'type': 'argument_list', 'children': []}, {'id': '27', 'type': 'block', 'children': ['28', '47']}; {'id': '28', 'type': 'if_statement', 'children': ['29', '37']}, {'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': 'SCons'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'is_List'}, {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}, {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '_delete_duplicates'}, {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '45', 'type': 'not_operator', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'delete_existing'}, {'id': '47', 'type': 'if_statement', 'children': ['48', '63', '72', '107', '180']}; {'id': '48', 'type': 'boolean_operator', 'children': ['49', '54'], 'value': 'or'}, {'id': '49', 'type': 'comparison_operator', 'children': ['50', '51'], 'value': 'not'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '53', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '60'], 'value': 'in'}, {'id': '55', 'type': 'subscript', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': '_dict'}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '60', 'type': 'tuple', 'children': ['61', '62']}, {'id': '61', 'type': 'string', 'children': [], 'value': "''"}; {'id': '62', 'type': 'None', 'children': []}, {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}, {'id': '65', 'type': 'assignment', 'children': ['66', '71']}; {'id': '66', 'type': 'subscript', 'children': ['67', '70']}, {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '69', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '72', 'type': 'elif_clause', 'children': ['73', '95']}, {'id': '73', 'type': 'boolean_operator', 'children': ['74', '86', '87'], 'value': 'and'}; {'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': 'SCons'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'Util'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'is_Dict'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}, {'id': '81', 'type': 'subscript', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': '_dict'}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '86', 'type': 'line_continuation', 'children': [], 'value': '\\'}, {'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': 'SCons'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'is_Dict'}, {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}, {'id': '97', 'type': 'call', 'children': ['98', '105']}; {'id': '98', 'type': 'attribute', 'children': ['99', '104']}, {'id': '99', 'type': 'subscript', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': '_dict'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'update'}, {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '107', 'type': 'elif_clause', 'children': ['108', '116']}; {'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': 'SCons'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'Util'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'is_List'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '116', 'type': 'block', 'children': ['117', '125', '141', '170']}, {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'assignment', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'dk'}; {'id': '120', 'type': 'subscript', 'children': ['121', '124']}, {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '123', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '125', 'type': 'if_statement', 'children': ['126', '135']}; {'id': '126', 'type': 'not_operator', 'children': ['127']}, {'id': '127', 'type': 'call', 'children': ['128', '133']}; {'id': '128', 'type': 'attribute', 'children': ['129', '132']}, {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'is_List'}, {'id': '133', 'type': 'argument_list', 'children': ['134']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'dk'}, {'id': '135', 'type': 'block', 'children': ['136']}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}, {'id': '137', 'type': 'assignment', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'dk'}, {'id': '139', 'type': 'list', 'children': ['140'], 'value': '[dk]'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'dk'}, {'id': '141', 'type': 'if_statement', 'children': ['142', '143', '156']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'delete_existing'}, {'id': '143', 'type': 'block', 'children': ['144']}; {'id': '144', 'type': 'expression_statement', 'children': ['145']}, {'id': '145', 'type': 'assignment', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'dk'}, {'id': '147', 'type': 'list_comprehension', 'children': ['148', '149', '152']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '149', 'type': 'for_in_clause', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'dk'}; {'id': '152', 'type': 'if_clause', 'children': ['153']}, {'id': '153', 'type': 'comparison_operator', 'children': ['154', '155'], 'value': 'not'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '156', 'type': 'else_clause', 'children': ['157']}, {'id': '157', 'type': 'block', 'children': ['158']}; {'id': '158', 'type': 'expression_statement', 'children': ['159']}, {'id': '159', 'type': 'assignment', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '161', 'type': 'list_comprehension', 'children': ['162', '163', '166']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '163', 'type': 'for_in_clause', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '166', 'type': 'if_clause', 'children': ['167']}, {'id': '167', 'type': 'comparison_operator', 'children': ['168', '169'], 'value': 'not'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'dk'}; {'id': '170', 'type': 'expression_statement', 'children': ['171']}, {'id': '171', 'type': 'assignment', 'children': ['172', '177']}; {'id': '172', 'type': 'subscript', 'children': ['173', '176']}, {'id': '173', 'type': 'attribute', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '175', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '177', 'type': 'binary_operator', 'children': ['178', '179'], 'value': '+'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'dk'}; {'id': '180', 'type': 'else_clause', 'children': ['181']}, {'id': '181', 'type': 'block', 'children': ['182', '190']}; {'id': '182', 'type': 'expression_statement', 'children': ['183']}, {'id': '183', 'type': 'assignment', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'dk'}, {'id': '185', 'type': 'subscript', 'children': ['186', '189']}; {'id': '186', 'type': 'attribute', 'children': ['187', '188']}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '188', 'type': 'identifier', 'children': [], 'value': '_dict'}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '190', 'type': 'if_statement', 'children': ['191', '199', '245']}, {'id': '191', 'type': 'call', 'children': ['192', '197']}; {'id': '192', 'type': 'attribute', 'children': ['193', '196']}, {'id': '193', 'type': 'attribute', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'is_List'}, {'id': '197', 'type': 'argument_list', 'children': ['198']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'dk'}, {'id': '199', 'type': 'block', 'children': ['200']}; {'id': '200', 'type': 'if_statement', 'children': ['201', '202', '226']}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'delete_existing'}; {'id': '202', 'type': 'block', 'children': ['203', '215']}, {'id': '203', 'type': 'expression_statement', 'children': ['204']}; {'id': '204', 'type': 'assignment', 'children': ['205', '206']}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'dk'}; {'id': '206', 'type': 'list_comprehension', 'children': ['207', '208', '211']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '208', 'type': 'for_in_clause', 'children': ['209', '210']}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'dk'}, {'id': '211', 'type': 'if_clause', 'children': ['212']}; {'id': '212', 'type': 'comparison_operator', 'children': ['213', '214'], 'value': 'not'}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '215', 'type': 'expression_statement', 'children': ['216']}; {'id': '216', 'type': 'assignment', 'children': ['217', '222']}, {'id': '217', 'type': 'subscript', 'children': ['218', '221']}; {'id': '218', 'type': 'attribute', 'children': ['219', '220']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '220', 'type': 'identifier', 'children': [], 'value': '_dict'}, {'id': '221', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '222', 'type': 'binary_operator', 'children': ['223', '225'], 'value': '+'}, {'id': '223', 'type': 'list', 'children': ['224'], 'value': '[val]'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'dk'}; {'id': '226', 'type': 'else_clause', 'children': ['227']}, {'id': '227', 'type': 'block', 'children': ['228']}; {'id': '228', 'type': 'if_statement', 'children': ['229', '233']}, {'id': '229', 'type': 'not_operator', 'children': ['230']}; {'id': '230', 'type': 'comparison_operator', 'children': ['231', '232'], 'value': 'in'}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'dk'}, {'id': '233', 'type': 'block', 'children': ['234']}; {'id': '234', 'type': 'expression_statement', 'children': ['235']}, {'id': '235', 'type': 'assignment', 'children': ['236', '241']}; {'id': '236', 'type': 'subscript', 'children': ['237', '240']}, {'id': '237', 'type': 'attribute', 'children': ['238', '239']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '239', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '241', 'type': 'binary_operator', 'children': ['242', '244'], 'value': '+'}; {'id': '242', 'type': 'list', 'children': ['243'], 'value': '[val]'}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'dk'}, {'id': '245', 'type': 'else_clause', 'children': ['246']}; {'id': '246', 'type': 'block', 'children': ['247', '262']}, {'id': '247', 'type': 'if_statement', 'children': ['248', '249']}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 'delete_existing'}, {'id': '249', 'type': 'block', 'children': ['250']}; {'id': '250', 'type': 'expression_statement', 'children': ['251']}, {'id': '251', 'type': 'assignment', 'children': ['252', '253']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'dk'}, {'id': '253', 'type': 'list_comprehension', 'children': ['254', '255', '258']}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '255', 'type': 'for_in_clause', 'children': ['256', '257']}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '257', 'type': 'identifier', 'children': [], 'value': 'dk'}; {'id': '258', 'type': 'if_clause', 'children': ['259']}, {'id': '259', 'type': 'comparison_operator', 'children': ['260', '261'], 'value': 'not'}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '262', 'type': 'expression_statement', 'children': ['263']}, {'id': '263', 'type': 'assignment', 'children': ['264', '269']}; {'id': '264', 'type': 'subscript', 'children': ['265', '268']}, {'id': '265', 'type': 'attribute', 'children': ['266', '267']}; {'id': '266', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '267', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '269', 'type': 'binary_operator', 'children': ['270', '271'], 'value': '+'}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '271', 'type': 'identifier', 'children': [], 'value': 'dk'}; {'id': '272', 'type': 'expression_statement', 'children': ['273']}, {'id': '273', 'type': 'call', 'children': ['274', '277']}; {'id': '274', 'type': 'attribute', 'children': ['275', '276']}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'scanner_map_delete'}, {'id': '277', 'type': 'argument_list', 'children': ['278']}
def PrependUnique(self, delete_existing=0, **kw): kw = copy_non_reserved_keywords(kw) for key, val in kw.items(): if SCons.Util.is_List(val): val = _delete_duplicates(val, not delete_existing) if key not in self._dict or self._dict[key] in ('', None): self._dict[key] = val elif SCons.Util.is_Dict(self._dict[key]) and \ SCons.Util.is_Dict(val): self._dict[key].update(val) elif SCons.Util.is_List(val): dk = self._dict[key] if not SCons.Util.is_List(dk): dk = [dk] if delete_existing: dk = [x for x in dk if x not in val] else: val = [x for x in val if x not in dk] self._dict[key] = val + dk else: dk = self._dict[key] if SCons.Util.is_List(dk): if delete_existing: dk = [x for x in dk if x not in val] self._dict[key] = [val] + dk else: if not val in dk: self._dict[key] = [val] + dk else: if delete_existing: dk = [x for x in dk if x not in val] self._dict[key] = val + dk self.scanner_map_delete(kw)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wait_idle'}, {'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': 'timeout'}, {'id': '7', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '8', 'type': 'block', 'children': ['9', '83', '102', '111']}, {'id': '9', 'type': 'function_definition', 'children': ['10', '11', '12']}; {'id': '10', 'type': 'function_name', 'children': [], 'value': '_awaiter'}, {'id': '11', 'type': 'parameters', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '27', '52', '67']}, {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'background_work'}; {'id': '16', 'type': 'set_comprehension', 'children': ['17', '22']}, {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'for_in_clause', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_work_queues'}, {'id': '27', 'type': 'for_statement', 'children': ['28', '29', '32']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'event'}, {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '31', 'type': 'identifier', 'children': [], 'value': '_events'}; {'id': '32', 'type': 'block', 'children': ['33']}, {'id': '33', 'type': 'if_statement', 'children': ['34', '40']}; {'id': '34', 'type': 'not_operator', 'children': ['35']}, {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'is_set'}, {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'block', 'children': ['41']}, {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}, {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'background_work'}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}, {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'wait'}, {'id': '51', 'type': 'argument_list', 'children': []}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}, {'id': '53', 'type': 'assignment', 'children': ['54', '57']}; {'id': '54', 'type': 'pattern_list', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': '_done'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'pending'}, {'id': '57', 'type': 'await', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}, {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'asyncio'}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'wait'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'background_work'}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'timeout'}, {'id': '67', 'type': 'if_statement', 'children': ['68', '74']}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '73'], 'value': '>'}, {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'pending'}, {'id': '73', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '74', 'type': 'block', 'children': ['75']}, {'id': '75', 'type': 'raise_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'TimeoutExpiredError'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}, {'id': '79', 'type': 'string', 'children': [], 'value': '"Timeout waiting for event loop to become idle"'}; {'id': '80', 'type': 'keyword_argument', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'pending'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'pending'}, {'id': '83', 'type': 'if_statement', 'children': ['84', '89']}; {'id': '84', 'type': 'call', 'children': ['85', '88']}, {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': '_on_emulation_thread'}; {'id': '88', 'type': 'argument_list', 'children': []}, {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'return_statement', 'children': ['91']}, {'id': '91', 'type': 'call', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'asyncio'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'wait_for'}, {'id': '95', 'type': 'argument_list', 'children': ['96', '99']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': '_awaiter'}; {'id': '98', 'type': 'argument_list', 'children': []}, {'id': '99', 'type': 'keyword_argument', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'timeout'}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}, {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'run_task_external'}, {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': '_awaiter'}; {'id': '110', 'type': 'argument_list', 'children': []}, {'id': '111', 'type': 'return_statement', 'children': ['112']}
def wait_idle(self, timeout=1.0): async def _awaiter(): background_work = {x.join() for x in self._work_queues} for event in self._events: if not event.is_set(): background_work.add(event.wait()) _done, pending = await asyncio.wait(background_work, timeout=timeout) if len(pending) > 0: raise TimeoutExpiredError("Timeout waiting for event loop to become idle", pending=pending) if self._on_emulation_thread(): return asyncio.wait_for(_awaiter(), timeout=timeout) self.run_task_external(_awaiter()) return None
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_process_long_opt'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'rargs'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'values'}, {'id': '7', 'type': 'block', 'children': ['8', '17', '56', '98', '106', '281']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}, {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'arg'}, {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'rargs'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'pop'}, {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '17', 'type': 'if_statement', 'children': ['18', '21', '46']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': 'in'}, {'id': '19', 'type': 'string', 'children': [], 'value': '"="'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'arg'}, {'id': '21', 'type': 'block', 'children': ['22', '34', '42']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}, {'id': '23', 'type': 'assignment', 'children': ['24', '27']}; {'id': '24', 'type': 'tuple_pattern', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'next_arg'}, {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'split'}, {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': '"="'}, {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}; {'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': 'rargs'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'insert'}, {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'next_arg'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}, {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'had_explicit_value'}, {'id': '45', 'type': 'True', 'children': []}; {'id': '46', 'type': 'else_clause', 'children': ['47']}, {'id': '47', 'type': 'block', 'children': ['48', '52']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}, {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'opt'}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}, {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'had_explicit_value'}, {'id': '55', 'type': 'False', 'children': []}; {'id': '56', 'type': 'try_statement', 'children': ['57', '67']}, {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}, {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'opt'}, {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '_match_long_opt'}, {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'opt'}, {'id': '67', 'type': 'except_clause', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'optparse'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'BadOptionError'}, {'id': '71', 'type': 'block', 'children': ['72', '97']}; {'id': '72', 'type': 'if_statement', 'children': ['73', '76']}, {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'preserve_unknown_options'}; {'id': '76', 'type': 'block', 'children': ['77', '86', '96']}, {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '84']}, {'id': '79', 'type': 'attribute', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'largs'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '86', 'type': 'if_statement', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'had_explicit_value'}; {'id': '88', 'type': 'block', 'children': ['89']}, {'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': 'rargs'}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}, {'id': '95', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '96', 'type': 'return_statement', 'children': []}, {'id': '97', 'type': 'raise_statement', 'children': []}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}, {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '101', 'type': 'subscript', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': '_long_opt'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '106', 'type': 'if_statement', 'children': ['107', '112', '260', '275']}, {'id': '107', 'type': 'call', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'takes_value'}, {'id': '111', 'type': 'argument_list', 'children': []}; {'id': '112', 'type': 'block', 'children': ['113', '119']}, {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'assignment', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'nargs'}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'nargs'}, {'id': '119', 'type': 'if_statement', 'children': ['120', '123', '144', '225', '239']}; {'id': '120', 'type': 'comparison_operator', 'children': ['121', '122'], 'value': '=='}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'nargs'}; {'id': '122', 'type': 'string', 'children': [], 'value': "'?'"}, {'id': '123', 'type': 'block', 'children': ['124']}; {'id': '124', 'type': 'if_statement', 'children': ['125', '126', '136']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'had_explicit_value'}; {'id': '126', 'type': 'block', 'children': ['127']}, {'id': '127', 'type': 'expression_statement', 'children': ['128']}; {'id': '128', 'type': 'assignment', 'children': ['129', '130']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '130', 'type': 'call', 'children': ['131', '134']}, {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'rargs'}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}, {'id': '135', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '136', 'type': 'else_clause', 'children': ['137']}, {'id': '137', 'type': 'block', 'children': ['138']}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}, {'id': '139', 'type': 'assignment', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'const'}; {'id': '144', 'type': 'elif_clause', 'children': ['145', '151']}, {'id': '145', 'type': 'comparison_operator', 'children': ['146', '150'], 'value': '<'}; {'id': '146', 'type': 'call', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '148', 'type': 'argument_list', 'children': ['149']}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'rargs'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'nargs'}, {'id': '151', 'type': 'block', 'children': ['152']}; {'id': '152', 'type': 'if_statement', 'children': ['153', '156', '209']}, {'id': '153', 'type': 'comparison_operator', 'children': ['154', '155'], 'value': '=='}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'nargs'}, {'id': '155', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '156', 'type': 'block', 'children': ['157']}, {'id': '157', 'type': 'if_statement', 'children': ['158', '162', '175']}; {'id': '158', 'type': 'not_operator', 'children': ['159']}, {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'choices'}; {'id': '162', 'type': 'block', 'children': ['163']}, {'id': '163', 'type': 'expression_statement', 'children': ['164']}; {'id': '164', 'type': 'call', 'children': ['165', '168']}, {'id': '165', 'type': 'attribute', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '168', 'type': 'argument_list', 'children': ['169']}, {'id': '169', 'type': 'binary_operator', 'children': ['170', '174'], 'value': '%'}; {'id': '170', 'type': 'call', 'children': ['171', '172']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '172', 'type': 'argument_list', 'children': ['173']}, {'id': '173', 'type': 'string', 'children': [], 'value': '"%s option requires an argument"'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'opt'}, {'id': '175', 'type': 'else_clause', 'children': ['176']}; {'id': '176', 'type': 'block', 'children': ['177', '186', '202']}, {'id': '177', 'type': 'expression_statement', 'children': ['178']}; {'id': '178', 'type': 'assignment', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '180', 'type': 'call', 'children': ['181', '182']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '182', 'type': 'argument_list', 'children': ['183']}, {'id': '183', 'type': 'binary_operator', 'children': ['184', '185'], 'value': '%'}; {'id': '184', 'type': 'string', 'children': [], 'value': '"%s option requires an argument "'}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '186', 'type': 'expression_statement', 'children': ['187']}, {'id': '187', 'type': 'augmented_assignment', 'children': ['188', '189'], 'value': '+='}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '189', 'type': 'call', 'children': ['190', '191']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': '_'}, {'id': '191', 'type': 'argument_list', 'children': ['192']}; {'id': '192', 'type': 'binary_operator', 'children': ['193', '194'], 'value': '%'}, {'id': '193', 'type': 'string', 'children': [], 'value': '"(choose from %s)"'}; {'id': '194', 'type': 'call', 'children': ['195', '198']}, {'id': '195', 'type': 'attribute', 'children': ['196', '197']}; {'id': '196', 'type': 'string', 'children': [], 'value': "', '"}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '198', 'type': 'argument_list', 'children': ['199']}, {'id': '199', 'type': 'attribute', 'children': ['200', '201']}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'choices'}; {'id': '202', 'type': 'expression_statement', 'children': ['203']}, {'id': '203', 'type': 'call', 'children': ['204', '207']}; {'id': '204', 'type': 'attribute', 'children': ['205', '206']}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'error'}, {'id': '207', 'type': 'argument_list', 'children': ['208']}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '209', 'type': 'else_clause', 'children': ['210']}; {'id': '210', 'type': 'block', 'children': ['211']}, {'id': '211', 'type': 'expression_statement', 'children': ['212']}; {'id': '212', 'type': 'call', 'children': ['213', '216']}, {'id': '213', 'type': 'attribute', 'children': ['214', '215']}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '216', 'type': 'argument_list', 'children': ['217']}, {'id': '217', 'type': 'binary_operator', 'children': ['218', '222'], 'value': '%'}; {'id': '218', 'type': 'call', 'children': ['219', '220']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '220', 'type': 'argument_list', 'children': ['221']}, {'id': '221', 'type': 'string', 'children': [], 'value': '"%s option requires %d arguments"'}; {'id': '222', 'type': 'tuple', 'children': ['223', '224']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'nargs'}, {'id': '225', 'type': 'elif_clause', 'children': ['226', '229']}; {'id': '226', 'type': 'comparison_operator', 'children': ['227', '228'], 'value': '=='}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'nargs'}; {'id': '228', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '229', 'type': 'block', 'children': ['230']}; {'id': '230', 'type': 'expression_statement', 'children': ['231']}, {'id': '231', 'type': 'assignment', 'children': ['232', '233']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '233', 'type': 'call', 'children': ['234', '237']}; {'id': '234', 'type': 'attribute', 'children': ['235', '236']}, {'id': '235', 'type': 'identifier', 'children': [], 'value': 'rargs'}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'pop'}, {'id': '237', 'type': 'argument_list', 'children': ['238']}; {'id': '238', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '239', 'type': 'else_clause', 'children': ['240']}; {'id': '240', 'type': 'block', 'children': ['241', '253']}, {'id': '241', 'type': 'expression_statement', 'children': ['242']}; {'id': '242', 'type': 'assignment', 'children': ['243', '244']}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '244', 'type': 'call', 'children': ['245', '246']}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '246', 'type': 'argument_list', 'children': ['247']}, {'id': '247', 'type': 'subscript', 'children': ['248', '249']}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 'rargs'}, {'id': '249', 'type': 'slice', 'children': ['250', '251', '252']}; {'id': '250', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '251', 'type': 'colon', 'children': []}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'nargs'}, {'id': '253', 'type': 'delete_statement', 'children': ['254']}; {'id': '254', 'type': 'subscript', 'children': ['255', '256']}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'rargs'}; {'id': '256', 'type': 'slice', 'children': ['257', '258', '259']}, {'id': '257', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '258', 'type': 'colon', 'children': []}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'nargs'}; {'id': '260', 'type': 'elif_clause', 'children': ['261', '262']}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'had_explicit_value'}; {'id': '262', 'type': 'block', 'children': ['263']}, {'id': '263', 'type': 'expression_statement', 'children': ['264']}; {'id': '264', 'type': 'call', 'children': ['265', '268']}, {'id': '265', 'type': 'attribute', 'children': ['266', '267']}; {'id': '266', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '268', 'type': 'argument_list', 'children': ['269']}, {'id': '269', 'type': 'binary_operator', 'children': ['270', '274'], 'value': '%'}; {'id': '270', 'type': 'call', 'children': ['271', '272']}, {'id': '271', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '272', 'type': 'argument_list', 'children': ['273']}, {'id': '273', 'type': 'string', 'children': [], 'value': '"%s option does not take a value"'}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'opt'}, {'id': '275', 'type': 'else_clause', 'children': ['276']}; {'id': '276', 'type': 'block', 'children': ['277']}, {'id': '277', 'type': 'expression_statement', 'children': ['278']}; {'id': '278', 'type': 'assignment', 'children': ['279', '280']}, {'id': '279', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '280', 'type': 'None', 'children': []}, {'id': '281', 'type': 'expression_statement', 'children': ['282']}; {'id': '282', 'type': 'call', 'children': ['283', '286']}, {'id': '283', 'type': 'attribute', 'children': ['284', '285']}; {'id': '284', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '285', 'type': 'identifier', 'children': [], 'value': 'process'}; {'id': '286', 'type': 'argument_list', 'children': ['287', '288', '289', '290']}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '289', 'type': 'identifier', 'children': [], 'value': 'values'}
def _process_long_opt(self, rargs, values): arg = rargs.pop(0) if "=" in arg: (opt, next_arg) = arg.split("=", 1) rargs.insert(0, next_arg) had_explicit_value = True else: opt = arg had_explicit_value = False try: opt = self._match_long_opt(opt) except optparse.BadOptionError: if self.preserve_unknown_options: self.largs.append(arg) if had_explicit_value: rargs.pop(0) return raise option = self._long_opt[opt] if option.takes_value(): nargs = option.nargs if nargs == '?': if had_explicit_value: value = rargs.pop(0) else: value = option.const elif len(rargs) < nargs: if nargs == 1: if not option.choices: self.error(_("%s option requires an argument") % opt) else: msg = _("%s option requires an argument " % opt) msg += _("(choose from %s)" % ', '.join(option.choices)) self.error(msg) else: self.error(_("%s option requires %d arguments") % (opt, nargs)) elif nargs == 1: value = rargs.pop(0) else: value = tuple(rargs[0:nargs]) del rargs[0:nargs] elif had_explicit_value: self.error(_("%s option does not take a value") % opt) else: value = None option.process(opt, value, values, self)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Tag'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'source'}, {'id': '7', 'type': 'list_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'more_tags'}, {'id': '9', 'type': 'dictionary_splat_pattern', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'kw_tags'}, {'id': '11', 'type': 'block', 'children': ['12', '30', '41', '61', '71', '98']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '15', '24']}, {'id': '13', 'type': 'not_operator', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '15', 'type': 'block', 'children': ['16', '20']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}, {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}, {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'first_tag'}, {'id': '23', 'type': 'None', 'children': []}; {'id': '24', 'type': 'else_clause', 'children': ['25']}, {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}, {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'first_tag'}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '32']}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'first_tag'}; {'id': '32', 'type': 'block', 'children': ['33']}, {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '40']}, {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'kw_tags'}, {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'first_tag'}, {'id': '39', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '40', 'type': 'string', 'children': [], 'value': "''"}, {'id': '41', 'type': 'if_statement', 'children': ['42', '55']}; {'id': '42', 'type': 'boolean_operator', 'children': ['43', '49'], 'value': 'and'}, {'id': '43', 'type': 'comparison_operator', 'children': ['44', '48'], 'value': '=='}; {'id': '44', 'type': 'call', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'kw_tags'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '0'}, {'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': 'more_tags'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'raise_statement', 'children': ['57']}, {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'UserError'}, {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'string', 'children': [], 'value': '"No tags given."'}, {'id': '61', 'type': 'for_statement', 'children': ['62', '63', '64']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'more_tags'}; {'id': '64', 'type': 'block', 'children': ['65']}, {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '70']}, {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'kw_tags'}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '70', 'type': 'string', 'children': [], 'value': "''"}, {'id': '71', 'type': 'if_statement', 'children': ['72', '81', '87']}; {'id': '72', 'type': 'not_operator', 'children': ['73']}, {'id': '73', 'type': 'call', 'children': ['74', '79']}; {'id': '74', 'type': 'attribute', 'children': ['75', '78']}, {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'is_List'}, {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}, {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '85', 'type': 'list', 'children': ['86'], 'value': '[target]'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '87', 'type': 'else_clause', 'children': ['88']}; {'id': '88', 'type': 'block', 'children': ['89']}, {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '92', 'type': 'call', 'children': ['93', '96']}, {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'Flatten'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '98', 'type': 'for_statement', 'children': ['99', '100', '101']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'for_statement', 'children': ['103', '106', '111']}, {'id': '103', 'type': 'tuple_pattern', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'k'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '106', 'type': 'call', 'children': ['107', '110']}, {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'kw_tags'}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '110', 'type': 'argument_list', 'children': []}, {'id': '111', 'type': 'block', 'children': ['112', '127']}; {'id': '112', 'type': 'if_statement', 'children': ['113', '120']}, {'id': '113', 'type': 'comparison_operator', 'children': ['114', '119'], 'value': '!='}; {'id': '114', 'type': 'subscript', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '116', 'type': 'slice', 'children': ['117', '118']}, {'id': '117', 'type': 'colon', 'children': []}; {'id': '118', 'type': 'integer', 'children': [], 'value': '10'}, {'id': '119', 'type': 'string', 'children': [], 'value': "'PACKAGING_'"}; {'id': '120', 'type': 'block', 'children': ['121']}, {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'assignment', 'children': ['123', '124']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '124', 'type': 'binary_operator', 'children': ['125', '126'], 'value': '+'}, {'id': '125', 'type': 'string', 'children': [], 'value': "'PACKAGING_'"}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'k'}, {'id': '127', 'type': 'expression_statement', 'children': ['128']}; {'id': '128', 'type': 'call', 'children': ['129', '132']}, {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'Tag'}; {'id': '132', 'type': 'argument_list', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'k'}
def Tag(env, target, source, *more_tags, **kw_tags): if not target: target=source first_tag=None else: first_tag=source if first_tag: kw_tags[first_tag[0]] = '' if len(kw_tags) == 0 and len(more_tags) == 0: raise UserError("No tags given.") for x in more_tags: kw_tags[x] = '' if not SCons.Util.is_List(target): target=[target] else: target=env.Flatten(target) for t in target: for (k,v) in kw_tags.items(): if k[:10] != 'PACKAGING_': k='PACKAGING_'+k t.Tag(k, v)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_vc_pdir'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'msvc_version'}, {'id': '5', 'type': 'block', 'children': ['6', '10', '35', '202']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}, {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '9', 'type': 'string', 'children': [], 'value': "'Software\\\\'"}; {'id': '10', 'type': 'try_statement', 'children': ['11', '18']}, {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}, {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'hkeys'}, {'id': '15', 'type': 'subscript', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_VCVER_TO_PRODUCT_DIR'}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'msvc_version'}; {'id': '18', 'type': 'except_clause', 'children': ['19', '20']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '20', 'type': 'block', 'children': ['21', '28']}, {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}, {'id': '25', 'type': 'binary_operator', 'children': ['26', '27'], 'value': '%'}; {'id': '26', 'type': 'string', 'children': [], 'value': '"Unknown version of MSVC: %s"'}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'msvc_version'}; {'id': '28', 'type': 'raise_statement', 'children': ['29']}, {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'UnsupportedVersion'}, {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '34'], 'value': '%'}, {'id': '33', 'type': 'string', 'children': [], 'value': '"Unknown version %s"'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'msvc_version'}, {'id': '35', 'type': 'for_statement', 'children': ['36', '39', '40']}; {'id': '36', 'type': 'pattern_list', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'hkroot'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'hkeys'}; {'id': '40', 'type': 'block', 'children': ['41']}, {'id': '41', 'type': 'try_statement', 'children': ['42', '133', '156']}; {'id': '42', 'type': 'block', 'children': ['43', '47']}, {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'comps'}; {'id': '46', 'type': 'None', 'children': []}, {'id': '47', 'type': 'if_statement', 'children': ['48', '50', '81']}; {'id': '48', 'type': 'not_operator', 'children': ['49']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '50', 'type': 'block', 'children': ['51', '58']}, {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'comps'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'find_vc_pdir_vswhere'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'msvc_version'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '61']}, {'id': '59', 'type': 'not_operator', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'comps'}, {'id': '61', 'type': 'block', 'children': ['62', '75']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}, {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'debug'}, {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '70']}, {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'string', 'children': [], 'value': "'find_vc_dir(): no VC found via vswhere for version {}'"}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}, {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'repr'}, {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '75', 'type': 'raise_statement', 'children': ['76']}; {'id': '76', 'type': 'attribute', 'children': ['77', '80']}, {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'WinError'}, {'id': '81', 'type': 'else_clause', 'children': ['82']}; {'id': '82', 'type': 'block', 'children': ['83', '117']}, {'id': '83', 'type': 'if_statement', 'children': ['84', '89']}; {'id': '84', 'type': 'call', 'children': ['85', '88']}, {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'common'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'is_win64'}; {'id': '88', 'type': 'argument_list', 'children': []}, {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'try_statement', 'children': ['91', '106']}, {'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': 'comps'}, {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'common'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'read_reg'}, {'id': '99', 'type': 'argument_list', 'children': ['100', '105']}; {'id': '100', 'type': 'binary_operator', 'children': ['101', '104'], 'value': '+'}, {'id': '101', 'type': 'binary_operator', 'children': ['102', '103'], 'value': '+'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '103', 'type': 'string', 'children': [], 'value': "'Wow6432Node\\\\'"}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'hkroot'}; {'id': '106', 'type': 'except_clause', 'children': ['107', '115']}, {'id': '107', 'type': 'as_pattern', 'children': ['108', '113']}; {'id': '108', 'type': 'attribute', 'children': ['109', '112']}, {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'WinError'}, {'id': '113', 'type': 'as_pattern_target', 'children': ['114']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'e'}, {'id': '115', 'type': 'block', 'children': ['116']}; {'id': '116', 'type': 'pass_statement', 'children': []}, {'id': '117', 'type': 'if_statement', 'children': ['118', '120']}; {'id': '118', 'type': 'not_operator', 'children': ['119']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'comps'}; {'id': '120', 'type': 'block', 'children': ['121']}, {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'assignment', 'children': ['123', '124']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'comps'}; {'id': '124', 'type': 'call', 'children': ['125', '128']}, {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'common'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'read_reg'}; {'id': '128', 'type': 'argument_list', 'children': ['129', '132']}, {'id': '129', 'type': 'binary_operator', 'children': ['130', '131'], 'value': '+'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'hkroot'}, {'id': '133', 'type': 'except_clause', 'children': ['134', '142']}; {'id': '134', 'type': 'as_pattern', 'children': ['135', '140']}, {'id': '135', 'type': 'attribute', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'Util'}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'WinError'}; {'id': '140', 'type': 'as_pattern_target', 'children': ['141']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '142', 'type': 'block', 'children': ['143']}, {'id': '143', 'type': 'expression_statement', 'children': ['144']}; {'id': '144', 'type': 'call', 'children': ['145', '146']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '146', 'type': 'argument_list', 'children': ['147']}, {'id': '147', 'type': 'call', 'children': ['148', '151']}; {'id': '148', 'type': 'attribute', 'children': ['149', '150']}, {'id': '149', 'type': 'string', 'children': [], 'value': "'find_vc_dir(): no VC registry key {}'"}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'format'}, {'id': '151', 'type': 'argument_list', 'children': ['152']}; {'id': '152', 'type': 'call', 'children': ['153', '154']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '154', 'type': 'argument_list', 'children': ['155']}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '156', 'type': 'else_clause', 'children': ['157']}, {'id': '157', 'type': 'block', 'children': ['158', '168']}; {'id': '158', 'type': 'expression_statement', 'children': ['159']}, {'id': '159', 'type': 'call', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'debug'}, {'id': '161', 'type': 'argument_list', 'children': ['162']}; {'id': '162', 'type': 'call', 'children': ['163', '166']}, {'id': '163', 'type': 'attribute', 'children': ['164', '165']}; {'id': '164', 'type': 'string', 'children': [], 'value': "'find_vc_dir(): found VC in registry: {}'"}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '166', 'type': 'argument_list', 'children': ['167']}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'comps'}; {'id': '168', 'type': 'if_statement', 'children': ['169', '177', '180']}, {'id': '169', 'type': 'call', 'children': ['170', '175']}; {'id': '170', 'type': 'attribute', 'children': ['171', '174']}, {'id': '171', 'type': 'attribute', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'exists'}, {'id': '175', 'type': 'argument_list', 'children': ['176']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'comps'}, {'id': '177', 'type': 'block', 'children': ['178']}; {'id': '178', 'type': 'return_statement', 'children': ['179']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'comps'}; {'id': '180', 'type': 'else_clause', 'children': ['181']}, {'id': '181', 'type': 'block', 'children': ['182', '192']}; {'id': '182', 'type': 'expression_statement', 'children': ['183']}, {'id': '183', 'type': 'call', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'debug'}, {'id': '185', 'type': 'argument_list', 'children': ['186']}; {'id': '186', 'type': 'call', 'children': ['187', '190']}, {'id': '187', 'type': 'attribute', 'children': ['188', '189']}; {'id': '188', 'type': 'string', 'children': [], 'value': "'find_vc_dir(): reg says dir is {}, but it does not exist. (ignoring)'"}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '190', 'type': 'argument_list', 'children': ['191']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'comps'}; {'id': '192', 'type': 'raise_statement', 'children': ['193']}, {'id': '193', 'type': 'call', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'MissingConfiguration'}, {'id': '195', 'type': 'argument_list', 'children': ['196']}; {'id': '196', 'type': 'call', 'children': ['197', '200']}, {'id': '197', 'type': 'attribute', 'children': ['198', '199']}; {'id': '198', 'type': 'string', 'children': [], 'value': '"registry dir {} not found on the filesystem"'}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '200', 'type': 'argument_list', 'children': ['201']}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'comps'}; {'id': '202', 'type': 'return_statement', 'children': ['203']}, {'id': '203', 'type': 'None', 'children': []}
def find_vc_pdir(msvc_version): root = 'Software\\' try: hkeys = _VCVER_TO_PRODUCT_DIR[msvc_version] except KeyError: debug("Unknown version of MSVC: %s" % msvc_version) raise UnsupportedVersion("Unknown version %s" % msvc_version) for hkroot, key in hkeys: try: comps = None if not key: comps = find_vc_pdir_vswhere(msvc_version) if not comps: debug('find_vc_dir(): no VC found via vswhere for version {}'.format(repr(key))) raise SCons.Util.WinError else: if common.is_win64(): try: comps = common.read_reg(root + 'Wow6432Node\\' + key, hkroot) except SCons.Util.WinError as e: pass if not comps: comps = common.read_reg(root + key, hkroot) except SCons.Util.WinError as e: debug('find_vc_dir(): no VC registry key {}'.format(repr(key))) else: debug('find_vc_dir(): found VC in registry: {}'.format(comps)) if os.path.exists(comps): return comps else: debug('find_vc_dir(): reg says dir is {}, but it does not exist. (ignoring)'.format(comps)) raise MissingConfiguration("registry dir {} not found on the filesystem".format(comps)) return None
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'allocate_stream'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'stream_type'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'stream_id'}; {'id': '8', 'type': 'None', 'children': []}, {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'previous'}, {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'attach'}; {'id': '14', 'type': 'False', 'children': []}, {'id': '15', 'type': 'block', 'children': ['16', '31', '55', '93', '101', '119', '131']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '22']}, {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': 'not'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'stream_type'}, {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'DataStream'}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'TypeToString'}; {'id': '22', 'type': 'block', 'children': ['23']}, {'id': '23', 'type': 'raise_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}, {'id': '27', 'type': 'string', 'children': [], 'value': '"Unknown stream type in allocate_stream"'}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'stream_type'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'stream_type'}, {'id': '31', 'type': 'if_statement', 'children': ['32', '41']}; {'id': '32', 'type': 'boolean_operator', 'children': ['33', '36'], 'value': 'and'}, {'id': '33', 'type': 'comparison_operator', 'children': ['34', '35'], 'value': 'is'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'stream_id'}, {'id': '35', 'type': 'None', 'children': []}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': '>='}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'stream_id'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'StreamAllocator'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'StartingID'}, {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'raise_statement', 'children': ['43']}, {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}, {'id': '45', 'type': 'argument_list', 'children': ['46', '47', '50']}; {'id': '46', 'type': 'string', 'children': [], 'value': '"Attempted to explicitly allocate a stream id in the internally managed id range"'}, {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'stream_id'}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'stream_id'}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'started_id'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'StreamAllocator'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'StartingID'}, {'id': '55', 'type': 'if_statement', 'children': ['56', '59']}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '58'], 'value': 'is'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'stream_id'}; {'id': '58', 'type': 'None', 'children': []}, {'id': '59', 'type': 'block', 'children': ['60', '77', '85']}; {'id': '60', 'type': 'if_statement', 'children': ['61', '66']}, {'id': '61', 'type': 'comparison_operator', 'children': ['62', '63'], 'value': 'not'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'stream_type'}, {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': '_next_id'}; {'id': '66', 'type': 'block', 'children': ['67']}, {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '74']}, {'id': '69', 'type': 'subscript', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': '_next_id'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'stream_type'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'StreamAllocator'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'StartingID'}, {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'stream_id'}; {'id': '80', 'type': 'subscript', 'children': ['81', '84']}, {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': '_next_id'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'stream_type'}, {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'augmented_assignment', 'children': ['87', '92'], 'value': '+='}, {'id': '87', 'type': 'subscript', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': '_next_id'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'stream_type'}; {'id': '92', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '96', 'type': 'call', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'DataStream'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'stream_type'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'stream_id'}, {'id': '101', 'type': 'if_statement', 'children': ['102', '107']}; {'id': '102', 'type': 'comparison_operator', 'children': ['103', '104'], 'value': 'not'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': '_allocated_streams'}, {'id': '107', 'type': 'block', 'children': ['108']}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}, {'id': '109', 'type': 'assignment', 'children': ['110', '115']}; {'id': '110', 'type': 'subscript', 'children': ['111', '114']}, {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': '_allocated_streams'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'stream'}, {'id': '115', 'type': 'tuple', 'children': ['116', '117', '118']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'stream'}, {'id': '117', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'previous'}, {'id': '119', 'type': 'if_statement', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'attach'}, {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}, {'id': '123', 'type': 'assignment', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'stream'}, {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'attach_stream'}, {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'stream'}, {'id': '131', 'type': 'return_statement', 'children': ['132']}
def allocate_stream(self, stream_type, stream_id=None, previous=None, attach=False): if stream_type not in DataStream.TypeToString: raise ArgumentError("Unknown stream type in allocate_stream", stream_type=stream_type) if stream_id is not None and stream_id >= StreamAllocator.StartingID: raise ArgumentError("Attempted to explicitly allocate a stream id in the internally managed id range", stream_id=stream_id, started_id=StreamAllocator.StartingID) if stream_id is None: if stream_type not in self._next_id: self._next_id[stream_type] = StreamAllocator.StartingID stream_id = self._next_id[stream_type] self._next_id[stream_type] += 1 stream = DataStream(stream_type, stream_id) if stream not in self._allocated_streams: self._allocated_streams[stream] = (stream, 0, previous) if attach: stream = self.attach_stream(stream) return stream
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_products'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'product_type'}; {'id': '6', 'type': 'block', 'children': ['7', '26', '83', '96', '107', '126']}, {'id': '7', 'type': 'if_statement', 'children': ['8', '23']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '18'], 'value': 'and'}, {'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': 'filter_prods'}, {'id': '13', 'type': 'comparison_operator', 'children': ['14', '15'], 'value': 'in'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'product_type'}, {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'LIST_PRODUCTS'}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': 'not'}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'product_type'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'desired_prods'}, {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'return_statement', 'children': ['25']}, {'id': '25', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '32', '45']}, {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'in'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'product_type'}, {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'LIST_PRODUCTS'}; {'id': '32', 'type': 'block', 'children': ['33']}, {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'found_products'}; {'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': 'products'}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'product_type'}; {'id': '44', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '45', 'type': 'else_clause', 'children': ['46']}; {'id': '46', 'type': 'block', 'children': ['47']}, {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'found_products'}; {'id': '50', 'type': 'list_comprehension', 'children': ['51', '54', '63']}, {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '53', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '54', 'type': 'for_in_clause', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '56', 'type': 'call', 'children': ['57', '62']}, {'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': 'products'}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '62', 'type': 'argument_list', 'children': []}, {'id': '63', 'type': 'if_clause', 'children': ['64']}; {'id': '64', 'type': 'boolean_operator', 'children': ['65', '70'], 'value': 'and'}, {'id': '65', 'type': 'comparison_operator', 'children': ['66', '69'], 'value': '=='}; {'id': '66', 'type': 'subscript', 'children': ['67', '68']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'product_type'}; {'id': '70', 'type': 'parenthesized_expression', 'children': ['71']}, {'id': '71', 'type': 'boolean_operator', 'children': ['72', '76'], 'value': 'or'}; {'id': '72', 'type': 'not_operator', 'children': ['73']}, {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'filter_prods'}; {'id': '76', 'type': 'comparison_operator', 'children': ['77', '80'], 'value': 'in'}, {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '79', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'desired_prods'}, {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'found_products'}; {'id': '86', 'type': 'list_comprehension', 'children': ['87', '93']}, {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': '_ensure_product_string'}, {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '93', 'type': 'for_in_clause', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'found_products'}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}, {'id': '97', 'type': 'assignment', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'declaration'}, {'id': '99', 'type': 'call', 'children': ['100', '105']}; {'id': '100', 'type': 'attribute', 'children': ['101', '104']}, {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'PATH_PRODUCTS'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'get'}, {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'product_type'}, {'id': '107', 'type': 'if_statement', 'children': ['108', '111']}; {'id': '108', 'type': 'comparison_operator', 'children': ['109', '110'], 'value': 'is'}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'declaration'}; {'id': '110', 'type': 'None', 'children': []}, {'id': '111', 'type': 'block', 'children': ['112']}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}, {'id': '113', 'type': 'assignment', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'found_products'}, {'id': '115', 'type': 'list_comprehension', 'children': ['116', '123']}; {'id': '116', 'type': 'call', 'children': ['117', '120']}, {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': '_process_product_path'}; {'id': '120', 'type': 'argument_list', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'declaration'}, {'id': '123', 'type': 'for_in_clause', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'found_products'}; {'id': '126', 'type': 'return_statement', 'children': ['127']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'found_products'}
def find_products(self, product_type): if self.filter_prods and product_type in self.LIST_PRODUCTS and product_type not in self.desired_prods: return [] if product_type in self.LIST_PRODUCTS: found_products = self.products.get(product_type, []) else: found_products = [x[0] for x in self.products.items() if x[1] == product_type and (not self.filter_prods or x[0] in self.desired_prods)] found_products = [self._ensure_product_string(x) for x in found_products] declaration = self.PATH_PRODUCTS.get(product_type) if declaration is not None: found_products = [self._process_product_path(x, declaration) for x in found_products] return found_products
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_node'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'node_descriptor'}; {'id': '6', 'type': 'block', 'children': ['7', '35', '48', '52', '190', '221', '230', '243', '251']}, {'id': '7', 'type': 'if_statement', 'children': ['8', '24']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '14'], 'value': 'and'}, {'id': '9', 'type': 'comparison_operator', 'children': ['10', '13'], 'value': 'is'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_max_nodes'}, {'id': '13', 'type': 'None', 'children': []}; {'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': 'nodes'}, {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '23', 'type': 'identifier', 'children': [], 'value': '_max_nodes'}; {'id': '24', 'type': 'block', 'children': ['25']}, {'id': '25', 'type': 'raise_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ResourceUsageError'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}, {'id': '29', 'type': 'string', 'children': [], 'value': '"Maximum number of nodes exceeded"'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'max_nodes'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_max_nodes'}, {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '41']}, {'id': '37', 'type': 'pattern_list', 'children': ['38', '39', '40']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'processor'}, {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'parse_node_descriptor'}, {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'node_descriptor'}, {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}, {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'in_root'}, {'id': '51', 'type': 'False', 'children': []}; {'id': '52', 'type': 'for_statement', 'children': ['53', '56', '60']}, {'id': '53', 'type': 'pattern_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'input_data'}; {'id': '56', 'type': 'call', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '60', 'type': 'block', 'children': ['61', '67', '78', '102', '111']}, {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '66']}, {'id': '63', 'type': 'pattern_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'selector'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'trigger'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'input_data'}, {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'walker'}; {'id': '70', 'type': 'call', 'children': ['71', '76']}, {'id': '71', 'type': 'attribute', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'sensor_log'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'create_walker'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '78', 'type': 'if_statement', 'children': ['79', '84']}, {'id': '79', 'type': 'attribute', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'walker'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'selector'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'inexhaustible'}; {'id': '84', 'type': 'block', 'children': ['85']}, {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '90']}, {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'walker'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'reading'}; {'id': '90', 'type': 'call', 'children': ['91', '92']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'IOTileReading'}; {'id': '92', 'type': 'argument_list', 'children': ['93', '94', '101']}, {'id': '93', 'type': 'integer', 'children': [], 'value': '0xFFFFFFFF'}; {'id': '94', 'type': 'call', 'children': ['95', '100']}, {'id': '95', 'type': 'attribute', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'walker'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'selector'}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'as_stream'}; {'id': '100', 'type': 'argument_list', 'children': []}, {'id': '101', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}, {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'connect_input'}, {'id': '107', 'type': 'argument_list', 'children': ['108', '109', '110']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'walker'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'trigger'}, {'id': '111', 'type': 'if_statement', 'children': ['112', '118', '132']}; {'id': '112', 'type': 'boolean_operator', 'children': ['113', '116'], 'value': 'and'}, {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'selector'}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'input'}; {'id': '116', 'type': 'not_operator', 'children': ['117']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'in_root'}; {'id': '118', 'type': 'block', 'children': ['119', '128']}, {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '126']}, {'id': '121', 'type': 'attribute', 'children': ['122', '125']}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'roots'}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}, {'id': '129', 'type': 'assignment', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'in_root'}, {'id': '131', 'type': 'True', 'children': []}; {'id': '132', 'type': 'else_clause', 'children': ['133']}, {'id': '133', 'type': 'block', 'children': ['134', '138', '165']}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}, {'id': '135', 'type': 'assignment', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'found'}, {'id': '137', 'type': 'False', 'children': []}; {'id': '138', 'type': 'for_statement', 'children': ['139', '140', '143']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'nodes'}, {'id': '143', 'type': 'block', 'children': ['144']}; {'id': '144', 'type': 'if_statement', 'children': ['145', '153']}, {'id': '145', 'type': 'call', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'matches'}, {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'stream'}, {'id': '153', 'type': 'block', 'children': ['154', '161']}; {'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': 'other'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'connect_output'}, {'id': '159', 'type': 'argument_list', 'children': ['160']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '161', 'type': 'expression_statement', 'children': ['162']}; {'id': '162', 'type': 'assignment', 'children': ['163', '164']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'found'}; {'id': '164', 'type': 'True', 'children': []}, {'id': '165', 'type': 'if_statement', 'children': ['166', '172']}; {'id': '166', 'type': 'boolean_operator', 'children': ['167', '169'], 'value': 'and'}, {'id': '167', 'type': 'not_operator', 'children': ['168']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'found'}, {'id': '169', 'type': 'attribute', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'selector'}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'buffered'}; {'id': '172', 'type': 'block', 'children': ['173']}, {'id': '173', 'type': 'raise_statement', 'children': ['174']}; {'id': '174', 'type': 'call', 'children': ['175', '176']}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'NodeConnectionError'}; {'id': '176', 'type': 'argument_list', 'children': ['177', '178', '181', '187']}, {'id': '177', 'type': 'string', 'children': [], 'value': '"Node has input that refers to another node that has not been created yet"'}; {'id': '178', 'type': 'keyword_argument', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'node_descriptor'}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'node_descriptor'}, {'id': '181', 'type': 'keyword_argument', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'input_selector'}, {'id': '183', 'type': 'call', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '185', 'type': 'argument_list', 'children': ['186']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'selector'}, {'id': '187', 'type': 'keyword_argument', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'input_index'}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '190', 'type': 'for_statement', 'children': ['191', '192', '195']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'other_node'}; {'id': '192', 'type': 'attribute', 'children': ['193', '194']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'nodes'}, {'id': '195', 'type': 'block', 'children': ['196']}; {'id': '196', 'type': 'for_statement', 'children': ['197', '200', '203']}, {'id': '197', 'type': 'pattern_list', 'children': ['198', '199']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'selector'}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'trigger'}; {'id': '200', 'type': 'attribute', 'children': ['201', '202']}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'other_node'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'inputs'}, {'id': '203', 'type': 'block', 'children': ['204']}; {'id': '204', 'type': 'if_statement', 'children': ['205', '213']}, {'id': '205', 'type': 'call', 'children': ['206', '209']}; {'id': '206', 'type': 'attribute', 'children': ['207', '208']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'matches'}, {'id': '209', 'type': 'argument_list', 'children': ['210']}; {'id': '210', 'type': 'attribute', 'children': ['211', '212']}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'stream'}, {'id': '213', 'type': 'block', 'children': ['214']}; {'id': '214', 'type': 'expression_statement', 'children': ['215']}, {'id': '215', 'type': 'call', 'children': ['216', '219']}; {'id': '216', 'type': 'attribute', 'children': ['217', '218']}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'connect_output'}, {'id': '219', 'type': 'argument_list', 'children': ['220']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'other_node'}, {'id': '221', 'type': 'expression_statement', 'children': ['222']}; {'id': '222', 'type': 'assignment', 'children': ['223', '224']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '224', 'type': 'call', 'children': ['225', '228']}, {'id': '225', 'type': 'attribute', 'children': ['226', '227']}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'find_processing_function'}; {'id': '228', 'type': 'argument_list', 'children': ['229']}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'processor'}; {'id': '230', 'type': 'if_statement', 'children': ['231', '234']}, {'id': '231', 'type': 'comparison_operator', 'children': ['232', '233'], 'value': 'is'}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'func'}, {'id': '233', 'type': 'None', 'children': []}; {'id': '234', 'type': 'block', 'children': ['235']}, {'id': '235', 'type': 'raise_statement', 'children': ['236']}; {'id': '236', 'type': 'call', 'children': ['237', '238']}, {'id': '237', 'type': 'identifier', 'children': [], 'value': 'ProcessingFunctionError'}; {'id': '238', 'type': 'argument_list', 'children': ['239', '240']}, {'id': '239', 'type': 'string', 'children': [], 'value': '"Could not find processing function in installed packages"'}; {'id': '240', 'type': 'keyword_argument', 'children': ['241', '242']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'func_name'}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'processor'}, {'id': '243', 'type': 'expression_statement', 'children': ['244']}; {'id': '244', 'type': 'call', 'children': ['245', '248']}, {'id': '245', 'type': 'attribute', 'children': ['246', '247']}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'set_func'}; {'id': '248', 'type': 'argument_list', 'children': ['249', '250']}, {'id': '249', 'type': 'identifier', 'children': [], 'value': 'processor'}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'func'}, {'id': '251', 'type': 'expression_statement', 'children': ['252']}; {'id': '252', 'type': 'call', 'children': ['253', '258']}, {'id': '253', 'type': 'attribute', 'children': ['254', '257']}; {'id': '254', 'type': 'attribute', 'children': ['255', '256']}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'nodes'}, {'id': '257', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '258', 'type': 'argument_list', 'children': ['259']}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'node'}
def add_node(self, node_descriptor): if self._max_nodes is not None and len(self.nodes) >= self._max_nodes: raise ResourceUsageError("Maximum number of nodes exceeded", max_nodes=self._max_nodes) node, inputs, processor = parse_node_descriptor(node_descriptor, self.model) in_root = False for i, input_data in enumerate(inputs): selector, trigger = input_data walker = self.sensor_log.create_walker(selector) if walker.selector.inexhaustible: walker.reading = IOTileReading(0xFFFFFFFF, walker.selector.as_stream(), 0) node.connect_input(i, walker, trigger) if selector.input and not in_root: self.roots.append(node) in_root = True else: found = False for other in self.nodes: if selector.matches(other.stream): other.connect_output(node) found = True if not found and selector.buffered: raise NodeConnectionError("Node has input that refers to another node that has not been created yet", node_descriptor=node_descriptor, input_selector=str(selector), input_index=i) for other_node in self.nodes: for selector, trigger in other_node.inputs: if selector.matches(node.stream): node.connect_output(other_node) func = self.find_processing_function(processor) if func is None: raise ProcessingFunctionError("Could not find processing function in installed packages", func_name=processor) node.set_func(processor, func) self.nodes.append(node)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_streamers'}, {'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': 'blacklist'}, {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '13', '19', '161']}, {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ready'}; {'id': '12', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'selected'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '18', 'type': 'argument_list', 'children': []}, {'id': '19', 'type': 'for_statement', 'children': ['20', '23', '29']}; {'id': '20', 'type': 'pattern_list', 'children': ['21', '22']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'streamer'}, {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'enumerate'}, {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'streamers'}, {'id': '29', 'type': 'block', 'children': ['30', '40', '46', '50', '70']}; {'id': '30', 'type': 'if_statement', 'children': ['31', '38']}, {'id': '31', 'type': 'boolean_operator', 'children': ['32', '35'], 'value': 'and'}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '34'], 'value': 'is'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'blacklist'}; {'id': '34', 'type': 'None', 'children': []}, {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'in'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'blacklist'}; {'id': '38', 'type': 'block', 'children': ['39']}, {'id': '39', 'type': 'continue_statement', 'children': []}; {'id': '40', 'type': 'if_statement', 'children': ['41', '44']}, {'id': '41', 'type': 'comparison_operator', 'children': ['42', '43'], 'value': 'in'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'selected'}; {'id': '44', 'type': 'block', 'children': ['45']}, {'id': '45', 'type': 'continue_statement', 'children': []}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}, {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'marked'}, {'id': '49', 'type': 'False', 'children': []}; {'id': '50', 'type': 'if_statement', 'children': ['51', '56']}, {'id': '51', 'type': 'comparison_operator', 'children': ['52', '53'], 'value': 'in'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': '_manually_triggered_streamers'}; {'id': '56', 'type': 'block', 'children': ['57', '61']}, {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'marked'}; {'id': '60', 'type': 'True', 'children': []}, {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '68']}, {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '_manually_triggered_streamers'}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '70', 'type': 'if_statement', 'children': ['71', '77']}, {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'streamer'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'triggered'}, {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'marked'}, {'id': '77', 'type': 'block', 'children': ['78', '89', '96', '103']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}, {'id': '79', 'type': 'call', 'children': ['80', '85']}; {'id': '80', 'type': 'attribute', 'children': ['81', '84']}, {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'debug'}, {'id': '85', 'type': 'argument_list', 'children': ['86', '87', '88']}; {'id': '86', 'type': 'string', 'children': [], 'value': '"Streamer %d triggered, manual=%s"'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'marked'}, {'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': 'ready'}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'streamer'}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}, {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'selected'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'add'}, {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '103', 'type': 'for_statement', 'children': ['104', '107', '117']}; {'id': '104', 'type': 'pattern_list', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'streamer2'}, {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'enumerate'}, {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'subscript', 'children': ['111', '114']}, {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'streamers'}; {'id': '114', 'type': 'slice', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '116', 'type': 'colon', 'children': []}, {'id': '117', 'type': 'block', 'children': ['118']}; {'id': '118', 'type': 'if_statement', 'children': ['119', '135']}, {'id': '119', 'type': 'boolean_operator', 'children': ['120', '129'], 'value': 'and'}; {'id': '120', 'type': 'boolean_operator', 'children': ['121', '126'], 'value': 'and'}, {'id': '121', 'type': 'comparison_operator', 'children': ['122', '125'], 'value': '=='}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'streamer2'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'with_other'}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '126', 'type': 'comparison_operator', 'children': ['127', '128'], 'value': 'not'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'selected'}, {'id': '129', 'type': 'call', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'streamer2'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'triggered'}, {'id': '133', 'type': 'argument_list', 'children': ['134']}; {'id': '134', 'type': 'True', 'children': []}, {'id': '135', 'type': 'block', 'children': ['136', '147', '154']}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}, {'id': '137', 'type': 'call', 'children': ['138', '143']}; {'id': '138', 'type': 'attribute', 'children': ['139', '142']}, {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '141', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'debug'}, {'id': '143', 'type': 'argument_list', 'children': ['144', '145', '146']}; {'id': '144', 'type': 'string', 'children': [], 'value': '"Streamer %d triggered due to with-other on %d"'}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'call', 'children': ['149', '152']}, {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'ready'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '152', 'type': 'argument_list', 'children': ['153']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'streamer2'}; {'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': 'selected'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'add'}, {'id': '159', 'type': 'argument_list', 'children': ['160']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'j'}, {'id': '161', 'type': 'return_statement', 'children': ['162']}
def check_streamers(self, blacklist=None): ready = [] selected = set() for i, streamer in enumerate(self.streamers): if blacklist is not None and i in blacklist: continue if i in selected: continue marked = False if i in self._manually_triggered_streamers: marked = True self._manually_triggered_streamers.remove(i) if streamer.triggered(marked): self._logger.debug("Streamer %d triggered, manual=%s", i, marked) ready.append(streamer) selected.add(i) for j, streamer2 in enumerate(self.streamers[i:]): if streamer2.with_other == i and j not in selected and streamer2.triggered(True): self._logger.debug("Streamer %d triggered due to with-other on %d", j, i) ready.append(streamer2) selected.add(j) return ready
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_nodes'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6', '26', '30', '69', '76', '90']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}, {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'node_map'}, {'id': '9', 'type': 'dictionary_comprehension', 'children': ['10', '16']}; {'id': '10', 'type': 'pair', 'children': ['11', '15']}, {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'id'}, {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '16', 'type': 'for_in_clause', 'children': ['17', '20']}, {'id': '17', 'type': 'pattern_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}, {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}, {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'node_deps'}, {'id': '29', 'type': 'dictionary', 'children': []}; {'id': '30', 'type': 'for_statement', 'children': ['31', '35', '40']}, {'id': '31', 'type': 'pattern_list', 'children': ['32', '33', '34']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_outputs'}, {'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': 'iterate_bfs'}, {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'block', 'children': ['41', '50', '63']}, {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'node_index'}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'node_map'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}, {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'deps'}, {'id': '53', 'type': 'set_comprehension', 'children': ['54', '60']}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'node_map'}; {'id': '56', 'type': 'call', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '60', 'type': 'for_in_clause', 'children': ['61', '62']}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'inputs'}, {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '68']}, {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'node_deps'}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'node_index'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'deps'}, {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'node_order'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'toposort_flatten'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'node_deps'}; {'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': 'nodes'}, {'id': '81', 'type': 'list_comprehension', 'children': ['82', '87']}; {'id': '82', 'type': 'subscript', 'children': ['83', '86']}, {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '87', 'type': 'for_in_clause', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'node_order'}; {'id': '90', 'type': 'for_statement', 'children': ['91', '92', '95']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'roots'}, {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'if_statement', 'children': ['97', '112']}, {'id': '97', 'type': 'comparison_operator', 'children': ['98', '99'], 'value': 'not'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '99', 'type': 'subscript', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'nodes'}, {'id': '103', 'type': 'slice', 'children': ['104', '105', '106']}; {'id': '104', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '105', 'type': 'colon', 'children': []}; {'id': '106', 'type': 'call', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}, {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'roots'}; {'id': '112', 'type': 'block', 'children': ['113']}, {'id': '113', 'type': 'raise_statement', 'children': ['114']}; {'id': '114', 'type': 'call', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'NodeConnectionError'}; {'id': '116', 'type': 'argument_list', 'children': ['117', '118', '124']}, {'id': '117', 'type': 'string', 'children': [], 'value': '"Inputs not sorted in the beginning"'}; {'id': '118', 'type': 'keyword_argument', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '120', 'type': 'call', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '124', 'type': 'keyword_argument', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'node_position'}; {'id': '126', 'type': 'call', 'children': ['127', '132']}, {'id': '127', 'type': 'attribute', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'nodes'}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '132', 'type': 'argument_list', 'children': ['133']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'root'}
def sort_nodes(self): node_map = {id(node): i for i, node in enumerate(self.nodes)} node_deps = {} for node, inputs, _outputs in self.iterate_bfs(): node_index = node_map[id(node)] deps = {node_map[id(x)] for x in inputs} node_deps[node_index] = deps node_order = toposort_flatten(node_deps) self.nodes = [self.nodes[x] for x in node_order] for root in self.roots: if root not in self.nodes[0:len(self.roots)]: raise NodeConnectionError("Inputs not sorted in the beginning", node=str(root), node_position=self.nodes.index(root))
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mark_typed_list'}, {'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': 'identifier', 'children': [], 'value': 'type_object'}, {'id': '7', 'type': 'block', 'children': ['8', '23', '38', '80', '103']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '15']}, {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'type_object'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'dump'"}, {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'raise_statement', 'children': ['17']}, {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}, {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '22'], 'value': '%'}, {'id': '21', 'type': 'string', 'children': [], 'value': '"The passed type object %s is missing required method: dump()"'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'type_object'}, {'id': '23', 'type': 'if_statement', 'children': ['24', '30']}; {'id': '24', 'type': 'not_operator', 'children': ['25']}, {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'hasattr'}, {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'type_object'}, {'id': '29', 'type': 'string', 'children': [], 'value': "'Restore'"}; {'id': '30', 'type': 'block', 'children': ['31']}, {'id': '31', 'type': 'raise_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}, {'id': '35', 'type': 'binary_operator', 'children': ['36', '37'], 'value': '%'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"The passed type object %s is missing required method: Restore()"'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'type_object'}; {'id': '38', 'type': 'function_definition', 'children': ['39', '40', '42']}, {'id': '39', 'type': 'function_name', 'children': [], 'value': '_dump_list'}; {'id': '40', 'type': 'parameters', 'children': ['41']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '42', 'type': 'block', 'children': ['43', '50', '70']}, {'id': '43', 'type': 'if_statement', 'children': ['44', '47']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '46'], 'value': 'is'}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '46', 'type': 'None', 'children': []}, {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'return_statement', 'children': ['49']}, {'id': '49', 'type': 'None', 'children': []}; {'id': '50', 'type': 'if_statement', 'children': ['51', '57']}, {'id': '51', 'type': 'not_operator', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'list'}, {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'raise_statement', 'children': ['59']}, {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'DataError'}, {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'binary_operator', 'children': ['63', '64'], 'value': '%'}, {'id': '63', 'type': 'string', 'children': [], 'value': '"Property %s marked as list was not a list: %s"'}; {'id': '64', 'type': 'tuple', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '70', 'type': 'return_statement', 'children': ['71']}, {'id': '71', 'type': 'list_comprehension', 'children': ['72', '77']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}, {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'dump'}; {'id': '76', 'type': 'argument_list', 'children': []}, {'id': '77', 'type': 'for_in_clause', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '80', 'type': 'function_definition', 'children': ['81', '82', '84']}, {'id': '81', 'type': 'function_name', 'children': [], 'value': '_restore_list'}; {'id': '82', 'type': 'parameters', 'children': ['83']}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '84', 'type': 'block', 'children': ['85', '92']}, {'id': '85', 'type': 'if_statement', 'children': ['86', '89']}; {'id': '86', 'type': 'comparison_operator', 'children': ['87', '88'], 'value': 'is'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '88', 'type': 'None', 'children': []}, {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'return_statement', 'children': ['91']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '92', 'type': 'return_statement', 'children': ['93']}, {'id': '93', 'type': 'list_comprehension', 'children': ['94', '100']}; {'id': '94', 'type': 'call', 'children': ['95', '98']}, {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'type_object'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'Restore'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '100', 'type': 'for_in_clause', 'children': ['101', '102']}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'obj'}, {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '108']}, {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'mark_complex'}; {'id': '108', 'type': 'argument_list', 'children': ['109', '110', '111']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': '_dump_list'}, {'id': '111', 'type': 'identifier', 'children': [], 'value': '_restore_list'}
def mark_typed_list(self, name, type_object): if not hasattr(type_object, 'dump'): raise ArgumentError("The passed type object %s is missing required method: dump()" % type_object) if not hasattr(type_object, 'Restore'): raise ArgumentError("The passed type object %s is missing required method: Restore()" % type_object) def _dump_list(obj): if obj is None: return None if not isinstance(obj, list): raise DataError("Property %s marked as list was not a list: %s" % (name, repr(obj))) return [x.dump() for x in obj] def _restore_list(obj): if obj is None: return obj return [type_object.Restore(x) for x in obj] self.mark_complex(name, _dump_list, _restore_list)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mark_typed_map'}, {'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': 'identifier', 'children': [], 'value': 'type_object'}, {'id': '7', 'type': 'block', 'children': ['8', '23', '38', '88', '119']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '15']}, {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'type_object'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'dump'"}, {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'raise_statement', 'children': ['17']}, {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}, {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '22'], 'value': '%'}, {'id': '21', 'type': 'string', 'children': [], 'value': '"The passed type object %s is missing required method: dump()"'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'type_object'}, {'id': '23', 'type': 'if_statement', 'children': ['24', '30']}; {'id': '24', 'type': 'not_operator', 'children': ['25']}, {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'hasattr'}, {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'type_object'}, {'id': '29', 'type': 'string', 'children': [], 'value': "'Restore'"}; {'id': '30', 'type': 'block', 'children': ['31']}, {'id': '31', 'type': 'raise_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}, {'id': '35', 'type': 'binary_operator', 'children': ['36', '37'], 'value': '%'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"The passed type object %s is missing required method: Restore()"'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'type_object'}; {'id': '38', 'type': 'function_definition', 'children': ['39', '40', '42']}, {'id': '39', 'type': 'function_name', 'children': [], 'value': '_dump_map'}; {'id': '40', 'type': 'parameters', 'children': ['41']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '42', 'type': 'block', 'children': ['43', '50', '70']}, {'id': '43', 'type': 'if_statement', 'children': ['44', '47']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '46'], 'value': 'is'}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '46', 'type': 'None', 'children': []}, {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'return_statement', 'children': ['49']}, {'id': '49', 'type': 'None', 'children': []}; {'id': '50', 'type': 'if_statement', 'children': ['51', '57']}, {'id': '51', 'type': 'not_operator', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'dict'}, {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'raise_statement', 'children': ['59']}, {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'DataError'}, {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'binary_operator', 'children': ['63', '64'], 'value': '%'}, {'id': '63', 'type': 'string', 'children': [], 'value': '"Property %s marked as list was not a dict: %s"'}; {'id': '64', 'type': 'tuple', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '70', 'type': 'return_statement', 'children': ['71']}, {'id': '71', 'type': 'dictionary_comprehension', 'children': ['72', '79']}; {'id': '72', 'type': 'pair', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '74', 'type': 'call', 'children': ['75', '78']}, {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'dump'}; {'id': '78', 'type': 'argument_list', 'children': []}, {'id': '79', 'type': 'for_in_clause', 'children': ['80', '83']}; {'id': '80', 'type': 'pattern_list', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'val'}, {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'items'}, {'id': '87', 'type': 'argument_list', 'children': []}; {'id': '88', 'type': 'function_definition', 'children': ['89', '90', '92']}, {'id': '89', 'type': 'function_name', 'children': [], 'value': '_restore_map'}; {'id': '90', 'type': 'parameters', 'children': ['91']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '92', 'type': 'block', 'children': ['93', '100']}, {'id': '93', 'type': 'if_statement', 'children': ['94', '97']}; {'id': '94', 'type': 'comparison_operator', 'children': ['95', '96'], 'value': 'is'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '96', 'type': 'None', 'children': []}, {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'return_statement', 'children': ['99']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '100', 'type': 'return_statement', 'children': ['101']}, {'id': '101', 'type': 'dictionary_comprehension', 'children': ['102', '110']}; {'id': '102', 'type': 'pair', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '104', 'type': 'call', 'children': ['105', '108']}, {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'type_object'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'Restore'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '110', 'type': 'for_in_clause', 'children': ['111', '114']}, {'id': '111', 'type': 'pattern_list', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '114', 'type': 'call', 'children': ['115', '118']}, {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'obj'}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '118', 'type': 'argument_list', 'children': []}, {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '124']}, {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'mark_complex'}; {'id': '124', 'type': 'argument_list', 'children': ['125', '126', '127']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': '_dump_map'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': '_restore_map'}
def mark_typed_map(self, name, type_object): if not hasattr(type_object, 'dump'): raise ArgumentError("The passed type object %s is missing required method: dump()" % type_object) if not hasattr(type_object, 'Restore'): raise ArgumentError("The passed type object %s is missing required method: Restore()" % type_object) def _dump_map(obj): if obj is None: return None if not isinstance(obj, dict): raise DataError("Property %s marked as list was not a dict: %s" % (name, repr(obj))) return {key: val.dump() for key, val in obj.items()} def _restore_map(obj): if obj is None: return obj return {key: type_object.Restore(val) for key, val in obj.items()} self.mark_complex(name, _dump_map, _restore_map)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mark_typed_object'}, {'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': 'identifier', 'children': [], 'value': 'type_object'}, {'id': '7', 'type': 'block', 'children': ['8', '23', '38', '56', '75']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '15']}, {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'type_object'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'dump'"}, {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'raise_statement', 'children': ['17']}, {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}, {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '22'], 'value': '%'}, {'id': '21', 'type': 'string', 'children': [], 'value': '"The passed type object %s is missing required method: dump()"'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'type_object'}, {'id': '23', 'type': 'if_statement', 'children': ['24', '30']}; {'id': '24', 'type': 'not_operator', 'children': ['25']}, {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'hasattr'}, {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'type_object'}, {'id': '29', 'type': 'string', 'children': [], 'value': "'Restore'"}; {'id': '30', 'type': 'block', 'children': ['31']}, {'id': '31', 'type': 'raise_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}, {'id': '35', 'type': 'binary_operator', 'children': ['36', '37'], 'value': '%'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"The passed type object %s is missing required method: Restore()"'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'type_object'}; {'id': '38', 'type': 'function_definition', 'children': ['39', '40', '42']}, {'id': '39', 'type': 'function_name', 'children': [], 'value': '_dump_obj'}; {'id': '40', 'type': 'parameters', 'children': ['41']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '42', 'type': 'block', 'children': ['43', '50']}, {'id': '43', 'type': 'if_statement', 'children': ['44', '47']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '46'], 'value': 'is'}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '46', 'type': 'None', 'children': []}, {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'return_statement', 'children': ['49']}, {'id': '49', 'type': 'None', 'children': []}; {'id': '50', 'type': 'return_statement', 'children': ['51']}, {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'dump'}, {'id': '55', 'type': 'argument_list', 'children': []}; {'id': '56', 'type': 'function_definition', 'children': ['57', '58', '60']}, {'id': '57', 'type': 'function_name', 'children': [], 'value': '_restore_obj'}; {'id': '58', 'type': 'parameters', 'children': ['59']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '60', 'type': 'block', 'children': ['61', '68']}, {'id': '61', 'type': 'if_statement', 'children': ['62', '65']}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '64'], 'value': 'is'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '64', 'type': 'None', 'children': []}, {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'return_statement', 'children': ['67']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '68', 'type': 'return_statement', 'children': ['69']}, {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'type_object'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'Restore'}, {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'obj'}, {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}, {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'mark_complex'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '82', '83']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': '_dump_obj'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': '_restore_obj'}
def mark_typed_object(self, name, type_object): if not hasattr(type_object, 'dump'): raise ArgumentError("The passed type object %s is missing required method: dump()" % type_object) if not hasattr(type_object, 'Restore'): raise ArgumentError("The passed type object %s is missing required method: Restore()" % type_object) def _dump_obj(obj): if obj is None: return None return obj.dump() def _restore_obj(obj): if obj is None: return obj return type_object.Restore(obj) self.mark_complex(name, _dump_obj, _restore_obj)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scan'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'libpath'}; {'id': '8', 'type': 'tuple', 'children': []}, {'id': '9', 'type': 'block', 'children': ['10', '23', '31', '63', '95', '99', '128', '132', '144', '154', '162', '221']}; {'id': '10', 'type': 'try_statement', 'children': ['11', '18']}, {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}, {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'libs'}, {'id': '15', 'type': 'subscript', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '17', 'type': 'string', 'children': [], 'value': "'LIBS'"}; {'id': '18', 'type': 'except_clause', 'children': ['19', '20']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '20', 'type': 'block', 'children': ['21']}, {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'libs'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': '_subst_libs'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'libs'}, {'id': '31', 'type': 'try_statement', 'children': ['32', '55']}; {'id': '32', 'type': 'block', 'children': ['33', '39']}, {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'LIBPREFIXES'"}, {'id': '39', 'type': 'if_statement', 'children': ['40', '49']}; {'id': '40', 'type': 'not_operator', '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': 'SCons'}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'is_List'}, {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'prefix'}, {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}, {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'prefix'}, {'id': '53', 'type': 'list', 'children': ['54'], 'value': '[ prefix ]'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'prefix'}, {'id': '55', 'type': 'except_clause', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'KeyError'}, {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}, {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'prefix'}, {'id': '61', 'type': 'list', 'children': ['62'], 'value': "[ '' ]"}; {'id': '62', 'type': 'string', 'children': [], 'value': "''"}, {'id': '63', 'type': 'try_statement', 'children': ['64', '87']}; {'id': '64', 'type': 'block', 'children': ['65', '71']}, {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '68', 'type': 'subscript', 'children': ['69', '70']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '70', 'type': 'string', 'children': [], 'value': "'LIBSUFFIXES'"}, {'id': '71', 'type': 'if_statement', 'children': ['72', '81']}; {'id': '72', 'type': 'not_operator', 'children': ['73']}, {'id': '73', 'type': 'call', 'children': ['74', '79']}; {'id': '74', 'type': 'attribute', 'children': ['75', '78']}, {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'is_List'}, {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'suffix'}, {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}, {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'suffix'}, {'id': '85', 'type': 'list', 'children': ['86'], 'value': '[ suffix ]'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'suffix'}, {'id': '87', 'type': 'except_clause', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'KeyError'}, {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}, {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'suffix'}, {'id': '93', 'type': 'list', 'children': ['94'], 'value': "[ '' ]"}; {'id': '94', 'type': 'string', 'children': [], 'value': "''"}, {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'pairs'}; {'id': '98', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '99', 'type': 'for_statement', 'children': ['100', '101', '108']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'suf'}, {'id': '101', 'type': 'call', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'map'}, {'id': '103', 'type': 'argument_list', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'subst'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '108', 'type': 'block', 'children': ['109']}, {'id': '109', 'type': 'for_statement', 'children': ['110', '111', '118']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'pref'}, {'id': '111', 'type': 'call', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'map'}, {'id': '113', 'type': 'argument_list', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'subst'}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '118', 'type': 'block', 'children': ['119']}, {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '124']}, {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'pairs'}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}, {'id': '125', 'type': 'tuple', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'pref'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'suf'}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}, {'id': '129', 'type': 'assignment', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '131', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '132', 'type': 'if_statement', 'children': ['133', '137']}, {'id': '133', 'type': 'call', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'callable'}, {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'libpath'}, {'id': '137', 'type': 'block', 'children': ['138']}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}, {'id': '139', 'type': 'assignment', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'libpath'}, {'id': '141', 'type': 'call', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'libpath'}, {'id': '143', 'type': 'argument_list', 'children': []}; {'id': '144', 'type': 'expression_statement', 'children': ['145']}, {'id': '145', 'type': 'assignment', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'find_file'}, {'id': '147', 'type': 'attribute', 'children': ['148', '153']}; {'id': '148', 'type': 'attribute', 'children': ['149', '152']}, {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'Node'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'FS'}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'find_file'}; {'id': '154', 'type': 'expression_statement', 'children': ['155']}, {'id': '155', 'type': 'assignment', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'adjustixes'}, {'id': '157', 'type': 'attribute', 'children': ['158', '161']}; {'id': '158', 'type': 'attribute', 'children': ['159', '160']}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'Util'}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'adjustixes'}; {'id': '162', 'type': 'for_statement', 'children': ['163', '164', '165']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'lib'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'libs'}, {'id': '165', 'type': 'block', 'children': ['166']}; {'id': '166', 'type': 'if_statement', 'children': ['167', '175', '212']}, {'id': '167', 'type': 'call', 'children': ['168', '173']}; {'id': '168', 'type': 'attribute', 'children': ['169', '172']}, {'id': '169', 'type': 'attribute', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'is_String'}, {'id': '173', 'type': 'argument_list', 'children': ['174']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'lib'}, {'id': '175', 'type': 'block', 'children': ['176']}; {'id': '176', 'type': 'for_statement', 'children': ['177', '180', '181']}, {'id': '177', 'type': 'pattern_list', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'pref'}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'suf'}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'pairs'}, {'id': '181', 'type': 'block', 'children': ['182', '191', '202']}; {'id': '182', 'type': 'expression_statement', 'children': ['183']}, {'id': '183', 'type': 'assignment', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'l'}, {'id': '185', 'type': 'call', 'children': ['186', '187']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'adjustixes'}, {'id': '187', 'type': 'argument_list', 'children': ['188', '189', '190']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'lib'}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'pref'}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'suf'}, {'id': '191', 'type': 'expression_statement', 'children': ['192']}; {'id': '192', 'type': 'assignment', 'children': ['193', '194']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '194', 'type': 'call', 'children': ['195', '196']}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'find_file'}; {'id': '196', 'type': 'argument_list', 'children': ['197', '198', '199']}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'libpath'}, {'id': '199', 'type': 'keyword_argument', 'children': ['200', '201']}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'verbose'}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'print_find_libs'}; {'id': '202', 'type': 'if_statement', 'children': ['203', '204']}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '204', 'type': 'block', 'children': ['205']}, {'id': '205', 'type': 'expression_statement', 'children': ['206']}; {'id': '206', 'type': 'call', 'children': ['207', '210']}, {'id': '207', 'type': 'attribute', 'children': ['208', '209']}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '210', 'type': 'argument_list', 'children': ['211']}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '212', 'type': 'else_clause', 'children': ['213']}, {'id': '213', 'type': 'block', 'children': ['214']}; {'id': '214', 'type': 'expression_statement', 'children': ['215']}, {'id': '215', 'type': 'call', 'children': ['216', '219']}; {'id': '216', 'type': 'attribute', 'children': ['217', '218']}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '219', 'type': 'argument_list', 'children': ['220']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'lib'}, {'id': '221', 'type': 'return_statement', 'children': ['222']}
def scan(node, env, libpath = ()): try: libs = env['LIBS'] except KeyError: return [] libs = _subst_libs(env, libs) try: prefix = env['LIBPREFIXES'] if not SCons.Util.is_List(prefix): prefix = [ prefix ] except KeyError: prefix = [ '' ] try: suffix = env['LIBSUFFIXES'] if not SCons.Util.is_List(suffix): suffix = [ suffix ] except KeyError: suffix = [ '' ] pairs = [] for suf in map(env.subst, suffix): for pref in map(env.subst, prefix): pairs.append((pref, suf)) result = [] if callable(libpath): libpath = libpath() find_file = SCons.Node.FS.find_file adjustixes = SCons.Util.adjustixes for lib in libs: if SCons.Util.is_String(lib): for pref, suf in pairs: l = adjustixes(lib, pref, suf) l = find_file(l, libpath, verbose=print_find_libs) if l: result.append(l) else: result.append(lib) return result
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_recursive_template'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'template_folder'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'out_folder'}, {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'preserve'}, {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'dry_run'}; {'id': '12', 'type': 'False', 'children': []}, {'id': '13', 'type': 'block', 'children': ['14', '29', '38', '45', '55', '67', '111', '115', '119', '245', '361']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '20']}, {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'isinstance'}, {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'preserve'}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '20', 'type': 'block', 'children': ['21']}, {'id': '21', 'type': 'raise_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}, {'id': '25', 'type': 'string', 'children': [], 'value': '"You must pass a list of strings to preserve, not a string"'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'preserve'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'preserve'}, {'id': '29', 'type': 'if_statement', 'children': ['30', '33']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': 'is'}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'preserve'}; {'id': '32', 'type': 'None', 'children': []}, {'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': 'preserve'}, {'id': '37', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}, {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'preserve'}, {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'set'}, {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'preserve'}, {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'template_dir'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'resource_path'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}, {'id': '51', 'type': 'string', 'children': [], 'value': "'templates'"}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'expect'}; {'id': '54', 'type': 'string', 'children': [], 'value': "'folder'"}, {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'indir'}; {'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': 'os'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'template_dir'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'template_folder'}, {'id': '67', 'type': 'if_statement', 'children': ['68', '77', '89']}; {'id': '68', 'type': 'not_operator', 'children': ['69']}, {'id': '69', 'type': 'call', 'children': ['70', '75']}; {'id': '70', 'type': 'attribute', 'children': ['71', '74']}, {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'exists'}, {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'indir'}, {'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': 'ArgumentError'}, {'id': '81', 'type': 'argument_list', 'children': ['82', '83', '86']}; {'id': '82', 'type': 'string', 'children': [], 'value': '"Input template folder for recursive template not found"'}, {'id': '83', 'type': 'keyword_argument', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'template_folder'}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'template_folder'}; {'id': '86', 'type': 'keyword_argument', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'absolute_path'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'indir'}, {'id': '89', 'type': 'elif_clause', 'children': ['90', '99']}; {'id': '90', 'type': 'not_operator', 'children': ['91']}, {'id': '91', 'type': 'call', 'children': ['92', '97']}; {'id': '92', 'type': 'attribute', 'children': ['93', '96']}, {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'isdir'}, {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'indir'}, {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'raise_statement', 'children': ['101']}, {'id': '101', 'type': 'call', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}, {'id': '103', 'type': 'argument_list', 'children': ['104', '105', '108']}; {'id': '104', 'type': 'string', 'children': [], 'value': '"Input template folder is not a directory"'}, {'id': '105', 'type': 'keyword_argument', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'template_folder'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'template_folder'}; {'id': '108', 'type': 'keyword_argument', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'absolute_path'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'indir'}, {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'assignment', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'create_dirs'}; {'id': '114', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'assignment', 'children': ['117', '118']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'file_map'}; {'id': '118', 'type': 'dictionary', 'children': []}, {'id': '119', 'type': 'for_statement', 'children': ['120', '124', '130']}; {'id': '120', 'type': 'pattern_list', 'children': ['121', '122', '123']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'dirpath'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'dirs'}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '124', 'type': 'call', 'children': ['125', '128']}, {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'walk'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'indir'}; {'id': '130', 'type': 'block', 'children': ['131']}, {'id': '131', 'type': 'for_statement', 'children': ['132', '133', '134']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'file'}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '134', 'type': 'block', 'children': ['135', '154', '176', '204', '212']}, {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'assignment', 'children': ['137', '138']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'in_abspath'}; {'id': '138', 'type': 'call', 'children': ['139', '144']}, {'id': '139', 'type': 'attribute', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}, {'id': '145', 'type': 'call', 'children': ['146', '151']}; {'id': '146', 'type': 'attribute', 'children': ['147', '150']}, {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '151', 'type': 'argument_list', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'dirpath'}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '154', 'type': 'expression_statement', 'children': ['155']}, {'id': '155', 'type': 'assignment', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'in_path'}, {'id': '157', 'type': 'call', 'children': ['158', '163']}; {'id': '158', 'type': 'attribute', 'children': ['159', '162']}, {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'relpath'}, {'id': '163', 'type': 'argument_list', 'children': ['164', '173']}; {'id': '164', 'type': 'call', 'children': ['165', '170']}, {'id': '165', 'type': 'attribute', 'children': ['166', '169']}; {'id': '166', 'type': 'attribute', 'children': ['167', '168']}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '170', 'type': 'argument_list', 'children': ['171', '172']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'dirpath'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'file'}, {'id': '173', 'type': 'keyword_argument', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'start'}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'indir'}; {'id': '176', 'type': 'if_statement', 'children': ['177', '188', '198']}, {'id': '177', 'type': 'boolean_operator', 'children': ['178', '184'], 'value': 'and'}; {'id': '178', 'type': 'call', 'children': ['179', '182']}, {'id': '179', 'type': 'attribute', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'file'}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '182', 'type': 'argument_list', 'children': ['183']}, {'id': '183', 'type': 'string', 'children': [], 'value': '".tpl"'}; {'id': '184', 'type': 'not_operator', 'children': ['185']}, {'id': '185', 'type': 'comparison_operator', 'children': ['186', '187'], 'value': 'in'}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'in_path'}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'preserve'}; {'id': '188', 'type': 'block', 'children': ['189']}, {'id': '189', 'type': 'expression_statement', 'children': ['190']}; {'id': '190', 'type': 'assignment', 'children': ['191', '192']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'out_path'}; {'id': '192', 'type': 'subscript', 'children': ['193', '194']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'in_path'}; {'id': '194', 'type': 'slice', 'children': ['195', '196']}, {'id': '195', 'type': 'colon', 'children': []}; {'id': '196', 'type': 'unary_operator', 'children': ['197'], 'value': '-'}, {'id': '197', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '198', 'type': 'else_clause', 'children': ['199']}, {'id': '199', 'type': 'block', 'children': ['200']}; {'id': '200', 'type': 'expression_statement', 'children': ['201']}, {'id': '201', 'type': 'assignment', 'children': ['202', '203']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'out_path'}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'in_path'}; {'id': '204', 'type': 'expression_statement', 'children': ['205']}, {'id': '205', 'type': 'assignment', 'children': ['206', '209']}; {'id': '206', 'type': 'subscript', 'children': ['207', '208']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'file_map'}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'out_path'}, {'id': '209', 'type': 'tuple', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'in_path'}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'in_abspath'}; {'id': '212', 'type': 'for_statement', 'children': ['213', '214', '215']}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'folder'}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'dirs'}, {'id': '215', 'type': 'block', 'children': ['216', '238']}; {'id': '216', 'type': 'expression_statement', 'children': ['217']}, {'id': '217', 'type': 'assignment', 'children': ['218', '219']}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'dir_path'}, {'id': '219', 'type': 'call', 'children': ['220', '225']}; {'id': '220', 'type': 'attribute', 'children': ['221', '224']}, {'id': '221', 'type': 'attribute', 'children': ['222', '223']}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'relpath'}, {'id': '225', 'type': 'argument_list', 'children': ['226', '235']}; {'id': '226', 'type': 'call', 'children': ['227', '232']}, {'id': '227', 'type': 'attribute', 'children': ['228', '231']}; {'id': '228', 'type': 'attribute', 'children': ['229', '230']}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '232', 'type': 'argument_list', 'children': ['233', '234']}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'dirpath'}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'folder'}, {'id': '235', 'type': 'keyword_argument', 'children': ['236', '237']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'start'}, {'id': '237', 'type': 'identifier', 'children': [], 'value': 'indir'}; {'id': '238', 'type': 'expression_statement', 'children': ['239']}, {'id': '239', 'type': 'call', 'children': ['240', '243']}; {'id': '240', 'type': 'attribute', 'children': ['241', '242']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'create_dirs'}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '243', 'type': 'argument_list', 'children': ['244']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'dir_path'}, {'id': '245', 'type': 'if_statement', 'children': ['246', '248']}; {'id': '246', 'type': 'not_operator', 'children': ['247']}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'dry_run'}; {'id': '248', 'type': 'block', 'children': ['249', '283']}, {'id': '249', 'type': 'for_statement', 'children': ['250', '251', '252']}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'folder'}, {'id': '251', 'type': 'identifier', 'children': [], 'value': 'create_dirs'}; {'id': '252', 'type': 'block', 'children': ['253', '265']}, {'id': '253', 'type': 'expression_statement', 'children': ['254']}; {'id': '254', 'type': 'assignment', 'children': ['255', '256']}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'out_path'}; {'id': '256', 'type': 'call', 'children': ['257', '262']}, {'id': '257', 'type': 'attribute', 'children': ['258', '261']}; {'id': '258', 'type': 'attribute', 'children': ['259', '260']}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '262', 'type': 'argument_list', 'children': ['263', '264']}, {'id': '263', 'type': 'identifier', 'children': [], 'value': 'out_folder'}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'folder'}, {'id': '265', 'type': 'if_statement', 'children': ['266', '275']}; {'id': '266', 'type': 'not_operator', 'children': ['267']}, {'id': '267', 'type': 'call', 'children': ['268', '273']}; {'id': '268', 'type': 'attribute', 'children': ['269', '272']}, {'id': '269', 'type': 'attribute', 'children': ['270', '271']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '271', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '272', 'type': 'identifier', 'children': [], 'value': 'isdir'}, {'id': '273', 'type': 'argument_list', 'children': ['274']}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'out_path'}, {'id': '275', 'type': 'block', 'children': ['276']}; {'id': '276', 'type': 'expression_statement', 'children': ['277']}, {'id': '277', 'type': 'call', 'children': ['278', '281']}; {'id': '278', 'type': 'attribute', 'children': ['279', '280']}, {'id': '279', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '280', 'type': 'identifier', 'children': [], 'value': 'makedirs'}, {'id': '281', 'type': 'argument_list', 'children': ['282']}; {'id': '282', 'type': 'identifier', 'children': [], 'value': 'out_path'}, {'id': '283', 'type': 'for_statement', 'children': ['284', '289', '294']}; {'id': '284', 'type': 'pattern_list', 'children': ['285', '286']}, {'id': '285', 'type': 'identifier', 'children': [], 'value': 'out_rel'}; {'id': '286', 'type': 'tuple_pattern', 'children': ['287', '288']}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'in_path'}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'in_abspath'}, {'id': '289', 'type': 'call', 'children': ['290', '293']}; {'id': '290', 'type': 'attribute', 'children': ['291', '292']}, {'id': '291', 'type': 'identifier', 'children': [], 'value': 'file_map'}; {'id': '292', 'type': 'identifier', 'children': [], 'value': 'items'}, {'id': '293', 'type': 'argument_list', 'children': []}; {'id': '294', 'type': 'block', 'children': ['295', '307']}, {'id': '295', 'type': 'expression_statement', 'children': ['296']}; {'id': '296', 'type': 'assignment', 'children': ['297', '298']}, {'id': '297', 'type': 'identifier', 'children': [], 'value': 'out_path'}; {'id': '298', 'type': 'call', 'children': ['299', '304']}, {'id': '299', 'type': 'attribute', 'children': ['300', '303']}; {'id': '300', 'type': 'attribute', 'children': ['301', '302']}, {'id': '301', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '302', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '303', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '304', 'type': 'argument_list', 'children': ['305', '306']}, {'id': '305', 'type': 'identifier', 'children': [], 'value': 'out_folder'}; {'id': '306', 'type': 'identifier', 'children': [], 'value': 'out_rel'}, {'id': '307', 'type': 'if_statement', 'children': ['308', '319', '328']}; {'id': '308', 'type': 'boolean_operator', 'children': ['309', '312'], 'value': 'or'}, {'id': '309', 'type': 'comparison_operator', 'children': ['310', '311'], 'value': 'in'}; {'id': '310', 'type': 'identifier', 'children': [], 'value': 'in_path'}, {'id': '311', 'type': 'identifier', 'children': [], 'value': 'preserve'}; {'id': '312', 'type': 'not_operator', 'children': ['313']}, {'id': '313', 'type': 'call', 'children': ['314', '317']}; {'id': '314', 'type': 'attribute', 'children': ['315', '316']}, {'id': '315', 'type': 'identifier', 'children': [], 'value': 'in_path'}; {'id': '316', 'type': 'identifier', 'children': [], 'value': 'endswith'}, {'id': '317', 'type': 'argument_list', 'children': ['318']}; {'id': '318', 'type': 'string', 'children': [], 'value': '".tpl"'}, {'id': '319', 'type': 'block', 'children': ['320']}; {'id': '320', 'type': 'expression_statement', 'children': ['321']}, {'id': '321', 'type': 'call', 'children': ['322', '325']}; {'id': '322', 'type': 'attribute', 'children': ['323', '324']}, {'id': '323', 'type': 'identifier', 'children': [], 'value': 'shutil'}; {'id': '324', 'type': 'identifier', 'children': [], 'value': 'copyfile'}, {'id': '325', 'type': 'argument_list', 'children': ['326', '327']}; {'id': '326', 'type': 'identifier', 'children': [], 'value': 'in_abspath'}, {'id': '327', 'type': 'identifier', 'children': [], 'value': 'out_path'}; {'id': '328', 'type': 'else_clause', 'children': ['329']}, {'id': '329', 'type': 'block', 'children': ['330', '352']}; {'id': '330', 'type': 'expression_statement', 'children': ['331']}, {'id': '331', 'type': 'assignment', 'children': ['332', '333']}; {'id': '332', 'type': 'identifier', 'children': [], 'value': 'in_template_path'}, {'id': '333', 'type': 'call', 'children': ['334', '345']}; {'id': '334', 'type': 'attribute', 'children': ['335', '344']}, {'id': '335', 'type': 'call', 'children': ['336', '341']}; {'id': '336', 'type': 'attribute', 'children': ['337', '340']}, {'id': '337', 'type': 'attribute', 'children': ['338', '339']}; {'id': '338', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '339', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '340', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '341', 'type': 'argument_list', 'children': ['342', '343']}; {'id': '342', 'type': 'identifier', 'children': [], 'value': 'template_folder'}, {'id': '343', 'type': 'identifier', 'children': [], 'value': 'in_path'}; {'id': '344', 'type': 'identifier', 'children': [], 'value': 'replace'}, {'id': '345', 'type': 'argument_list', 'children': ['346', '351']}; {'id': '346', 'type': 'attribute', 'children': ['347', '350']}, {'id': '347', 'type': 'attribute', 'children': ['348', '349']}; {'id': '348', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '349', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '350', 'type': 'identifier', 'children': [], 'value': 'sep'}, {'id': '351', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '352', 'type': 'expression_statement', 'children': ['353']}, {'id': '353', 'type': 'call', 'children': ['354', '355']}; {'id': '354', 'type': 'identifier', 'children': [], 'value': 'render_template'}, {'id': '355', 'type': 'argument_list', 'children': ['356', '357', '358']}; {'id': '356', 'type': 'identifier', 'children': [], 'value': 'in_template_path'}, {'id': '357', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '358', 'type': 'keyword_argument', 'children': ['359', '360']}, {'id': '359', 'type': 'identifier', 'children': [], 'value': 'out_path'}; {'id': '360', 'type': 'identifier', 'children': [], 'value': 'out_path'}, {'id': '361', 'type': 'return_statement', 'children': ['362']}; {'id': '362', 'type': 'expression_list', 'children': ['363', '364']}, {'id': '363', 'type': 'identifier', 'children': [], 'value': 'file_map'}
def render_recursive_template(template_folder, info, out_folder, preserve=None, dry_run=False): if isinstance(preserve, str): raise ArgumentError("You must pass a list of strings to preserve, not a string", preserve=preserve) if preserve is None: preserve = [] preserve = set(preserve) template_dir = resource_path('templates', expect='folder') indir = os.path.join(template_dir, template_folder) if not os.path.exists(indir): raise ArgumentError("Input template folder for recursive template not found", template_folder=template_folder, absolute_path=indir) elif not os.path.isdir(indir): raise ArgumentError("Input template folder is not a directory", template_folder=template_folder, absolute_path=indir) create_dirs = [] file_map = {} for dirpath, dirs, files in os.walk(indir): for file in files: in_abspath = os.path.abspath(os.path.join(dirpath, file)) in_path = os.path.relpath(os.path.join(dirpath, file), start=indir) if file.endswith(".tpl") and not in_path in preserve: out_path = in_path[:-4] else: out_path = in_path file_map[out_path] = (in_path, in_abspath) for folder in dirs: dir_path = os.path.relpath(os.path.join(dirpath, folder), start=indir) create_dirs.append(dir_path) if not dry_run: for folder in create_dirs: out_path = os.path.join(out_folder, folder) if not os.path.isdir(out_path): os.makedirs(out_path) for out_rel, (in_path, in_abspath) in file_map.items(): out_path = os.path.join(out_folder, out_rel) if in_path in preserve or not in_path.endswith(".tpl"): shutil.copyfile(in_abspath, out_path) else: in_template_path = os.path.join(template_folder, in_path).replace(os.path.sep, '/') render_template(in_template_path, info, out_path=out_path) return file_map, create_dirs
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Update'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '8', 'type': 'None', 'children': []}, {'id': '9', 'type': 'block', 'children': ['10', '14', '38', '137', '148', '207', '231', '316']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}, {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'values'}, {'id': '13', 'type': 'dictionary', 'children': []}; {'id': '14', 'type': 'for_statement', 'children': ['15', '16', '19']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'options'}, {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'if_statement', 'children': ['21', '27']}, {'id': '21', 'type': 'not_operator', 'children': ['22']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '26'], 'value': 'is'}, {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '26', 'type': 'None', 'children': []}, {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}, {'id': '29', 'type': 'assignment', 'children': ['30', '35']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '38', 'type': 'for_statement', 'children': ['39', '40', '43']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'files'}, {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'if_statement', 'children': ['45', '53']}, {'id': '45', 'type': 'call', 'children': ['46', '51']}; {'id': '46', 'type': 'attribute', 'children': ['47', '50']}, {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'exists'}, {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'filename'}, {'id': '53', 'type': 'block', 'children': ['54', '74', '87']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}, {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'dir'}, {'id': '57', 'type': 'subscript', 'children': ['58', '73']}; {'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': 'os'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '64', 'type': 'argument_list', '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': 'abspath'}, {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'filename'}, {'id': '73', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '74', 'type': 'if_statement', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '76', 'type': 'block', 'children': ['77']}, {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '84']}, {'id': '79', 'type': 'attribute', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '86']}, {'id': '85', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'dir'}, {'id': '87', 'type': 'try_statement', 'children': ['88', '122']}; {'id': '88', 'type': 'block', 'children': ['89', '95', '115']}, {'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': 'values'}, {'id': '93', 'type': 'string', 'children': [], 'value': "'__name__'"}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'filename'}, {'id': '95', 'type': 'with_statement', 'children': ['96', '106']}; {'id': '96', 'type': 'with_clause', 'children': ['97']}, {'id': '97', 'type': 'with_item', 'children': ['98']}; {'id': '98', 'type': 'as_pattern', 'children': ['99', '104']}, {'id': '99', 'type': 'call', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'open'}, {'id': '101', 'type': 'argument_list', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'filename'}, {'id': '103', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '104', 'type': 'as_pattern_target', 'children': ['105']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '106', 'type': 'block', 'children': ['107']}, {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'contents'}; {'id': '110', 'type': 'call', 'children': ['111', '114']}, {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '114', 'type': 'argument_list', 'children': []}, {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '118']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'exec'}; {'id': '118', 'type': 'argument_list', 'children': ['119', '120', '121']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'contents'}; {'id': '120', 'type': 'dictionary', 'children': []}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '122', 'type': 'finally_clause', 'children': ['123']}, {'id': '123', 'type': 'block', 'children': ['124', '133']}; {'id': '124', 'type': 'if_statement', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '126', 'type': 'block', 'children': ['127']}, {'id': '127', 'type': 'delete_statement', 'children': ['128']}; {'id': '128', 'type': 'subscript', 'children': ['129', '132']}, {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'sys'}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '132', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '133', 'type': 'delete_statement', 'children': ['134']}; {'id': '134', 'type': 'subscript', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '136', 'type': 'string', 'children': [], 'value': "'__name__'"}, {'id': '137', 'type': 'if_statement', 'children': ['138', '141']}; {'id': '138', 'type': 'comparison_operator', 'children': ['139', '140'], 'value': 'is'}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '140', 'type': 'None', 'children': []}, {'id': '141', 'type': 'block', 'children': ['142']}; {'id': '142', 'type': 'expression_statement', 'children': ['143']}, {'id': '143', 'type': 'assignment', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '148', 'type': 'for_statement', 'children': ['149', '152', '157']}, {'id': '149', 'type': 'pattern_list', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'arg'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '152', 'type': 'call', 'children': ['153', '156']}, {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '156', 'type': 'argument_list', 'children': []}, {'id': '157', 'type': 'block', 'children': ['158', '162', '195']}; {'id': '158', 'type': 'expression_statement', 'children': ['159']}, {'id': '159', 'type': 'assignment', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'added'}, {'id': '161', 'type': 'False', 'children': []}; {'id': '162', 'type': 'for_statement', 'children': ['163', '164', '167']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '164', 'type': 'attribute', 'children': ['165', '166']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'options'}, {'id': '167', 'type': 'block', 'children': ['168']}; {'id': '168', 'type': 'if_statement', 'children': ['169', '182']}, {'id': '169', 'type': 'comparison_operator', 'children': ['170', '171'], 'value': 'in'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'arg'}, {'id': '171', 'type': 'binary_operator', 'children': ['172', '178'], 'value': '+'}; {'id': '172', 'type': 'call', 'children': ['173', '174']}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '174', 'type': 'argument_list', 'children': ['175']}, {'id': '175', 'type': 'attribute', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'aliases'}; {'id': '178', 'type': 'list', 'children': ['179'], 'value': '[ option.key ]'}, {'id': '179', 'type': 'attribute', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '182', 'type': 'block', 'children': ['183', '191']}, {'id': '183', 'type': 'expression_statement', 'children': ['184']}; {'id': '184', 'type': 'assignment', 'children': ['185', '190']}, {'id': '185', 'type': 'subscript', 'children': ['186', '187']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'values'}, {'id': '187', 'type': 'attribute', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '191', 'type': 'expression_statement', 'children': ['192']}; {'id': '192', 'type': 'assignment', 'children': ['193', '194']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'added'}; {'id': '194', 'type': 'True', 'children': []}, {'id': '195', 'type': 'if_statement', 'children': ['196', '198']}; {'id': '196', 'type': 'not_operator', 'children': ['197']}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'added'}; {'id': '198', 'type': 'block', 'children': ['199']}, {'id': '199', 'type': 'expression_statement', 'children': ['200']}; {'id': '200', 'type': 'assignment', 'children': ['201', '206']}, {'id': '201', 'type': 'subscript', 'children': ['202', '205']}; {'id': '202', 'type': 'attribute', 'children': ['203', '204']}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'unknown'}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '207', 'type': 'for_statement', 'children': ['208', '209', '212']}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '209', 'type': 'attribute', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '212', 'type': 'block', 'children': ['213']}, {'id': '213', 'type': 'try_statement', 'children': ['214', '227']}; {'id': '214', 'type': 'block', 'children': ['215']}, {'id': '215', 'type': 'expression_statement', 'children': ['216']}; {'id': '216', 'type': 'assignment', 'children': ['217', '222']}, {'id': '217', 'type': 'subscript', 'children': ['218', '219']}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '219', 'type': 'attribute', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '221', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '222', 'type': 'subscript', 'children': ['223', '224']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '224', 'type': 'attribute', 'children': ['225', '226']}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '227', 'type': 'except_clause', 'children': ['228', '229']}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'KeyError'}, {'id': '229', 'type': 'block', 'children': ['230']}; {'id': '230', 'type': 'pass_statement', 'children': []}, {'id': '231', 'type': 'for_statement', 'children': ['232', '233', '236']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '233', 'type': 'attribute', 'children': ['234', '235']}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '235', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '236', 'type': 'block', 'children': ['237']}, {'id': '237', 'type': 'if_statement', 'children': ['238', '247']}; {'id': '238', 'type': 'boolean_operator', 'children': ['239', '242'], 'value': 'and'}, {'id': '239', 'type': 'attribute', 'children': ['240', '241']}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'converter'}; {'id': '242', 'type': 'comparison_operator', 'children': ['243', '246'], 'value': 'in'}, {'id': '243', 'type': 'attribute', 'children': ['244', '245']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'values'}, {'id': '247', 'type': 'block', 'children': ['248', '261']}; {'id': '248', 'type': 'expression_statement', 'children': ['249']}, {'id': '249', 'type': 'assignment', 'children': ['250', '251']}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '251', 'type': 'call', 'children': ['252', '255']}; {'id': '252', 'type': 'attribute', 'children': ['253', '254']}, {'id': '253', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'subst'}, {'id': '255', 'type': 'argument_list', 'children': ['256']}; {'id': '256', 'type': 'binary_operator', 'children': ['257', '258'], 'value': '%'}, {'id': '257', 'type': 'string', 'children': [], 'value': "'${%s}'"}; {'id': '258', 'type': 'attribute', 'children': ['259', '260']}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '261', 'type': 'try_statement', 'children': ['262', '295']}; {'id': '262', 'type': 'block', 'children': ['263']}, {'id': '263', 'type': 'try_statement', 'children': ['264', '278']}; {'id': '264', 'type': 'block', 'children': ['265']}, {'id': '265', 'type': 'expression_statement', 'children': ['266']}; {'id': '266', 'type': 'assignment', 'children': ['267', '272']}, {'id': '267', 'type': 'subscript', 'children': ['268', '269']}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '269', 'type': 'attribute', 'children': ['270', '271']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '271', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '272', 'type': 'call', 'children': ['273', '276']}, {'id': '273', 'type': 'attribute', 'children': ['274', '275']}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 'converter'}; {'id': '276', 'type': 'argument_list', 'children': ['277']}, {'id': '277', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '278', 'type': 'except_clause', 'children': ['279', '280']}, {'id': '279', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '280', 'type': 'block', 'children': ['281']}, {'id': '281', 'type': 'expression_statement', 'children': ['282']}; {'id': '282', 'type': 'assignment', 'children': ['283', '288']}, {'id': '283', 'type': 'subscript', 'children': ['284', '285']}; {'id': '284', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '285', 'type': 'attribute', 'children': ['286', '287']}; {'id': '286', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '288', 'type': 'call', 'children': ['289', '292']}, {'id': '289', 'type': 'attribute', 'children': ['290', '291']}; {'id': '290', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '291', 'type': 'identifier', 'children': [], 'value': 'converter'}; {'id': '292', 'type': 'argument_list', 'children': ['293', '294']}, {'id': '293', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '295', 'type': 'except_clause', 'children': ['296', '300']}; {'id': '296', 'type': 'as_pattern', 'children': ['297', '298']}, {'id': '297', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '298', 'type': 'as_pattern_target', 'children': ['299']}, {'id': '299', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '300', 'type': 'block', 'children': ['301']}, {'id': '301', 'type': 'raise_statement', 'children': ['302']}; {'id': '302', 'type': 'call', 'children': ['303', '308']}, {'id': '303', 'type': 'attribute', 'children': ['304', '307']}; {'id': '304', 'type': 'attribute', 'children': ['305', '306']}, {'id': '305', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '306', 'type': 'identifier', 'children': [], 'value': 'Errors'}, {'id': '307', 'type': 'identifier', 'children': [], 'value': 'UserError'}; {'id': '308', 'type': 'argument_list', 'children': ['309']}, {'id': '309', 'type': 'binary_operator', 'children': ['310', '311'], 'value': '%'}; {'id': '310', 'type': 'string', 'children': [], 'value': "'Error converting option: %s\\n%s'"}, {'id': '311', 'type': 'tuple', 'children': ['312', '315']}; {'id': '312', 'type': 'attribute', 'children': ['313', '314']}, {'id': '313', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '314', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '315', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '316', 'type': 'for_statement', 'children': ['317', '318', '321']}, {'id': '317', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '318', 'type': 'attribute', 'children': ['319', '320']}, {'id': '319', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '320', 'type': 'identifier', 'children': [], 'value': 'options'}, {'id': '321', 'type': 'block', 'children': ['322']}; {'id': '322', 'type': 'if_statement', 'children': ['323', '332']}, {'id': '323', 'type': 'boolean_operator', 'children': ['324', '327'], 'value': 'and'}; {'id': '324', 'type': 'attribute', 'children': ['325', '326']}, {'id': '325', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '326', 'type': 'identifier', 'children': [], 'value': 'validator'}, {'id': '327', 'type': 'comparison_operator', 'children': ['328', '331'], 'value': 'in'}; {'id': '328', 'type': 'attribute', 'children': ['329', '330']}, {'id': '329', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '330', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '331', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '332', 'type': 'block', 'children': ['333']}, {'id': '333', 'type': 'expression_statement', 'children': ['334']}; {'id': '334', 'type': 'call', 'children': ['335', '338']}, {'id': '335', 'type': 'attribute', 'children': ['336', '337']}; {'id': '336', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '337', 'type': 'identifier', 'children': [], 'value': 'validator'}; {'id': '338', 'type': 'argument_list', 'children': ['339', '342', '352']}, {'id': '339', 'type': 'attribute', 'children': ['340', '341']}; {'id': '340', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '341', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '342', 'type': 'call', 'children': ['343', '346']}, {'id': '343', 'type': 'attribute', 'children': ['344', '345']}; {'id': '344', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '345', 'type': 'identifier', 'children': [], 'value': 'subst'}; {'id': '346', 'type': 'argument_list', 'children': ['347']}, {'id': '347', 'type': 'binary_operator', 'children': ['348', '349'], 'value': '%'}; {'id': '348', 'type': 'string', 'children': [], 'value': "'${%s}'"}, {'id': '349', 'type': 'attribute', 'children': ['350', '351']}; {'id': '350', 'type': 'identifier', 'children': [], 'value': 'option'}, {'id': '351', 'type': 'identifier', 'children': [], 'value': 'key'}
def Update(self, env, args=None): values = {} for option in self.options: if not option.default is None: values[option.key] = option.default for filename in self.files: if os.path.exists(filename): dir = os.path.split(os.path.abspath(filename))[0] if dir: sys.path.insert(0, dir) try: values['__name__'] = filename with open(filename, 'r') as f: contents = f.read() exec(contents, {}, values) finally: if dir: del sys.path[0] del values['__name__'] if args is None: args = self.args for arg, value in args.items(): added = False for option in self.options: if arg in list(option.aliases) + [ option.key ]: values[option.key] = value added = True if not added: self.unknown[arg] = value for option in self.options: try: env[option.key] = values[option.key] except KeyError: pass for option in self.options: if option.converter and option.key in values: value = env.subst('${%s}'%option.key) try: try: env[option.key] = option.converter(value) except TypeError: env[option.key] = option.converter(value, env) except ValueError as x: raise SCons.Errors.UserError('Error converting option: %s\n%s'%(option.key, x)) for option in self.options: if option.validator and option.key in values: option.validator(option.key, env.subst('${%s}'%option.key), env)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GenerateHelpText'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '8', 'type': 'None', 'children': []}, {'id': '9', 'type': 'block', 'children': ['10', '73', '130', '144']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '15', '43', '65']}, {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'callable'}, {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'sort'}, {'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': 'options'}, {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'sorted'}, {'id': '21', 'type': 'argument_list', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'options'}, {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cmp_to_key'}, {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'lambda', 'children': ['31', '34']}, {'id': '31', 'type': 'lambda_parameters', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '40']}, {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '43', 'type': 'elif_clause', 'children': ['44', '47']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '46'], 'value': 'is'}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '46', 'type': 'True', 'children': []}, {'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': 'options'}, {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'sorted'}, {'id': '53', 'type': 'argument_list', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'options'}, {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '59', 'type': 'lambda', 'children': ['60', '62']}; {'id': '60', 'type': 'lambda_parameters', 'children': ['61']}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '65', 'type': 'else_clause', 'children': ['66']}; {'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': 'options'}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'options'}, {'id': '73', 'type': 'function_definition', 'children': ['74', '75', '83']}; {'id': '74', 'type': 'function_name', 'children': [], 'value': 'format'}, {'id': '75', 'type': 'parameters', 'children': ['76', '77', '80']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'opt'}, {'id': '77', 'type': 'default_parameter', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'default_parameter', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '83', 'type': 'block', 'children': ['84', '110']}; {'id': '84', 'type': 'if_statement', 'children': ['85', '90', '104']}, {'id': '85', 'type': 'comparison_operator', 'children': ['86', '89'], 'value': 'in'}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '90', 'type': 'block', 'children': ['91']}, {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'actual'}; {'id': '94', 'type': 'call', 'children': ['95', '98']}, {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'subst'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}, {'id': '99', 'type': 'binary_operator', 'children': ['100', '101'], 'value': '%'}; {'id': '100', 'type': 'string', 'children': [], 'value': "'${%s}'"}, {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'opt'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '104', 'type': 'else_clause', 'children': ['105']}, {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}, {'id': '107', 'type': 'assignment', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'actual'}, {'id': '109', 'type': 'None', 'children': []}; {'id': '110', 'type': 'return_statement', 'children': ['111']}, {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'FormatVariableHelpText'}, {'id': '115', 'type': 'argument_list', 'children': ['116', '117', '120', '123', '126', '127']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'opt'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'help'}, {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'opt'}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'actual'}, {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'opt'}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'aliases'}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}, {'id': '131', 'type': 'assignment', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'lines'}, {'id': '133', 'type': 'list_comprehension', 'children': ['134', '135', '142']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': '_f'}, {'id': '135', 'type': 'for_in_clause', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': '_f'}, {'id': '137', 'type': 'call', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'map'}, {'id': '139', 'type': 'argument_list', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'format'}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '142', 'type': 'if_clause', 'children': ['143']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': '_f'}; {'id': '144', 'type': 'return_statement', 'children': ['145']}, {'id': '145', 'type': 'call', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}, {'id': '147', 'type': 'string', 'children': [], 'value': "''"}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '149', 'type': 'argument_list', 'children': ['150']}
def GenerateHelpText(self, env, sort=None): if callable(sort): options = sorted(self.options, key=cmp_to_key(lambda x,y: sort(x.key,y.key))) elif sort is True: options = sorted(self.options, key=lambda x: x.key) else: options = self.options def format(opt, self=self, env=env): if opt.key in env: actual = env.subst('${%s}' % opt.key) else: actual = None return self.FormatVariableHelpText(env, opt.key, opt.help, opt.default, actual, opt.aliases) lines = [_f for _f in map(format, options) if _f] return ''.join(lines)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_tree'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '13']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'child_func'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'prune'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'margin'}, {'id': '11', 'type': 'list', 'children': ['12'], 'value': '[0]'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'visited'}, {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17', '24', '33', '40', '44', '70', '83', '93', '106', '112', '157']}, {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'rname'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '28']}, {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': 'is'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'visited'}, {'id': '27', 'type': 'None', 'children': []}; {'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': 'visited'}; {'id': '32', 'type': 'dictionary', 'children': []}, {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'child_func'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}, {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'retval'}, {'id': '43', 'type': 'string', 'children': [], 'value': '""'}; {'id': '44', 'type': 'for_statement', 'children': ['45', '46', '52']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'pipe'}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'margin'}; {'id': '48', 'type': 'slice', 'children': ['49', '50']}, {'id': '49', 'type': 'colon', 'children': []}; {'id': '50', 'type': 'unary_operator', 'children': ['51'], 'value': '-'}, {'id': '51', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '52', 'type': 'block', 'children': ['53']}, {'id': '53', 'type': 'if_statement', 'children': ['54', '55', '62']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'pipe'}, {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}, {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'retval'}, {'id': '59', 'type': 'binary_operator', 'children': ['60', '61'], 'value': '+'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'retval'}, {'id': '61', 'type': 'string', 'children': [], 'value': '"| "'}; {'id': '62', 'type': 'else_clause', 'children': ['63']}, {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}, {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'retval'}, {'id': '67', 'type': 'binary_operator', 'children': ['68', '69'], 'value': '+'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'retval'}, {'id': '69', 'type': 'string', 'children': [], 'value': '" "'}; {'id': '70', 'type': 'if_statement', 'children': ['71', '74']}, {'id': '71', 'type': 'comparison_operator', 'children': ['72', '73'], 'value': 'in'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'rname'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '74', 'type': 'block', 'children': ['75']}, {'id': '75', 'type': 'return_statement', 'children': ['76']}; {'id': '76', 'type': 'binary_operator', 'children': ['77', '82'], 'value': '+'}, {'id': '77', 'type': 'binary_operator', 'children': ['78', '81'], 'value': '+'}; {'id': '78', 'type': 'binary_operator', 'children': ['79', '80'], 'value': '+'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'retval'}; {'id': '80', 'type': 'string', 'children': [], 'value': '"+-["'}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'rname'}; {'id': '82', 'type': 'string', 'children': [], 'value': '"]\\n"'}, {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'retval'}; {'id': '86', 'type': 'binary_operator', 'children': ['87', '92'], 'value': '+'}, {'id': '87', 'type': 'binary_operator', 'children': ['88', '91'], 'value': '+'}; {'id': '88', 'type': 'binary_operator', 'children': ['89', '90'], 'value': '+'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'retval'}; {'id': '90', 'type': 'string', 'children': [], 'value': '"+-"'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'rname'}; {'id': '92', 'type': 'string', 'children': [], 'value': '"\\n"'}, {'id': '93', 'type': 'if_statement', 'children': ['94', '96']}; {'id': '94', 'type': 'not_operator', 'children': ['95']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'prune'}; {'id': '96', 'type': 'block', 'children': ['97']}, {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '100', 'type': 'call', 'children': ['101', '104']}, {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'copy'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}, {'id': '107', 'type': 'assignment', 'children': ['108', '111']}; {'id': '108', 'type': 'subscript', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'rname'}, {'id': '111', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '112', 'type': 'for_statement', 'children': ['113', '114', '121']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '114', 'type': 'call', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}, {'id': '117', 'type': 'call', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'children'}, {'id': '121', 'type': 'block', 'children': ['122', '136', '151']}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}, {'id': '123', 'type': 'call', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'margin'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'comparison_operator', 'children': ['129', '130'], 'value': '<'}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '130', 'type': 'binary_operator', 'children': ['131', '135'], 'value': '-'}, {'id': '131', 'type': 'call', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '133', 'type': 'argument_list', 'children': ['134']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'children'}, {'id': '135', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}, {'id': '137', 'type': 'assignment', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'retval'}, {'id': '139', 'type': 'binary_operator', 'children': ['140', '141'], 'value': '+'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'retval'}, {'id': '141', 'type': 'call', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'render_tree'}, {'id': '143', 'type': 'argument_list', 'children': ['144', '147', '148', '149', '150']}; {'id': '144', 'type': 'subscript', 'children': ['145', '146']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'child_func'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'prune'}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'margin'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'visited'}, {'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': 'margin'}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '156', 'type': 'argument_list', 'children': []}, {'id': '157', 'type': 'return_statement', 'children': ['158']}
def render_tree(root, child_func, prune=0, margin=[0], visited=None): rname = str(root) if visited is None: visited = {} children = child_func(root) retval = "" for pipe in margin[:-1]: if pipe: retval = retval + "| " else: retval = retval + " " if rname in visited: return retval + "+-[" + rname + "]\n" retval = retval + "+-" + rname + "\n" if not prune: visited = copy.copy(visited) visited[rname] = 1 for i in range(len(children)): margin.append(i < len(children)-1) retval = retval + render_tree(children[i], child_func, prune, margin, visited) margin.pop() return retval
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_tree'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '16']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'child_func'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'prune'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'showtags'}, {'id': '11', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'margin'}; {'id': '14', 'type': 'list', 'children': ['15'], 'value': '[0]'}, {'id': '15', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '16', 'type': 'default_parameter', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '18', 'type': 'None', 'children': []}, {'id': '19', 'type': 'block', 'children': ['20', '27', '36', '254', '265', '281', '288', '321', '343', '349']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}, {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'rname'}, {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '27', 'type': 'if_statement', 'children': ['28', '31']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '30'], 'value': 'is'}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '30', 'type': 'None', 'children': []}, {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}, {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'visited'}, {'id': '35', 'type': 'dictionary', 'children': []}; {'id': '36', 'type': 'if_statement', 'children': ['37', '38', '248']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'showtags'}; {'id': '38', 'type': 'block', 'children': ['39', '78', '83', '99', '122', '155', '169', '183', '197', '213', '227', '241']}, {'id': '39', 'type': 'if_statement', 'children': ['40', '43']}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '42'], 'value': '=='}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'showtags'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '43', 'type': 'block', 'children': ['44', '69']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}, {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'legend'}, {'id': '47', 'type': 'parenthesized_expression', 'children': ['48']}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '68'], 'value': '+'}, {'id': '49', 'type': 'binary_operator', 'children': ['50', '67'], 'value': '+'}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '66'], 'value': '+'}, {'id': '51', 'type': 'binary_operator', 'children': ['52', '65'], 'value': '+'}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '64'], 'value': '+'}, {'id': '53', 'type': 'binary_operator', 'children': ['54', '63'], 'value': '+'}; {'id': '54', 'type': 'binary_operator', 'children': ['55', '62'], 'value': '+'}, {'id': '55', 'type': 'binary_operator', 'children': ['56', '61'], 'value': '+'}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '60'], 'value': '+'}, {'id': '57', 'type': 'binary_operator', 'children': ['58', '59'], 'value': '+'}; {'id': '58', 'type': 'string', 'children': [], 'value': "' E = exists\\n'"}, {'id': '59', 'type': 'string', 'children': [], 'value': "' R = exists in repository only\\n'"}; {'id': '60', 'type': 'string', 'children': [], 'value': "' b = implicit builder\\n'"}, {'id': '61', 'type': 'string', 'children': [], 'value': "' B = explicit builder\\n'"}; {'id': '62', 'type': 'string', 'children': [], 'value': "' S = side effect\\n'"}, {'id': '63', 'type': 'string', 'children': [], 'value': "' P = precious\\n'"}; {'id': '64', 'type': 'string', 'children': [], 'value': "' A = always build\\n'"}, {'id': '65', 'type': 'string', 'children': [], 'value': "' C = current\\n'"}; {'id': '66', 'type': 'string', 'children': [], 'value': "' N = no clean\\n'"}, {'id': '67', 'type': 'string', 'children': [], 'value': "' H = no cache\\n'"}; {'id': '68', 'type': 'string', 'children': [], 'value': "'\\n'"}, {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '76']}, {'id': '71', 'type': 'attribute', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'stdout'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'legend'}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}, {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'tags'}, {'id': '81', 'type': 'list', 'children': ['82'], 'value': "['[']"}; {'id': '82', 'type': 'string', 'children': [], 'value': "'['"}, {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '88']}, {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'tags'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}, {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'string', 'children': [], 'value': "' E'"}, {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'IDX'}, {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '98']}, {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '98', 'type': 'argument_list', 'children': []}, {'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': 'tags'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}, {'id': '105', 'type': 'subscript', 'children': ['106', '107']}; {'id': '106', 'type': 'string', 'children': [], 'value': "' R'"}, {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'IDX'}, {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'boolean_operator', 'children': ['111', '116'], 'value': 'and'}, {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'rexists'}, {'id': '115', 'type': 'argument_list', 'children': []}; {'id': '116', 'type': 'not_operator', 'children': ['117']}, {'id': '117', 'type': 'call', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'exists'}, {'id': '121', 'type': 'argument_list', 'children': []}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}, {'id': '123', 'type': 'call', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'tags'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'subscript', 'children': ['129', '130']}, {'id': '129', 'type': 'string', 'children': [], 'value': "' BbB'"}; {'id': '130', 'type': 'binary_operator', 'children': ['131', '143'], 'value': '+'}, {'id': '131', 'type': 'subscript', 'children': ['132', '135']}; {'id': '132', 'type': 'list', 'children': ['133', '134'], 'value': '[0,1]'}, {'id': '133', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '134', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '135', 'type': 'call', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'IDX'}, {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '142']}, {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'has_explicit_builder'}; {'id': '142', 'type': 'argument_list', 'children': []}, {'id': '143', 'type': 'subscript', 'children': ['144', '147']}; {'id': '144', 'type': 'list', 'children': ['145', '146'], 'value': '[0,2]'}, {'id': '145', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '146', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '147', 'type': 'call', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'IDX'}, {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'call', 'children': ['151', '154']}, {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'has_builder'}; {'id': '154', 'type': 'argument_list', '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': 'tags'}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '160', 'type': 'argument_list', 'children': ['161']}, {'id': '161', 'type': 'subscript', 'children': ['162', '163']}; {'id': '162', 'type': 'string', 'children': [], 'value': "' S'"}, {'id': '163', 'type': 'call', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'IDX'}, {'id': '165', 'type': 'argument_list', 'children': ['166']}; {'id': '166', 'type': 'attribute', 'children': ['167', '168']}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'side_effect'}, {'id': '169', 'type': 'expression_statement', 'children': ['170']}; {'id': '170', 'type': 'call', 'children': ['171', '174']}, {'id': '171', 'type': 'attribute', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'tags'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '174', 'type': 'argument_list', 'children': ['175']}, {'id': '175', 'type': 'subscript', 'children': ['176', '177']}; {'id': '176', 'type': 'string', 'children': [], 'value': "' P'"}, {'id': '177', 'type': 'call', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'IDX'}, {'id': '179', 'type': 'argument_list', 'children': ['180']}; {'id': '180', 'type': 'attribute', 'children': ['181', '182']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'precious'}, {'id': '183', 'type': 'expression_statement', 'children': ['184']}; {'id': '184', 'type': 'call', 'children': ['185', '188']}, {'id': '185', 'type': 'attribute', 'children': ['186', '187']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'tags'}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '188', 'type': 'argument_list', 'children': ['189']}, {'id': '189', 'type': 'subscript', 'children': ['190', '191']}; {'id': '190', 'type': 'string', 'children': [], 'value': "' A'"}, {'id': '191', 'type': 'call', 'children': ['192', '193']}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'IDX'}, {'id': '193', 'type': 'argument_list', 'children': ['194']}; {'id': '194', 'type': 'attribute', 'children': ['195', '196']}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'always_build'}, {'id': '197', 'type': 'expression_statement', 'children': ['198']}; {'id': '198', 'type': 'call', 'children': ['199', '202']}, {'id': '199', 'type': 'attribute', 'children': ['200', '201']}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'tags'}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '202', 'type': 'argument_list', 'children': ['203']}, {'id': '203', 'type': 'subscript', 'children': ['204', '205']}; {'id': '204', 'type': 'string', 'children': [], 'value': "' C'"}, {'id': '205', 'type': 'call', 'children': ['206', '207']}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'IDX'}, {'id': '207', 'type': 'argument_list', 'children': ['208']}; {'id': '208', 'type': 'call', 'children': ['209', '212']}, {'id': '209', 'type': 'attribute', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'is_up_to_date'}; {'id': '212', 'type': 'argument_list', 'children': []}, {'id': '213', 'type': 'expression_statement', 'children': ['214']}; {'id': '214', 'type': 'call', 'children': ['215', '218']}, {'id': '215', 'type': 'attribute', 'children': ['216', '217']}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'tags'}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '218', 'type': 'argument_list', 'children': ['219']}, {'id': '219', 'type': 'subscript', 'children': ['220', '221']}; {'id': '220', 'type': 'string', 'children': [], 'value': "' N'"}, {'id': '221', 'type': 'call', 'children': ['222', '223']}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'IDX'}, {'id': '223', 'type': 'argument_list', 'children': ['224']}; {'id': '224', 'type': 'attribute', 'children': ['225', '226']}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'noclean'}, {'id': '227', 'type': 'expression_statement', 'children': ['228']}; {'id': '228', 'type': 'call', 'children': ['229', '232']}, {'id': '229', 'type': 'attribute', 'children': ['230', '231']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'tags'}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '232', 'type': 'argument_list', 'children': ['233']}, {'id': '233', 'type': 'subscript', 'children': ['234', '235']}; {'id': '234', 'type': 'string', 'children': [], 'value': "' H'"}, {'id': '235', 'type': 'call', 'children': ['236', '237']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'IDX'}, {'id': '237', 'type': 'argument_list', 'children': ['238']}; {'id': '238', 'type': 'attribute', 'children': ['239', '240']}, {'id': '239', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'nocache'}, {'id': '241', 'type': 'expression_statement', 'children': ['242']}; {'id': '242', 'type': 'call', 'children': ['243', '246']}, {'id': '243', 'type': 'attribute', 'children': ['244', '245']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'tags'}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '246', 'type': 'argument_list', 'children': ['247']}, {'id': '247', 'type': 'string', 'children': [], 'value': "']'"}; {'id': '248', 'type': 'else_clause', 'children': ['249']}, {'id': '249', 'type': 'block', 'children': ['250']}; {'id': '250', 'type': 'expression_statement', 'children': ['251']}, {'id': '251', 'type': 'assignment', 'children': ['252', '253']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'tags'}, {'id': '253', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '254', 'type': 'function_definition', 'children': ['255', '256', '258']}, {'id': '255', 'type': 'function_name', 'children': [], 'value': 'MMM'}; {'id': '256', 'type': 'parameters', 'children': ['257']}, {'id': '257', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '258', 'type': 'block', 'children': ['259']}, {'id': '259', 'type': 'return_statement', 'children': ['260']}; {'id': '260', 'type': 'subscript', 'children': ['261', '264']}, {'id': '261', 'type': 'list', 'children': ['262', '263'], 'value': '[" ","| "]'}; {'id': '262', 'type': 'string', 'children': [], 'value': '" "'}, {'id': '263', 'type': 'string', 'children': [], 'value': '"| "'}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '265', 'type': 'expression_statement', 'children': ['266']}; {'id': '266', 'type': 'assignment', 'children': ['267', '268']}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'margins'}; {'id': '268', 'type': 'call', 'children': ['269', '270']}, {'id': '269', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '270', 'type': 'argument_list', 'children': ['271']}, {'id': '271', 'type': 'call', 'children': ['272', '273']}; {'id': '272', 'type': 'identifier', 'children': [], 'value': 'map'}, {'id': '273', 'type': 'argument_list', 'children': ['274', '275']}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'MMM'}, {'id': '275', 'type': 'subscript', 'children': ['276', '277']}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'margin'}, {'id': '277', 'type': 'slice', 'children': ['278', '279']}; {'id': '278', 'type': 'colon', 'children': []}, {'id': '279', 'type': 'unary_operator', 'children': ['280'], 'value': '-'}; {'id': '280', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '281', 'type': 'expression_statement', 'children': ['282']}; {'id': '282', 'type': 'assignment', 'children': ['283', '284']}, {'id': '283', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '284', 'type': 'call', 'children': ['285', '286']}, {'id': '285', 'type': 'identifier', 'children': [], 'value': 'child_func'}; {'id': '286', 'type': 'argument_list', 'children': ['287']}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '288', 'type': 'if_statement', 'children': ['289', '296']}, {'id': '289', 'type': 'boolean_operator', 'children': ['290', '295'], 'value': 'and'}; {'id': '290', 'type': 'boolean_operator', 'children': ['291', '292'], 'value': 'and'}, {'id': '291', 'type': 'identifier', 'children': [], 'value': 'prune'}; {'id': '292', 'type': 'comparison_operator', 'children': ['293', '294'], 'value': 'in'}, {'id': '293', 'type': 'identifier', 'children': [], 'value': 'rname'}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'visited'}, {'id': '295', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '296', 'type': 'block', 'children': ['297', '320']}, {'id': '297', 'type': 'expression_statement', 'children': ['298']}; {'id': '298', 'type': 'call', 'children': ['299', '304']}, {'id': '299', 'type': 'attribute', 'children': ['300', '303']}; {'id': '300', 'type': 'attribute', 'children': ['301', '302']}, {'id': '301', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '302', 'type': 'identifier', 'children': [], 'value': 'stdout'}, {'id': '303', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '304', 'type': 'argument_list', 'children': ['305']}, {'id': '305', 'type': 'binary_operator', 'children': ['306', '319'], 'value': '+'}; {'id': '306', 'type': 'call', 'children': ['307', '310']}, {'id': '307', 'type': 'attribute', 'children': ['308', '309']}; {'id': '308', 'type': 'string', 'children': [], 'value': "''"}, {'id': '309', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '310', 'type': 'argument_list', 'children': ['311']}, {'id': '311', 'type': 'binary_operator', 'children': ['312', '315'], 'value': '+'}; {'id': '312', 'type': 'binary_operator', 'children': ['313', '314'], 'value': '+'}, {'id': '313', 'type': 'identifier', 'children': [], 'value': 'tags'}; {'id': '314', 'type': 'identifier', 'children': [], 'value': 'margins'}, {'id': '315', 'type': 'list', 'children': ['316', '317', '318'], 'value': "['+-[', rname, ']']"}; {'id': '316', 'type': 'string', 'children': [], 'value': "'+-['"}, {'id': '317', 'type': 'identifier', 'children': [], 'value': 'rname'}; {'id': '318', 'type': 'string', 'children': [], 'value': "']'"}, {'id': '319', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '320', 'type': 'return_statement', 'children': []}, {'id': '321', 'type': 'expression_statement', 'children': ['322']}; {'id': '322', 'type': 'call', 'children': ['323', '328']}, {'id': '323', 'type': 'attribute', 'children': ['324', '327']}; {'id': '324', 'type': 'attribute', 'children': ['325', '326']}, {'id': '325', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '326', 'type': 'identifier', 'children': [], 'value': 'stdout'}, {'id': '327', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '328', 'type': 'argument_list', 'children': ['329']}, {'id': '329', 'type': 'binary_operator', 'children': ['330', '342'], 'value': '+'}; {'id': '330', 'type': 'call', 'children': ['331', '334']}, {'id': '331', 'type': 'attribute', 'children': ['332', '333']}; {'id': '332', 'type': 'string', 'children': [], 'value': "''"}, {'id': '333', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '334', 'type': 'argument_list', 'children': ['335']}, {'id': '335', 'type': 'binary_operator', 'children': ['336', '339'], 'value': '+'}; {'id': '336', 'type': 'binary_operator', 'children': ['337', '338'], 'value': '+'}, {'id': '337', 'type': 'identifier', 'children': [], 'value': 'tags'}; {'id': '338', 'type': 'identifier', 'children': [], 'value': 'margins'}, {'id': '339', 'type': 'list', 'children': ['340', '341'], 'value': "['+-', rname]"}; {'id': '340', 'type': 'string', 'children': [], 'value': "'+-'"}, {'id': '341', 'type': 'identifier', 'children': [], 'value': 'rname'}; {'id': '342', 'type': 'string', 'children': [], 'value': "'\\n'"}, {'id': '343', 'type': 'expression_statement', 'children': ['344']}; {'id': '344', 'type': 'assignment', 'children': ['345', '348']}, {'id': '345', 'type': 'subscript', 'children': ['346', '347']}; {'id': '346', 'type': 'identifier', 'children': [], 'value': 'visited'}, {'id': '347', 'type': 'identifier', 'children': [], 'value': 'rname'}; {'id': '348', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '349', 'type': 'if_statement', 'children': ['350', '351']}; {'id': '350', 'type': 'identifier', 'children': [], 'value': 'children'}, {'id': '351', 'type': 'block', 'children': ['352', '359', '366', '385', '392', '405']}; {'id': '352', 'type': 'expression_statement', 'children': ['353']}, {'id': '353', 'type': 'call', 'children': ['354', '357']}; {'id': '354', 'type': 'attribute', 'children': ['355', '356']}, {'id': '355', 'type': 'identifier', 'children': [], 'value': 'margin'}; {'id': '356', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '357', 'type': 'argument_list', 'children': ['358']}; {'id': '358', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '359', 'type': 'expression_statement', 'children': ['360']}; {'id': '360', 'type': 'assignment', 'children': ['361', '362']}, {'id': '361', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '362', 'type': 'call', 'children': ['363', '364']}, {'id': '363', 'type': 'identifier', 'children': [], 'value': 'IDX'}; {'id': '364', 'type': 'argument_list', 'children': ['365']}, {'id': '365', 'type': 'identifier', 'children': [], 'value': 'showtags'}; {'id': '366', 'type': 'for_statement', 'children': ['367', '368', '374']}, {'id': '367', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '368', 'type': 'subscript', 'children': ['369', '370']}, {'id': '369', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '370', 'type': 'slice', 'children': ['371', '372']}, {'id': '371', 'type': 'colon', 'children': []}; {'id': '372', 'type': 'unary_operator', 'children': ['373'], 'value': '-'}, {'id': '373', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '374', 'type': 'block', 'children': ['375']}, {'id': '375', 'type': 'expression_statement', 'children': ['376']}; {'id': '376', 'type': 'call', 'children': ['377', '378']}, {'id': '377', 'type': 'identifier', 'children': [], 'value': 'print_tree'}; {'id': '378', 'type': 'argument_list', 'children': ['379', '380', '381', '382', '383', '384']}, {'id': '379', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '380', 'type': 'identifier', 'children': [], 'value': 'child_func'}, {'id': '381', 'type': 'identifier', 'children': [], 'value': 'prune'}; {'id': '382', 'type': 'identifier', 'children': [], 'value': 'idx'}, {'id': '383', 'type': 'identifier', 'children': [], 'value': 'margin'}; {'id': '384', 'type': 'identifier', 'children': [], 'value': 'visited'}, {'id': '385', 'type': 'expression_statement', 'children': ['386']}; {'id': '386', 'type': 'assignment', 'children': ['387', '391']}, {'id': '387', 'type': 'subscript', 'children': ['388', '389']}; {'id': '388', 'type': 'identifier', 'children': [], 'value': 'margin'}, {'id': '389', 'type': 'unary_operator', 'children': ['390'], 'value': '-'}; {'id': '390', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '391', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '392', 'type': 'expression_statement', 'children': ['393']}, {'id': '393', 'type': 'call', 'children': ['394', '395']}; {'id': '394', 'type': 'identifier', 'children': [], 'value': 'print_tree'}, {'id': '395', 'type': 'argument_list', 'children': ['396', '400', '401', '402', '403', '404']}; {'id': '396', 'type': 'subscript', 'children': ['397', '398']}, {'id': '397', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '398', 'type': 'unary_operator', 'children': ['399'], 'value': '-'}, {'id': '399', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '400', 'type': 'identifier', 'children': [], 'value': 'child_func'}, {'id': '401', 'type': 'identifier', 'children': [], 'value': 'prune'}; {'id': '402', 'type': 'identifier', 'children': [], 'value': 'idx'}, {'id': '403', 'type': 'identifier', 'children': [], 'value': 'margin'}; {'id': '404', 'type': 'identifier', 'children': [], 'value': 'visited'}, {'id': '405', 'type': 'expression_statement', 'children': ['406']}; {'id': '406', 'type': 'call', 'children': ['407', '410']}, {'id': '407', 'type': 'attribute', 'children': ['408', '409']}; {'id': '408', 'type': 'identifier', 'children': [], 'value': 'margin'}, {'id': '409', 'type': 'identifier', 'children': [], 'value': 'pop'}
def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): rname = str(root) if visited is None: visited = {} if showtags: if showtags == 2: legend = (' E = exists\n' + ' R = exists in repository only\n' + ' b = implicit builder\n' + ' B = explicit builder\n' + ' S = side effect\n' + ' P = precious\n' + ' A = always build\n' + ' C = current\n' + ' N = no clean\n' + ' H = no cache\n' + '\n') sys.stdout.write(legend) tags = ['['] tags.append(' E'[IDX(root.exists())]) tags.append(' R'[IDX(root.rexists() and not root.exists())]) tags.append(' BbB'[[0,1][IDX(root.has_explicit_builder())] + [0,2][IDX(root.has_builder())]]) tags.append(' S'[IDX(root.side_effect)]) tags.append(' P'[IDX(root.precious)]) tags.append(' A'[IDX(root.always_build)]) tags.append(' C'[IDX(root.is_up_to_date())]) tags.append(' N'[IDX(root.noclean)]) tags.append(' H'[IDX(root.nocache)]) tags.append(']') else: tags = [] def MMM(m): return [" ","| "][m] margins = list(map(MMM, margin[:-1])) children = child_func(root) if prune and rname in visited and children: sys.stdout.write(''.join(tags + margins + ['+-[', rname, ']']) + '\n') return sys.stdout.write(''.join(tags + margins + ['+-', rname]) + '\n') visited[rname] = 1 if children: margin.append(1) idx = IDX(showtags) for C in children[:-1]: print_tree(C, child_func, prune, idx, margin, visited) margin[-1] = 0 print_tree(children[-1], child_func, prune, idx, margin, visited) margin.pop()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unique'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '5', 'type': 'block', 'children': ['6', '13', '20', '24', '51', '53', '124', '126', '130', '146']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}, {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'n'}, {'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': 's'}, {'id': '13', 'type': 'if_statement', 'children': ['14', '17']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '16'], 'value': '=='}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'return_statement', 'children': ['19']}, {'id': '19', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}, {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'u'}, {'id': '23', 'type': 'dictionary', 'children': []}; {'id': '24', 'type': 'try_statement', 'children': ['25', '36', '40']}, {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'for_statement', 'children': ['27', '28', '29']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}, {'id': '31', 'type': 'assignment', 'children': ['32', '35']}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'u'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '35', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '36', 'type': 'except_clause', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '38', 'type': 'block', 'children': ['39']}, {'id': '39', 'type': 'pass_statement', 'children': []}; {'id': '40', 'type': 'else_clause', 'children': ['41']}, {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'return_statement', 'children': ['43']}, {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'list'}, {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}, {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'u'}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '50', 'type': 'argument_list', 'children': []}, {'id': '51', 'type': 'delete_statement', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'u'}, {'id': '53', 'type': 'try_statement', 'children': ['54', '62', '66']}; {'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': 't'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '62', 'type': 'except_clause', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '64', 'type': 'block', 'children': ['65']}, {'id': '65', 'type': 'pass_statement', 'children': []}; {'id': '66', 'type': 'else_clause', 'children': ['67']}, {'id': '67', 'type': 'block', 'children': ['68', '72', '78', '84', '118']}; {'id': '68', 'type': 'assert_statement', 'children': ['69']}, {'id': '69', 'type': 'comparison_operator', 'children': ['70', '71'], 'value': '>'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '71', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}, {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'last'}, {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '77', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}, {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'lasti'}, {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '83', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '84', 'type': 'while_statement', 'children': ['85', '88']}, {'id': '85', 'type': 'comparison_operator', 'children': ['86', '87'], 'value': '<'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '88', 'type': 'block', 'children': ['89', '112']}, {'id': '89', 'type': 'if_statement', 'children': ['90', '95']}; {'id': '90', 'type': 'comparison_operator', 'children': ['91', '94'], 'value': '!='}, {'id': '91', 'type': 'subscript', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'last'}, {'id': '95', 'type': 'block', 'children': ['96', '106']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}, {'id': '97', 'type': 'assignment', 'children': ['98', '101']}; {'id': '98', 'type': 'subscript', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'lasti'}, {'id': '101', 'type': 'assignment', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'last'}, {'id': '103', 'type': 'subscript', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}, {'id': '107', 'type': 'assignment', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'lasti'}, {'id': '109', 'type': 'binary_operator', 'children': ['110', '111'], 'value': '+'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'lasti'}, {'id': '111', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}, {'id': '113', 'type': 'assignment', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '115', 'type': 'binary_operator', 'children': ['116', '117'], 'value': '+'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '117', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '118', 'type': 'return_statement', 'children': ['119']}, {'id': '119', 'type': 'subscript', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '121', 'type': 'slice', 'children': ['122', '123']}; {'id': '122', 'type': 'colon', 'children': []}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'lasti'}; {'id': '124', 'type': 'delete_statement', 'children': ['125']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}, {'id': '127', 'type': 'assignment', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'u'}, {'id': '129', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '130', 'type': 'for_statement', 'children': ['131', '132', '133']}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '133', 'type': 'block', 'children': ['134']}; {'id': '134', 'type': 'if_statement', 'children': ['135', '138']}, {'id': '135', 'type': 'comparison_operator', 'children': ['136', '137'], 'value': 'not'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'u'}; {'id': '138', 'type': 'block', 'children': ['139']}, {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'call', 'children': ['141', '144']}, {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'u'}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '146', 'type': 'return_statement', 'children': ['147']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'u'}
def unique(s): n = len(s) if n == 0: return [] u = {} try: for x in s: u[x] = 1 except TypeError: pass else: return list(u.keys()) del u try: t = sorted(s) except TypeError: pass else: assert n > 0 last = t[0] lasti = i = 1 while i < n: if t[i] != last: t[lasti] = last = t[i] lasti = lasti + 1 i = i + 1 return t[:lasti] del t u = [] for x in s: if x not in u: u.append(x) return u
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setup_client'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'client_id'}, {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'user_data'}; {'id': '10', 'type': 'None', 'children': []}, {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'scan'}, {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'broadcast'}; {'id': '16', 'type': 'False', 'children': []}, {'id': '17', 'type': 'block', 'children': ['18', '34', '51', '75', '88', '107', '116']}; {'id': '18', 'type': 'if_statement', 'children': ['19', '22']}, {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': 'is'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'client_id'}, {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23']}, {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}, {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'uuid'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'uuid4'}, {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'if_statement', 'children': ['35', '40']}, {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'in'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'client_id'}, {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '39', 'type': 'identifier', 'children': [], 'value': '_clients'}; {'id': '40', 'type': 'block', 'children': ['41']}, {'id': '41', 'type': 'raise_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}, {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}, {'id': '47', 'type': 'string', 'children': [], 'value': '"Duplicate client_id: {}"'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'format'}, {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'client_id'}, {'id': '51', 'type': 'function_definition', 'children': ['52', '53', '58']}; {'id': '52', 'type': 'function_name', 'children': [], 'value': '_client_callback'}, {'id': '53', 'type': 'parameters', 'children': ['54', '55', '56', '57']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'conn_string'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'event_name'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '58', 'type': 'block', 'children': ['59', '66']}, {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'event_tuple'}; {'id': '62', 'type': 'tuple', 'children': ['63', '64', '65']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'conn_string'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'event_name'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}, {'id': '67', 'type': 'await', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '72']}, {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': '_forward_client_event'}; {'id': '72', 'type': 'argument_list', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'event_tuple'}, {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'client_monitor'}; {'id': '78', 'type': 'call', 'children': ['79', '84']}, {'id': '79', 'type': 'attribute', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'adapter'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'register_monitor'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '86', '87']}, {'id': '85', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '86', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': '_client_callback'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}, {'id': '89', 'type': 'assignment', 'children': ['90', '95']}; {'id': '90', 'type': 'subscript', 'children': ['91', '94']}, {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '93', 'type': 'identifier', 'children': [], 'value': '_clients'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'client_id'}, {'id': '95', 'type': 'call', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'dict'}, {'id': '97', 'type': 'argument_list', 'children': ['98', '101', '104']}; {'id': '98', 'type': 'keyword_argument', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'user_data'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'user_data'}, {'id': '101', 'type': 'keyword_argument', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'connections'}, {'id': '103', 'type': 'dictionary', 'children': []}; {'id': '104', 'type': 'keyword_argument', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'monitor'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'client_monitor'}, {'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': 'self'}, {'id': '111', 'type': 'identifier', 'children': [], 'value': '_adjust_global_events'}; {'id': '112', 'type': 'argument_list', 'children': ['113', '114', '115']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'scan'}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'broadcast'}; {'id': '116', 'type': 'return_statement', 'children': ['117']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'client_id'}
def setup_client(self, client_id=None, user_data=None, scan=True, broadcast=False): if client_id is None: client_id = str(uuid.uuid4()) if client_id in self._clients: raise ArgumentError("Duplicate client_id: {}".format(client_id)) async def _client_callback(conn_string, _, event_name, event): event_tuple = (conn_string, event_name, event) await self._forward_client_event(client_id, event_tuple) client_monitor = self.adapter.register_monitor([], [], _client_callback) self._clients[client_id] = dict(user_data=user_data, connections={}, monitor=client_monitor) self._adjust_global_events(client_id, scan, broadcast) return client_id
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_conn_string'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'conn_string'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '47', '61', '74', '83', '241']}, {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'disconnection_required'}; {'id': '10', 'type': 'False', 'children': []}, {'id': '11', 'type': 'if_statement', 'children': ['12', '19']}; {'id': '12', 'type': 'boolean_operator', 'children': ['13', '16'], 'value': 'or'}, {'id': '13', 'type': 'comparison_operator', 'children': ['14', '15'], 'value': 'is'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'conn_string'}, {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': 'not'}, {'id': '17', 'type': 'string', 'children': [], 'value': "'device'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'conn_string'}, {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'if_statement', 'children': ['21', '34']}, {'id': '21', 'type': 'boolean_operator', 'children': ['22', '27'], 'value': 'and'}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '26'], 'value': 'is'}, {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': '_default_device_info'}; {'id': '26', 'type': 'None', 'children': []}, {'id': '27', 'type': 'comparison_operator', 'children': ['28', '31'], 'value': '!='}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_device_info'}, {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': '_default_device_info'}; {'id': '34', 'type': 'block', 'children': ['35', '39']}, {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'disconnection_required'}; {'id': '38', 'type': 'True', 'children': []}, {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '44']}, {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '43', 'type': 'identifier', 'children': [], 'value': '_device_info'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_default_device_info'}, {'id': '47', 'type': 'if_statement', 'children': ['48', '58']}; {'id': '48', 'type': 'boolean_operator', 'children': ['49', '52'], 'value': 'or'}, {'id': '49', 'type': 'comparison_operator', 'children': ['50', '51'], 'value': 'is'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'conn_string'}, {'id': '51', 'type': 'None', 'children': []}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '57'], 'value': '=='}, {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'conn_string'}, {'id': '57', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '58', 'type': 'block', 'children': ['59']}, {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'disconnection_required'}, {'id': '61', 'type': 'if_statement', 'children': ['62', '65']}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '64'], 'value': 'in'}, {'id': '63', 'type': 'string', 'children': [], 'value': "'@'"}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'conn_string'}, {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'raise_statement', 'children': ['67']}, {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}, {'id': '69', 'type': 'argument_list', 'children': ['70', '71']}; {'id': '70', 'type': 'string', 'children': [], 'value': '"Configuration files are not yet supported as part of a connection string argument"'}, {'id': '71', 'type': 'keyword_argument', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'conn_string'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'conn_string'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}, {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'pairs'}, {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'conn_string'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'split'}, {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'string', 'children': [], 'value': "';'"}, {'id': '83', 'type': 'for_statement', 'children': ['84', '85', '86']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'pair'}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'pairs'}; {'id': '86', 'type': 'block', 'children': ['87', '99', '115', '123', '131']}, {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '93']}, {'id': '89', 'type': 'pattern_list', 'children': ['90', '91', '92']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'pair'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'partition'}, {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'string', 'children': [], 'value': "'='"}, {'id': '99', 'type': 'if_statement', 'children': ['100', '113']}; {'id': '100', 'type': 'boolean_operator', 'children': ['101', '107'], 'value': 'or'}, {'id': '101', 'type': 'comparison_operator', 'children': ['102', '106'], 'value': '=='}; {'id': '102', 'type': 'call', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '106', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '107', 'type': 'comparison_operator', 'children': ['108', '112'], 'value': '=='}; {'id': '108', 'type': 'call', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '112', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '113', 'type': 'block', 'children': ['114']}; {'id': '114', 'type': 'continue_statement', 'children': []}, {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'assignment', 'children': ['117', '118']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '118', 'type': 'call', 'children': ['119', '122']}, {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '122', 'type': 'argument_list', 'children': []}, {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}, {'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': 'value'}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '130', 'type': 'argument_list', 'children': []}, {'id': '131', 'type': 'if_statement', 'children': ['132', '135', '199']}; {'id': '132', 'type': 'comparison_operator', 'children': ['133', '134'], 'value': '=='}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '134', 'type': 'string', 'children': [], 'value': "'device'"}, {'id': '135', 'type': 'block', 'children': ['136', '147']}; {'id': '136', 'type': 'if_statement', 'children': ['137', '140']}, {'id': '137', 'type': 'comparison_operator', 'children': ['138', '139'], 'value': 'in'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'DEVICE_ALIASES'}; {'id': '140', 'type': 'block', 'children': ['141']}, {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'assignment', 'children': ['143', '144']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'device_name'}; {'id': '144', 'type': 'subscript', 'children': ['145', '146']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'DEVICE_ALIASES'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '147', 'type': 'if_statement', 'children': ['148', '151', '178']}; {'id': '148', 'type': 'comparison_operator', 'children': ['149', '150'], 'value': 'in'}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'device_name'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'KNOWN_DEVICES'}, {'id': '151', 'type': 'block', 'children': ['152', '161']}; {'id': '152', 'type': 'expression_statement', 'children': ['153']}, {'id': '153', 'type': 'assignment', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'device_info'}, {'id': '155', 'type': 'call', 'children': ['156', '159']}; {'id': '156', 'type': 'attribute', 'children': ['157', '158']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'KNOWN_DEVICES'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'get'}, {'id': '159', 'type': 'argument_list', 'children': ['160']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'device_name'}, {'id': '161', 'type': 'if_statement', 'children': ['162', '167']}; {'id': '162', 'type': 'comparison_operator', 'children': ['163', '166'], 'value': '!='}, {'id': '163', 'type': 'attribute', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '165', 'type': 'identifier', 'children': [], 'value': '_device_info'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'device_info'}, {'id': '167', 'type': 'block', 'children': ['168', '174']}; {'id': '168', 'type': 'expression_statement', 'children': ['169']}, {'id': '169', 'type': 'assignment', 'children': ['170', '173']}; {'id': '170', 'type': 'attribute', 'children': ['171', '172']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': '_device_info'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'device_info'}; {'id': '174', 'type': 'expression_statement', 'children': ['175']}, {'id': '175', 'type': 'assignment', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'disconnection_required'}, {'id': '177', 'type': 'True', 'children': []}; {'id': '178', 'type': 'else_clause', 'children': ['179']}, {'id': '179', 'type': 'block', 'children': ['180']}; {'id': '180', 'type': 'raise_statement', 'children': ['181']}, {'id': '181', 'type': 'call', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}, {'id': '183', 'type': 'argument_list', 'children': ['184', '185', '188']}; {'id': '184', 'type': 'string', 'children': [], 'value': '"Unknown device name or alias, please select from known_devices"'}, {'id': '185', 'type': 'keyword_argument', 'children': ['186', '187']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'device_name'}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '188', 'type': 'keyword_argument', 'children': ['189', '190']}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'known_devices'}; {'id': '190', 'type': 'list_comprehension', 'children': ['191', '192']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '192', 'type': 'for_in_clause', 'children': ['193', '194']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '194', 'type': 'call', 'children': ['195', '198']}, {'id': '195', 'type': 'attribute', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'DEVICE_ALIASES'}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '198', 'type': 'argument_list', 'children': []}, {'id': '199', 'type': 'elif_clause', 'children': ['200', '203']}; {'id': '200', 'type': 'comparison_operator', 'children': ['201', '202'], 'value': '=='}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '202', 'type': 'string', 'children': [], 'value': "'channel'"}, {'id': '203', 'type': 'block', 'children': ['204']}; {'id': '204', 'type': 'if_statement', 'children': ['205', '210', '234']}, {'id': '205', 'type': 'comparison_operator', 'children': ['206', '209'], 'value': 'is'}; {'id': '206', 'type': 'attribute', 'children': ['207', '208']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '208', 'type': 'identifier', 'children': [], 'value': '_mux_func'}, {'id': '209', 'type': 'None', 'children': []}; {'id': '210', 'type': 'block', 'children': ['211']}, {'id': '211', 'type': 'if_statement', 'children': ['212', '220']}; {'id': '212', 'type': 'comparison_operator', 'children': ['213', '216'], 'value': '!='}, {'id': '213', 'type': 'attribute', 'children': ['214', '215']}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '215', 'type': 'identifier', 'children': [], 'value': '_channel'}; {'id': '216', 'type': 'call', 'children': ['217', '218']}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '218', 'type': 'argument_list', 'children': ['219']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '220', 'type': 'block', 'children': ['221', '230']}, {'id': '221', 'type': 'expression_statement', 'children': ['222']}; {'id': '222', 'type': 'assignment', 'children': ['223', '226']}, {'id': '223', 'type': 'attribute', 'children': ['224', '225']}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '225', 'type': 'identifier', 'children': [], 'value': '_channel'}; {'id': '226', 'type': 'call', 'children': ['227', '228']}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '228', 'type': 'argument_list', 'children': ['229']}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '230', 'type': 'expression_statement', 'children': ['231']}, {'id': '231', 'type': 'assignment', 'children': ['232', '233']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'disconnection_required'}, {'id': '233', 'type': 'True', 'children': []}; {'id': '234', 'type': 'else_clause', 'children': ['235']}, {'id': '235', 'type': 'block', 'children': ['236']}; {'id': '236', 'type': 'expression_statement', 'children': ['237']}, {'id': '237', 'type': 'call', 'children': ['238', '239']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'print'}, {'id': '239', 'type': 'argument_list', 'children': ['240']}; {'id': '240', 'type': 'string', 'children': [], 'value': '"Warning: multiplexing architecture not selected, channel will not be set"'}, {'id': '241', 'type': 'return_statement', 'children': ['242']}
def _parse_conn_string(self, conn_string): disconnection_required = False if conn_string is None or 'device' not in conn_string: if self._default_device_info is not None and self._device_info != self._default_device_info: disconnection_required = True self._device_info = self._default_device_info if conn_string is None or len(conn_string) == 0: return disconnection_required if '@' in conn_string: raise ArgumentError("Configuration files are not yet supported as part of a connection string argument", conn_string=conn_string) pairs = conn_string.split(';') for pair in pairs: name, _, value = pair.partition('=') if len(name) == 0 or len(value) == 0: continue name = name.strip() value = value.strip() if name == 'device': if value in DEVICE_ALIASES: device_name = DEVICE_ALIASES[value] if device_name in KNOWN_DEVICES: device_info = KNOWN_DEVICES.get(device_name) if self._device_info != device_info: self._device_info = device_info disconnection_required = True else: raise ArgumentError("Unknown device name or alias, please select from known_devices", device_name=value, known_devices=[x for x in DEVICE_ALIASES.keys()]) elif name == 'channel': if self._mux_func is not None: if self._channel != int(value): self._channel = int(value) disconnection_required = True else: print("Warning: multiplexing architecture not selected, channel will not be set") return disconnection_required
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '6', 'type': 'None', 'children': []}, {'id': '7', 'type': 'block', 'children': ['8', '23', '29', '40', '62', '68', '97', '106', '133', '145', '157', '161', '169', '276', '284', '290', '307', '317']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12']}, {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'is'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'argv'}, {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}, {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '16', 'type': 'subscript', 'children': ['17', '20']}, {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'sys'}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '20', 'type': 'slice', 'children': ['21', '22']}, {'id': '21', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '22', 'type': 'colon', 'children': []}, {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'build_args'}; {'id': '28', 'type': 'argument_list', 'children': []}, {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}, {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'parser'}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'parse_args'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}, {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}, {'id': '41', 'type': 'assignment', 'children': ['42', '45']}; {'id': '42', 'type': 'pattern_list', 'children': ['43', '44']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'recipe_name'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_ext'}, {'id': '45', 'type': 'call', 'children': ['46', '51']}; {'id': '46', 'type': 'attribute', 'children': ['47', '50']}, {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'splitext'}, {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '58']}, {'id': '53', 'type': 'attribute', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}, {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'recipe'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}, {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'rm'}, {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'RecipeManager'}, {'id': '67', 'type': 'argument_list', 'children': []}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}, {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'rm'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'add_recipe_folder'}, {'id': '73', 'type': 'argument_list', 'children': ['74', '84']}; {'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': 'os'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}, {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'recipe'}; {'id': '84', 'type': 'keyword_argument', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'whitelist'}; {'id': '86', 'type': 'list', 'children': ['87'], 'value': '[os.path.basename(args.recipe)]'}, {'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': 'basename'}, {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'recipe'}, {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'recipe'}; {'id': '100', 'type': 'call', 'children': ['101', '104']}, {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'rm'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'get_recipe'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'recipe_name'}; {'id': '106', 'type': 'if_statement', 'children': ['107', '112']}, {'id': '107', 'type': 'comparison_operator', 'children': ['108', '111'], 'value': 'is'}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'archive'}, {'id': '111', 'type': 'None', 'children': []}; {'id': '112', 'type': 'block', 'children': ['113', '122', '131']}, {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'call', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}, {'id': '117', 'type': 'binary_operator', 'children': ['118', '119'], 'value': '%'}; {'id': '118', 'type': 'string', 'children': [], 'value': '"Archiving recipe into %s"'}, {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'archive'}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}, {'id': '123', 'type': 'call', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'recipe'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'archive'}, {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'archive'}, {'id': '131', 'type': 'return_statement', 'children': ['132']}; {'id': '132', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '133', 'type': 'if_statement', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'info'}, {'id': '137', 'type': 'block', 'children': ['138', '143']}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}, {'id': '139', 'type': 'call', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'print'}, {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'recipe'}, {'id': '143', 'type': 'return_statement', 'children': ['144']}; {'id': '144', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '145', 'type': 'expression_statement', 'children': ['146']}; {'id': '146', 'type': 'assignment', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '148', 'type': 'call', 'children': ['149', '150']}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'load_variables'}; {'id': '150', 'type': 'argument_list', 'children': ['151', '154']}, {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'define'}; {'id': '154', 'type': 'attribute', 'children': ['155', '156']}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'config'}, {'id': '157', 'type': 'expression_statement', 'children': ['158']}; {'id': '158', 'type': 'assignment', 'children': ['159', '160']}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'success'}; {'id': '160', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '161', 'type': 'expression_statement', 'children': ['162']}; {'id': '162', 'type': 'assignment', 'children': ['163', '164']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '164', 'type': 'call', 'children': ['165', '168']}, {'id': '165', 'type': 'attribute', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'time'}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '168', 'type': 'argument_list', 'children': []}, {'id': '169', 'type': 'if_statement', 'children': ['170', '175', '207']}; {'id': '170', 'type': 'comparison_operator', 'children': ['171', '174'], 'value': 'is'}, {'id': '171', 'type': 'attribute', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '174', 'type': 'None', 'children': []}, {'id': '175', 'type': 'block', 'children': ['176']}; {'id': '176', 'type': 'try_statement', 'children': ['177', '189']}, {'id': '177', 'type': 'block', 'children': ['178', '185']}; {'id': '178', 'type': 'expression_statement', 'children': ['179']}, {'id': '179', 'type': 'call', 'children': ['180', '183']}; {'id': '180', 'type': 'attribute', 'children': ['181', '182']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'recipe'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'run'}, {'id': '183', 'type': 'argument_list', 'children': ['184']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'variables'}, {'id': '185', 'type': 'expression_statement', 'children': ['186']}; {'id': '186', 'type': 'augmented_assignment', 'children': ['187', '188'], 'value': '+='}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'success'}; {'id': '188', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '189', 'type': 'except_clause', 'children': ['190', '194']}; {'id': '190', 'type': 'as_pattern', 'children': ['191', '192']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'IOTileException'}; {'id': '192', 'type': 'as_pattern_target', 'children': ['193']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '194', 'type': 'block', 'children': ['195', '205']}, {'id': '195', 'type': 'expression_statement', 'children': ['196']}; {'id': '196', 'type': 'call', 'children': ['197', '198']}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '198', 'type': 'argument_list', 'children': ['199']}, {'id': '199', 'type': 'binary_operator', 'children': ['200', '201'], 'value': '%'}; {'id': '200', 'type': 'string', 'children': [], 'value': '"Error running recipe: %s"'}, {'id': '201', 'type': 'call', 'children': ['202', '203']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '203', 'type': 'argument_list', 'children': ['204']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'exc'}, {'id': '205', 'type': 'return_statement', 'children': ['206']}; {'id': '206', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '207', 'type': 'else_clause', 'children': ['208']}; {'id': '208', 'type': 'block', 'children': ['209']}, {'id': '209', 'type': 'while_statement', 'children': ['210', '211']}; {'id': '210', 'type': 'True', 'children': []}, {'id': '211', 'type': 'block', 'children': ['212', '223', '229', '237', '245']}; {'id': '212', 'type': 'expression_statement', 'children': ['213']}, {'id': '213', 'type': 'assignment', 'children': ['214', '215']}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '215', 'type': 'call', 'children': ['216', '217']}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'input'}, {'id': '217', 'type': 'argument_list', 'children': ['218']}; {'id': '218', 'type': 'binary_operator', 'children': ['219', '220'], 'value': '%'}, {'id': '219', 'type': 'string', 'children': [], 'value': '"Enter value for loop variable %s (return to stop): "'}; {'id': '220', 'type': 'attribute', 'children': ['221', '222']}, {'id': '221', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'loop'}, {'id': '223', 'type': 'if_statement', 'children': ['224', '227']}; {'id': '224', 'type': 'comparison_operator', 'children': ['225', '226'], 'value': '=='}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '226', 'type': 'string', 'children': [], 'value': "''"}, {'id': '227', 'type': 'block', 'children': ['228']}; {'id': '228', 'type': 'break_statement', 'children': []}, {'id': '229', 'type': 'expression_statement', 'children': ['230']}; {'id': '230', 'type': 'assignment', 'children': ['231', '232']}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'local_vars'}; {'id': '232', 'type': 'call', 'children': ['233', '234']}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '234', 'type': 'argument_list', 'children': ['235']}, {'id': '235', 'type': 'dictionary_splat', 'children': ['236']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'variables'}, {'id': '237', 'type': 'expression_statement', 'children': ['238']}; {'id': '238', 'type': 'assignment', 'children': ['239', '244']}, {'id': '239', 'type': 'subscript', 'children': ['240', '241']}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'local_vars'}, {'id': '241', 'type': 'attribute', 'children': ['242', '243']}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '245', 'type': 'try_statement', 'children': ['246', '258']}; {'id': '246', 'type': 'block', 'children': ['247', '254']}, {'id': '247', 'type': 'expression_statement', 'children': ['248']}; {'id': '248', 'type': 'call', 'children': ['249', '252']}, {'id': '249', 'type': 'attribute', 'children': ['250', '251']}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'recipe'}, {'id': '251', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '252', 'type': 'argument_list', 'children': ['253']}, {'id': '253', 'type': 'identifier', 'children': [], 'value': 'local_vars'}; {'id': '254', 'type': 'expression_statement', 'children': ['255']}, {'id': '255', 'type': 'augmented_assignment', 'children': ['256', '257'], 'value': '+='}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'success'}, {'id': '257', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '258', 'type': 'except_clause', 'children': ['259', '263']}, {'id': '259', 'type': 'as_pattern', 'children': ['260', '261']}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'IOTileException'}, {'id': '261', 'type': 'as_pattern_target', 'children': ['262']}; {'id': '262', 'type': 'identifier', 'children': [], 'value': 'exc'}, {'id': '263', 'type': 'block', 'children': ['264']}; {'id': '264', 'type': 'expression_statement', 'children': ['265']}, {'id': '265', 'type': 'call', 'children': ['266', '267']}; {'id': '266', 'type': 'identifier', 'children': [], 'value': 'print'}, {'id': '267', 'type': 'argument_list', 'children': ['268']}; {'id': '268', 'type': 'binary_operator', 'children': ['269', '270'], 'value': '%'}, {'id': '269', 'type': 'string', 'children': [], 'value': '"--> ERROR processing loop variable %s: %s"'}; {'id': '270', 'type': 'tuple', 'children': ['271', '272']}, {'id': '271', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '272', 'type': 'call', 'children': ['273', '274']}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '274', 'type': 'argument_list', 'children': ['275']}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '276', 'type': 'expression_statement', 'children': ['277']}, {'id': '277', 'type': 'assignment', 'children': ['278', '279']}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'end_time'}, {'id': '279', 'type': 'call', 'children': ['280', '283']}; {'id': '280', 'type': 'attribute', 'children': ['281', '282']}, {'id': '281', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '282', 'type': 'identifier', 'children': [], 'value': 'time'}, {'id': '283', 'type': 'argument_list', 'children': []}; {'id': '284', 'type': 'expression_statement', 'children': ['285']}, {'id': '285', 'type': 'assignment', 'children': ['286', '287']}; {'id': '286', 'type': 'identifier', 'children': [], 'value': 'total_time'}, {'id': '287', 'type': 'binary_operator', 'children': ['288', '289'], 'value': '-'}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'end_time'}, {'id': '289', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '290', 'type': 'if_statement', 'children': ['291', '294', '299']}, {'id': '291', 'type': 'comparison_operator', 'children': ['292', '293'], 'value': '=='}; {'id': '292', 'type': 'identifier', 'children': [], 'value': 'success'}, {'id': '293', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '294', 'type': 'block', 'children': ['295']}, {'id': '295', 'type': 'expression_statement', 'children': ['296']}; {'id': '296', 'type': 'assignment', 'children': ['297', '298']}, {'id': '297', 'type': 'identifier', 'children': [], 'value': 'per_time'}; {'id': '298', 'type': 'float', 'children': [], 'value': '0.0'}, {'id': '299', 'type': 'else_clause', 'children': ['300']}; {'id': '300', 'type': 'block', 'children': ['301']}, {'id': '301', 'type': 'expression_statement', 'children': ['302']}; {'id': '302', 'type': 'assignment', 'children': ['303', '304']}, {'id': '303', 'type': 'identifier', 'children': [], 'value': 'per_time'}; {'id': '304', 'type': 'binary_operator', 'children': ['305', '306'], 'value': '/'}, {'id': '305', 'type': 'identifier', 'children': [], 'value': 'total_time'}; {'id': '306', 'type': 'identifier', 'children': [], 'value': 'success'}, {'id': '307', 'type': 'expression_statement', 'children': ['308']}; {'id': '308', 'type': 'call', 'children': ['309', '310']}, {'id': '309', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '310', 'type': 'argument_list', 'children': ['311']}, {'id': '311', 'type': 'binary_operator', 'children': ['312', '313'], 'value': '%'}; {'id': '312', 'type': 'string', 'children': [], 'value': '"Performed %d runs in %.1f seconds (%.1f seconds / run)"'}, {'id': '313', 'type': 'tuple', 'children': ['314', '315', '316']}; {'id': '314', 'type': 'identifier', 'children': [], 'value': 'success'}, {'id': '315', 'type': 'identifier', 'children': [], 'value': 'total_time'}; {'id': '316', 'type': 'identifier', 'children': [], 'value': 'per_time'}, {'id': '317', 'type': 'return_statement', 'children': ['318']}
def main(argv=None): if argv is None: argv = sys.argv[1:] parser = build_args() args = parser.parse_args(args=argv) recipe_name, _ext = os.path.splitext(os.path.basename(args.recipe)) rm = RecipeManager() rm.add_recipe_folder(os.path.dirname(args.recipe), whitelist=[os.path.basename(args.recipe)]) recipe = rm.get_recipe(recipe_name) if args.archive is not None: print("Archiving recipe into %s" % args.archive) recipe.archive(args.archive) return 0 if args.info: print(recipe) return 0 variables = load_variables(args.define, args.config) success = 0 start_time = time.time() if args.loop is None: try: recipe.run(variables) success += 1 except IOTileException as exc: print("Error running recipe: %s" % str(exc)) return 1 else: while True: value = input("Enter value for loop variable %s (return to stop): " % args.loop) if value == '': break local_vars = dict(**variables) local_vars[args.loop] = value try: recipe.run(local_vars) success += 1 except IOTileException as exc: print("--> ERROR processing loop variable %s: %s" % (value, str(exc))) end_time = time.time() total_time = end_time - start_time if success == 0: per_time = 0.0 else: per_time = total_time / success print("Performed %d runs in %.1f seconds (%.1f seconds / run)" % (success, total_time, per_time)) return 0
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'assign_utc'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'reading_id'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'uptime'}; {'id': '8', 'type': 'None', 'children': []}, {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'prefer'}, {'id': '11', 'type': 'string', 'children': [], 'value': '"before"'}; {'id': '12', 'type': 'block', 'children': ['13', '30', '42', '56', '67', '71', '75', '79', '91', '102', '131', '143', '154', '166', '177']}, {'id': '13', 'type': 'if_statement', 'children': ['14', '19']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '16'], 'value': 'not'}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'prefer'}; {'id': '16', 'type': 'tuple', 'children': ['17', '18']}, {'id': '17', 'type': 'string', 'children': [], 'value': '"before"'}; {'id': '18', 'type': 'string', 'children': [], 'value': '"after"'}, {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'raise_statement', 'children': ['21']}, {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}, {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}, {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': '"Invalid prefer parameter: {}, must be \'before\' or \'after\'"'}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'prefer'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '39']}, {'id': '31', 'type': 'comparison_operator', 'children': ['32', '38'], 'value': '=='}; {'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': 'self'}, {'id': '37', 'type': 'identifier', 'children': [], 'value': '_anchor_points'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}, {'id': '41', 'type': 'None', 'children': []}; {'id': '42', 'type': 'if_statement', 'children': ['43', '53']}, {'id': '43', 'type': 'comparison_operator', 'children': ['44', '45'], 'value': '>'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'reading_id'}, {'id': '45', 'type': 'attribute', 'children': ['46', '52']}; {'id': '46', 'type': 'subscript', 'children': ['47', '50']}, {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '49', 'type': 'identifier', 'children': [], 'value': '_anchor_points'}; {'id': '50', 'type': 'unary_operator', 'children': ['51'], 'value': '-'}, {'id': '51', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'reading_id'}, {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'return_statement', 'children': ['55']}, {'id': '55', 'type': 'None', 'children': []}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}, {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '59', 'type': 'call', 'children': ['60', '65']}; {'id': '60', 'type': 'attribute', 'children': ['61', '64']}, {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': '_anchor_points'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'bisect_key_left'}, {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'reading_id'}, {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'found_id'}; {'id': '70', 'type': 'False', 'children': []}, {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'crossed_break'}; {'id': '74', 'type': 'False', 'children': []}, {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'exact'}; {'id': '78', 'type': 'True', 'children': []}, {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'last'}; {'id': '82', 'type': 'call', 'children': ['83', '90']}, {'id': '83', 'type': 'attribute', 'children': ['84', '89']}; {'id': '84', 'type': 'subscript', 'children': ['85', '88']}, {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': '_anchor_points'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '90', 'type': 'argument_list', 'children': []}, {'id': '91', 'type': 'if_statement', 'children': ['92', '95']}; {'id': '92', 'type': 'comparison_operator', 'children': ['93', '94'], 'value': 'is'}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'uptime'}; {'id': '94', 'type': 'None', 'children': []}, {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}, {'id': '97', 'type': 'assignment', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'last'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'uptime'}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'uptime'}; {'id': '102', 'type': 'if_statement', 'children': ['103', '108']}, {'id': '103', 'type': 'comparison_operator', 'children': ['104', '107'], 'value': '=='}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'last'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'reading_id'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'reading_id'}; {'id': '108', 'type': 'block', 'children': ['109', '113']}, {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'found_id'}; {'id': '112', 'type': 'True', 'children': []}, {'id': '113', 'type': 'if_statement', 'children': ['114', '119']}; {'id': '114', 'type': 'comparison_operator', 'children': ['115', '118'], 'value': 'is'}, {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'last'}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'utc'}; {'id': '118', 'type': 'None', 'children': []}, {'id': '119', 'type': 'block', 'children': ['120']}; {'id': '120', 'type': 'return_statement', 'children': ['121']}, {'id': '121', 'type': 'call', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'UTCAssignment'}, {'id': '123', 'type': 'argument_list', 'children': ['124', '125', '128', '129', '130']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'reading_id'}, {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'last'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'utc'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'found_id'}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'exact'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'crossed_break'}, {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'assignment', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'left_assign'}; {'id': '134', 'type': 'call', 'children': ['135', '138']}, {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '137', 'type': 'identifier', 'children': [], 'value': '_fix_left'}; {'id': '138', 'type': 'argument_list', 'children': ['139', '140', '141', '142']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'reading_id'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'last'}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'found_id'}, {'id': '143', 'type': 'if_statement', 'children': ['144', '151']}; {'id': '144', 'type': 'boolean_operator', 'children': ['145', '148'], 'value': 'and'}, {'id': '145', 'type': 'comparison_operator', 'children': ['146', '147'], 'value': 'is'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'left_assign'}, {'id': '147', 'type': 'None', 'children': []}; {'id': '148', 'type': 'attribute', 'children': ['149', '150']}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'left_assign'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'exact'}, {'id': '151', 'type': 'block', 'children': ['152']}; {'id': '152', 'type': 'return_statement', 'children': ['153']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'left_assign'}; {'id': '154', 'type': 'expression_statement', 'children': ['155']}, {'id': '155', 'type': 'assignment', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'right_assign'}, {'id': '157', 'type': 'call', 'children': ['158', '161']}; {'id': '158', 'type': 'attribute', 'children': ['159', '160']}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': '_fix_right'}, {'id': '161', 'type': 'argument_list', 'children': ['162', '163', '164', '165']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'reading_id'}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'last'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'i'}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'found_id'}; {'id': '166', 'type': 'if_statement', 'children': ['167', '174']}, {'id': '167', 'type': 'boolean_operator', 'children': ['168', '171'], 'value': 'and'}; {'id': '168', 'type': 'comparison_operator', 'children': ['169', '170'], 'value': 'is'}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'right_assign'}; {'id': '170', 'type': 'None', 'children': []}, {'id': '171', 'type': 'attribute', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'right_assign'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'exact'}; {'id': '174', 'type': 'block', 'children': ['175']}, {'id': '175', 'type': 'return_statement', 'children': ['176']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'right_assign'}, {'id': '177', 'type': 'return_statement', 'children': ['178']}; {'id': '178', 'type': 'call', 'children': ['179', '182']}, {'id': '179', 'type': 'attribute', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '181', 'type': 'identifier', 'children': [], 'value': '_pick_best_fix'}; {'id': '182', 'type': 'argument_list', 'children': ['183', '184', '185']}, {'id': '183', 'type': 'identifier', 'children': [], 'value': 'left_assign'}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'right_assign'}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'prefer'}
def assign_utc(self, reading_id, uptime=None, prefer="before"): if prefer not in ("before", "after"): raise ArgumentError("Invalid prefer parameter: {}, must be 'before' or 'after'".format(prefer)) if len(self._anchor_points) == 0: return None if reading_id > self._anchor_points[-1].reading_id: return None i = self._anchor_points.bisect_key_left(reading_id) found_id = False crossed_break = False exact = True last = self._anchor_points[i].copy() if uptime is not None: last.uptime = uptime if last.reading_id == reading_id: found_id = True if last.utc is not None: return UTCAssignment(reading_id, last.utc, found_id, exact, crossed_break) left_assign = self._fix_left(reading_id, last, i, found_id) if left_assign is not None and left_assign.exact: return left_assign right_assign = self._fix_right(reading_id, last, i, found_id) if right_assign is not None and right_assign.exact: return right_assign return self._pick_best_fix(left_assign, right_assign, prefer)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_text_contents'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '19', '28']}, {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}, {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'disambiguate'}, {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'must_exist'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '19', 'type': 'except_clause', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}, {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'Errors'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'UserError'}, {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': ['27']}, {'id': '27', 'type': 'string', 'children': [], 'value': "''"}; {'id': '28', 'type': 'else_clause', 'children': ['29']}, {'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': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get_text_contents'}, {'id': '35', 'type': 'argument_list', 'children': []}
def get_text_contents(self): try: self = self.disambiguate(must_exist=1) except SCons.Errors.UserError: return '' else: return self.get_text_contents()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_lookup'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'directory'}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'fsclass'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'create'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '11', 'type': 'block', 'children': ['12', '28', '35', '49', '108', '117', '124', '153', '170', '186', '200', '207', '305', '373']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '18']}, {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'isinstance'}, {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Base'}; {'id': '18', 'type': 'block', 'children': ['19', '26']}, {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}, {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'must_be_same'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'fsclass'}; {'id': '26', 'type': 'return_statement', 'children': ['27']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}, {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '35', 'type': 'if_statement', 'children': ['36', '38']}; {'id': '36', 'type': 'not_operator', 'children': ['37']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'os_sep_is_slash'}; {'id': '38', 'type': 'block', 'children': ['39']}, {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '42', 'type': 'call', 'children': ['43', '46']}, {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'OS_SEP'}; {'id': '48', 'type': 'string', 'children': [], 'value': "'/'"}, {'id': '49', 'type': 'if_statement', 'children': ['50', '68', '70', '100']}; {'id': '50', 'type': 'comparison_operator', 'children': ['51', '57', '65'], 'value': '=='}, {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '53', 'type': 'slice', 'children': ['54', '55', '56']}; {'id': '54', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '55', 'type': 'colon', 'children': []}; {'id': '56', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '57', 'type': 'ERROR', 'children': ['58', '59', '64']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '61', 'type': 'slice', 'children': ['62', '63']}; {'id': '62', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '63', 'type': 'colon', 'children': []}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'directory'}, {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'Top'}; {'id': '68', 'type': 'ERROR', 'children': ['69']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'do_splitdrive'}; {'id': '70', 'type': 'block', 'children': ['71', '80']}, {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '76']}, {'id': '73', 'type': 'pattern_list', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'drive'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '76', 'type': 'call', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': '_my_splitdrive'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '80', 'type': 'if_statement', 'children': ['81', '82', '92']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'drive'}; {'id': '82', 'type': 'block', 'children': ['83']}, {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '86', 'type': 'call', 'children': ['87', '90']}, {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'get_root'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'drive'}; {'id': '92', 'type': 'else_clause', 'children': ['93']}, {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}, {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'directory'}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '100', 'type': 'else_clause', 'children': ['101']}, {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}, {'id': '103', 'type': 'assignment', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'directory'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}, {'id': '109', 'type': 'assignment', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'strip'}, {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'string', 'children': [], 'value': "'/'"}, {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'assignment', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'needs_normpath'}; {'id': '120', 'type': 'call', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'needs_normpath_match'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '124', 'type': 'if_statement', 'children': ['125', '130', '139']}, {'id': '125', 'type': 'comparison_operator', 'children': ['126', '127'], 'value': 'in'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '127', 'type': 'tuple', 'children': ['128', '129']}; {'id': '128', 'type': 'string', 'children': [], 'value': "''"}, {'id': '129', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '130', 'type': 'block', 'children': ['131']}, {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'assignment', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '134', 'type': 'call', 'children': ['135', '138']}, {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'directory'}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'get_labspath'}; {'id': '138', 'type': 'argument_list', 'children': []}, {'id': '139', 'type': 'else_clause', 'children': ['140']}; {'id': '140', 'type': 'block', 'children': ['141']}, {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'assignment', 'children': ['143', '144']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '144', 'type': 'binary_operator', 'children': ['145', '152'], 'value': '+'}, {'id': '145', 'type': 'binary_operator', 'children': ['146', '151'], 'value': '+'}; {'id': '146', 'type': 'call', 'children': ['147', '150']}, {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'directory'}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'get_labspath'}; {'id': '150', 'type': 'argument_list', 'children': []}, {'id': '151', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'assignment', 'children': ['155', '156', '158', '164', '166']}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'else'}; {'id': '156', 'type': 'ERROR', 'children': ['157']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'if'}; {'id': '158', 'type': 'type', 'children': ['159']}, {'id': '159', 'type': 'constrained_type', 'children': ['160', '162']}; {'id': '160', 'type': 'type', 'children': ['161']}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'do_splitdrive'}; {'id': '162', 'type': 'type', 'children': ['163']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'drive'}; {'id': '164', 'type': 'ERROR', 'children': ['165']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '166', 'type': 'call', 'children': ['167', '168']}, {'id': '167', 'type': 'identifier', 'children': [], 'value': '_my_splitdrive'}; {'id': '168', 'type': 'argument_list', 'children': ['169']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '170', 'type': 'if_statement', 'children': ['171', '175', '180']}, {'id': '171', 'type': 'boolean_operator', 'children': ['172', '173'], 'value': 'and'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'drive'}, {'id': '173', 'type': 'not_operator', 'children': ['174']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '175', 'type': 'block', 'children': ['176']}; {'id': '176', 'type': 'expression_statement', 'children': ['177']}, {'id': '177', 'type': 'assignment', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '179', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '180', 'type': 'else_clause', 'children': ['181']}, {'id': '181', 'type': 'block', 'children': ['182']}; {'id': '182', 'type': 'expression_statement', 'children': ['183']}, {'id': '183', 'type': 'assignment', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'drive'}, {'id': '185', 'type': 'string', 'children': [], 'value': "''"}; {'id': '186', 'type': 'if_statement', 'children': ['187', '190']}, {'id': '187', 'type': 'comparison_operator', 'children': ['188', '189'], 'value': '!='}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '189', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '190', 'type': 'block', 'children': ['191']}, {'id': '191', 'type': 'expression_statement', 'children': ['192']}; {'id': '192', 'type': 'assignment', 'children': ['193', '194']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '194', 'type': 'call', 'children': ['195', '198']}, {'id': '195', 'type': 'attribute', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'rstrip'}; {'id': '198', 'type': 'argument_list', 'children': ['199']}, {'id': '199', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '200', 'type': 'expression_statement', 'children': ['201']}, {'id': '201', 'type': 'assignment', 'children': ['202', '203']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'needs_normpath'}, {'id': '203', 'type': 'call', 'children': ['204', '205']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'needs_normpath_match'}, {'id': '205', 'type': 'argument_list', 'children': ['206']}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '207', 'type': 'if_statement', 'children': ['208', '216', '226']}; {'id': '208', 'type': 'comparison_operator', 'children': ['209', '215'], 'value': '=='}, {'id': '209', 'type': 'subscript', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '211', 'type': 'slice', 'children': ['212', '213', '214']}; {'id': '212', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '213', 'type': 'colon', 'children': []}; {'id': '214', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '215', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '216', 'type': 'block', 'children': ['217']}, {'id': '217', 'type': 'expression_statement', 'children': ['218']}; {'id': '218', 'type': 'assignment', 'children': ['219', '220']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '220', 'type': 'call', 'children': ['221', '224']}, {'id': '221', 'type': 'attribute', 'children': ['222', '223']}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'get_root'}; {'id': '224', 'type': 'argument_list', 'children': ['225']}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'drive'}; {'id': '226', 'type': 'else_clause', 'children': ['227']}, {'id': '227', 'type': 'block', 'children': ['228', '256', '285']}; {'id': '228', 'type': 'if_statement', 'children': ['229', '230', '248']}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '230', 'type': 'block', 'children': ['231']}, {'id': '231', 'type': 'if_statement', 'children': ['232', '238']}; {'id': '232', 'type': 'not_operator', 'children': ['233']}, {'id': '233', 'type': 'call', 'children': ['234', '235']}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'isinstance'}, {'id': '235', 'type': 'argument_list', 'children': ['236', '237']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'directory'}, {'id': '237', 'type': 'identifier', 'children': [], 'value': 'Dir'}; {'id': '238', 'type': 'block', 'children': ['239']}, {'id': '239', 'type': 'expression_statement', 'children': ['240']}; {'id': '240', 'type': 'assignment', 'children': ['241', '242']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '242', 'type': 'call', 'children': ['243', '246']}, {'id': '243', 'type': 'attribute', 'children': ['244', '245']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'Dir'}; {'id': '246', 'type': 'argument_list', 'children': ['247']}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '248', 'type': 'else_clause', 'children': ['249']}, {'id': '249', 'type': 'block', 'children': ['250']}; {'id': '250', 'type': 'expression_statement', 'children': ['251']}, {'id': '251', 'type': 'assignment', 'children': ['252', '253']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'directory'}, {'id': '253', 'type': 'attribute', 'children': ['254', '255']}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '255', 'type': 'identifier', 'children': [], 'value': '_cwd'}; {'id': '256', 'type': 'if_statement', 'children': ['257', '262', '271']}, {'id': '257', 'type': 'comparison_operator', 'children': ['258', '259'], 'value': 'in'}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '259', 'type': 'tuple', 'children': ['260', '261']}; {'id': '260', 'type': 'string', 'children': [], 'value': "''"}, {'id': '261', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '262', 'type': 'block', 'children': ['263']}, {'id': '263', 'type': 'expression_statement', 'children': ['264']}; {'id': '264', 'type': 'assignment', 'children': ['265', '266']}, {'id': '265', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '266', 'type': 'call', 'children': ['267', '270']}, {'id': '267', 'type': 'attribute', 'children': ['268', '269']}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'directory'}, {'id': '269', 'type': 'identifier', 'children': [], 'value': 'get_labspath'}; {'id': '270', 'type': 'argument_list', 'children': []}, {'id': '271', 'type': 'else_clause', 'children': ['272']}; {'id': '272', 'type': 'block', 'children': ['273']}, {'id': '273', 'type': 'expression_statement', 'children': ['274']}; {'id': '274', 'type': 'assignment', 'children': ['275', '276']}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '276', 'type': 'binary_operator', 'children': ['277', '284'], 'value': '+'}, {'id': '277', 'type': 'binary_operator', 'children': ['278', '283'], 'value': '+'}; {'id': '278', 'type': 'call', 'children': ['279', '282']}, {'id': '279', 'type': 'attribute', 'children': ['280', '281']}; {'id': '280', 'type': 'identifier', 'children': [], 'value': 'directory'}, {'id': '281', 'type': 'identifier', 'children': [], 'value': 'get_labspath'}; {'id': '282', 'type': 'argument_list', 'children': []}, {'id': '283', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '284', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '285', 'type': 'if_statement', 'children': ['286', '287', '297']}; {'id': '286', 'type': 'identifier', 'children': [], 'value': 'drive'}, {'id': '287', 'type': 'block', 'children': ['288']}; {'id': '288', 'type': 'expression_statement', 'children': ['289']}, {'id': '289', 'type': 'assignment', 'children': ['290', '291']}; {'id': '290', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '291', 'type': 'call', 'children': ['292', '295']}; {'id': '292', 'type': 'attribute', 'children': ['293', '294']}, {'id': '293', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'get_root'}, {'id': '295', 'type': 'argument_list', 'children': ['296']}; {'id': '296', 'type': 'identifier', 'children': [], 'value': 'drive'}, {'id': '297', 'type': 'else_clause', 'children': ['298']}; {'id': '298', 'type': 'block', 'children': ['299']}, {'id': '299', 'type': 'expression_statement', 'children': ['300']}; {'id': '300', 'type': 'assignment', 'children': ['301', '302']}, {'id': '301', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '302', 'type': 'attribute', 'children': ['303', '304']}, {'id': '303', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '304', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '305', 'type': 'if_statement', 'children': ['306', '309']}; {'id': '306', 'type': 'comparison_operator', 'children': ['307', '308'], 'value': 'is'}, {'id': '307', 'type': 'identifier', 'children': [], 'value': 'needs_normpath'}; {'id': '308', 'type': 'None', 'children': []}, {'id': '309', 'type': 'block', 'children': ['310', '323', '327', '362']}; {'id': '310', 'type': 'expression_statement', 'children': ['311']}, {'id': '311', 'type': 'assignment', 'children': ['312', '313']}; {'id': '312', 'type': 'identifier', 'children': [], 'value': 'ins'}, {'id': '313', 'type': 'subscript', 'children': ['314', '320']}; {'id': '314', 'type': 'call', 'children': ['315', '318']}, {'id': '315', 'type': 'attribute', 'children': ['316', '317']}; {'id': '316', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '317', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '318', 'type': 'argument_list', 'children': ['319']}, {'id': '319', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '320', 'type': 'slice', 'children': ['321', '322']}, {'id': '321', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '322', 'type': 'colon', 'children': []}, {'id': '323', 'type': 'expression_statement', 'children': ['324']}; {'id': '324', 'type': 'assignment', 'children': ['325', '326']}, {'id': '325', 'type': 'identifier', 'children': [], 'value': 'outs'}; {'id': '326', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '327', 'type': 'for_statement', 'children': ['328', '329', '330']}; {'id': '328', 'type': 'identifier', 'children': [], 'value': 'd'}, {'id': '329', 'type': 'identifier', 'children': [], 'value': 'ins'}; {'id': '330', 'type': 'block', 'children': ['331']}, {'id': '331', 'type': 'if_statement', 'children': ['332', '335', '348']}; {'id': '332', 'type': 'comparison_operator', 'children': ['333', '334'], 'value': '=='}, {'id': '333', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '334', 'type': 'string', 'children': [], 'value': "'..'"}, {'id': '335', 'type': 'block', 'children': ['336']}; {'id': '336', 'type': 'try_statement', 'children': ['337', '344']}, {'id': '337', 'type': 'block', 'children': ['338']}; {'id': '338', 'type': 'expression_statement', 'children': ['339']}, {'id': '339', 'type': 'call', 'children': ['340', '343']}; {'id': '340', 'type': 'attribute', 'children': ['341', '342']}, {'id': '341', 'type': 'identifier', 'children': [], 'value': 'outs'}; {'id': '342', 'type': 'identifier', 'children': [], 'value': 'pop'}, {'id': '343', 'type': 'argument_list', 'children': []}; {'id': '344', 'type': 'except_clause', 'children': ['345', '346']}, {'id': '345', 'type': 'identifier', 'children': [], 'value': 'IndexError'}; {'id': '346', 'type': 'block', 'children': ['347']}, {'id': '347', 'type': 'pass_statement', 'children': []}; {'id': '348', 'type': 'elif_clause', 'children': ['349', '354']}, {'id': '349', 'type': 'comparison_operator', 'children': ['350', '351'], 'value': 'not'}; {'id': '350', 'type': 'identifier', 'children': [], 'value': 'd'}, {'id': '351', 'type': 'tuple', 'children': ['352', '353']}; {'id': '352', 'type': 'string', 'children': [], 'value': "''"}, {'id': '353', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '354', 'type': 'block', 'children': ['355']}, {'id': '355', 'type': 'expression_statement', 'children': ['356']}; {'id': '356', 'type': 'call', 'children': ['357', '360']}, {'id': '357', 'type': 'attribute', 'children': ['358', '359']}; {'id': '358', 'type': 'identifier', 'children': [], 'value': 'outs'}, {'id': '359', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '360', 'type': 'argument_list', 'children': ['361']}, {'id': '361', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '362', 'type': 'expression_statement', 'children': ['363']}, {'id': '363', 'type': 'assignment', 'children': ['364', '365']}; {'id': '364', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '365', 'type': 'binary_operator', 'children': ['366', '367'], 'value': '+'}; {'id': '366', 'type': 'string', 'children': [], 'value': "'/'"}, {'id': '367', 'type': 'call', 'children': ['368', '371']}; {'id': '368', 'type': 'attribute', 'children': ['369', '370']}, {'id': '369', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '370', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '371', 'type': 'argument_list', 'children': ['372']}; {'id': '372', 'type': 'identifier', 'children': [], 'value': 'outs'}, {'id': '373', 'type': 'return_statement', 'children': ['374']}; {'id': '374', 'type': 'call', 'children': ['375', '378']}, {'id': '375', 'type': 'attribute', 'children': ['376', '377']}; {'id': '376', 'type': 'identifier', 'children': [], 'value': 'root'}, {'id': '377', 'type': 'identifier', 'children': [], 'value': '_lookup_abs'}; {'id': '378', 'type': 'argument_list', 'children': ['379', '380', '381']}, {'id': '379', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '380', 'type': 'identifier', 'children': [], 'value': 'fsclass'}, {'id': '381', 'type': 'identifier', 'children': [], 'value': 'create'}
def _lookup(self, p, directory, fsclass, create=1): if isinstance(p, Base): p.must_be_same(fsclass) return p p = str(p) if not os_sep_is_slash: p = p.replace(OS_SEP, '/') if p[0:1] == ' p = p[1:] directory = self.Top if do_splitdrive: drive, p = _my_splitdrive(p) if drive: root = self.get_root(drive) else: root = directory.root else: root = directory.root p = p.strip('/') needs_normpath = needs_normpath_match(p) if p in ('', '.'): p = directory.get_labspath() else: p = directory.get_labspath() + '/' + p else: if do_splitdrive: drive, p = _my_splitdrive(p) if drive and not p: p = '/' else: drive = '' if p != '/': p = p.rstrip('/') needs_normpath = needs_normpath_match(p) if p[0:1] == '/': root = self.get_root(drive) else: if directory: if not isinstance(directory, Dir): directory = self.Dir(directory) else: directory = self._cwd if p in ('', '.'): p = directory.get_labspath() else: p = directory.get_labspath() + '/' + p if drive: root = self.get_root(drive) else: root = directory.root if needs_normpath is not None: ins = p.split('/')[1:] outs = [] for d in ins: if d == '..': try: outs.pop() except IndexError: pass elif d not in ('', '.'): outs.append(d) p = '/' + '/'.join(outs) return root._lookup_abs(p, fsclass, create)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_glob1'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'ondisk'}; {'id': '8', 'type': 'True', 'children': []}, {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'source'}, {'id': '11', 'type': 'False', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'strings'}; {'id': '14', 'type': 'False', 'children': []}, {'id': '15', 'type': 'block', 'children': ['16', '24', '43', '49', '53', '222', '229', '250', '260', '265']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}, {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'search_dir_list'}, {'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': 'get_all_rdirs'}, {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'for_statement', 'children': ['25', '26', '31']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'srcdir'}; {'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': 'srcdir_list'}; {'id': '30', 'type': 'argument_list', 'children': []}, {'id': '31', 'type': 'block', 'children': ['32']}; {'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': 'search_dir_list'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'extend'}, {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}, {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'srcdir'}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'get_all_rdirs'}; {'id': '42', 'type': 'argument_list', 'children': []}, {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'selfEntry'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'Entry'}, {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '52', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '53', 'type': 'for_statement', 'children': ['54', '55', '56']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'dir'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'search_dir_list'}; {'id': '56', 'type': 'block', 'children': ['57', '81', '88', '101']}, {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'node_names'}; {'id': '60', 'type': 'list_comprehension', 'children': ['61', '64', '75']}, {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'v'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '64', 'type': 'for_in_clause', 'children': ['65', '68']}, {'id': '65', 'type': 'pattern_list', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'k'}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'v'}; {'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': 'dir'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'entries'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '74', 'type': 'argument_list', 'children': []}, {'id': '75', 'type': 'if_clause', 'children': ['76']}; {'id': '76', 'type': 'comparison_operator', 'children': ['77', '78'], 'value': 'not'}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '78', 'type': 'tuple', 'children': ['79', '80']}, {'id': '79', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '80', 'type': 'string', 'children': [], 'value': "'..'"}, {'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': 'names'}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'node_names'}; {'id': '88', 'type': 'if_statement', 'children': ['89', '91']}, {'id': '89', 'type': 'not_operator', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'strings'}, {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'for_statement', 'children': ['93', '94', '95']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'node_names'}, {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}, {'id': '97', 'type': 'call', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'selfEntry'}, {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '101', 'type': 'if_statement', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'ondisk'}, {'id': '103', 'type': 'block', 'children': ['104', '123', '130']}; {'id': '104', 'type': 'try_statement', 'children': ['105', '117']}, {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}, {'id': '107', 'type': 'assignment', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'disk_names'}, {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'listdir'}, {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': '_abspath'}, {'id': '117', 'type': 'except_clause', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'error'}, {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'continue_statement', 'children': []}, {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '128']}, {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'names'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'disk_names'}; {'id': '130', 'type': 'if_statement', 'children': ['131', '133']}, {'id': '131', 'type': 'not_operator', 'children': ['132']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'strings'}, {'id': '133', 'type': 'block', 'children': ['134', '155', '165', '171']}; {'id': '134', 'type': 'if_statement', 'children': ['135', '140']}, {'id': '135', 'type': 'comparison_operator', 'children': ['136', '139'], 'value': '!='}; {'id': '136', 'type': 'subscript', 'children': ['137', '138']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '138', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '139', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '140', 'type': 'block', 'children': ['141']}, {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'assignment', 'children': ['143', '144']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'disk_names'}; {'id': '144', 'type': 'list_comprehension', 'children': ['145', '146', '149']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '146', 'type': 'for_in_clause', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'disk_names'}, {'id': '149', 'type': 'if_clause', 'children': ['150']}; {'id': '150', 'type': 'comparison_operator', 'children': ['151', '154'], 'value': '!='}, {'id': '151', 'type': 'subscript', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '153', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '154', 'type': 'string', 'children': [], 'value': "'.'"}, {'id': '155', 'type': 'expression_statement', 'children': ['156']}; {'id': '156', 'type': 'assignment', 'children': ['157', '158']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'disk_names'}; {'id': '158', 'type': 'call', 'children': ['159', '162']}, {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'fnmatch'}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '162', 'type': 'argument_list', 'children': ['163', '164']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'disk_names'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'pattern'}, {'id': '165', 'type': 'expression_statement', 'children': ['166']}; {'id': '166', 'type': 'assignment', 'children': ['167', '168']}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'dirEntry'}; {'id': '168', 'type': 'attribute', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'Entry'}, {'id': '171', 'type': 'for_statement', 'children': ['172', '173', '174']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'disk_names'}; {'id': '174', 'type': 'block', 'children': ['175', '181', '192', '199']}, {'id': '175', 'type': 'expression_statement', 'children': ['176']}; {'id': '176', 'type': 'assignment', 'children': ['177', '178']}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '178', 'type': 'binary_operator', 'children': ['179', '180'], 'value': '+'}, {'id': '179', 'type': 'string', 'children': [], 'value': "'./'"}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '181', 'type': 'expression_statement', 'children': ['182']}; {'id': '182', 'type': 'assignment', 'children': ['183', '184']}, {'id': '183', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '184', 'type': 'call', 'children': ['185', '191']}, {'id': '185', 'type': 'attribute', 'children': ['186', '190']}; {'id': '186', 'type': 'call', 'children': ['187', '188']}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'dirEntry'}; {'id': '188', 'type': 'argument_list', 'children': ['189']}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'disambiguate'}, {'id': '191', 'type': 'argument_list', 'children': []}; {'id': '192', 'type': 'expression_statement', 'children': ['193']}, {'id': '193', 'type': 'assignment', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '195', 'type': 'call', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'selfEntry'}, {'id': '197', 'type': 'argument_list', 'children': ['198']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '199', 'type': 'if_statement', 'children': ['200', '207']}; {'id': '200', 'type': 'comparison_operator', 'children': ['201', '204'], 'value': '!='}, {'id': '201', 'type': 'attribute', 'children': ['202', '203']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '203', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '204', 'type': 'attribute', 'children': ['205', '206']}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '206', 'type': 'identifier', 'children': [], 'value': '__class__'}, {'id': '207', 'type': 'block', 'children': ['208', '216']}; {'id': '208', 'type': 'expression_statement', 'children': ['209']}, {'id': '209', 'type': 'assignment', 'children': ['210', '213']}; {'id': '210', 'type': 'attribute', 'children': ['211', '212']}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '212', 'type': 'identifier', 'children': [], 'value': '__class__'}, {'id': '213', 'type': 'attribute', 'children': ['214', '215']}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '215', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '216', 'type': 'expression_statement', 'children': ['217']}, {'id': '217', 'type': 'call', 'children': ['218', '221']}; {'id': '218', 'type': 'attribute', 'children': ['219', '220']}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '220', 'type': 'identifier', 'children': [], 'value': '_morph'}, {'id': '221', 'type': 'argument_list', 'children': []}; {'id': '222', 'type': 'expression_statement', 'children': ['223']}, {'id': '223', 'type': 'assignment', 'children': ['224', '225']}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'names'}, {'id': '225', 'type': 'call', 'children': ['226', '227']}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'set'}, {'id': '227', 'type': 'argument_list', 'children': ['228']}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'names'}, {'id': '229', 'type': 'if_statement', 'children': ['230', '235']}; {'id': '230', 'type': 'comparison_operator', 'children': ['231', '234'], 'value': '!='}, {'id': '231', 'type': 'subscript', 'children': ['232', '233']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'pattern'}, {'id': '233', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '234', 'type': 'string', 'children': [], 'value': "'.'"}, {'id': '235', 'type': 'block', 'children': ['236']}; {'id': '236', 'type': 'expression_statement', 'children': ['237']}, {'id': '237', 'type': 'assignment', 'children': ['238', '239']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'names'}, {'id': '239', 'type': 'list_comprehension', 'children': ['240', '241', '244']}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '241', 'type': 'for_in_clause', 'children': ['242', '243']}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '244', 'type': 'if_clause', 'children': ['245']}, {'id': '245', 'type': 'comparison_operator', 'children': ['246', '249'], 'value': '!='}; {'id': '246', 'type': 'subscript', 'children': ['247', '248']}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '248', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '249', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '250', 'type': 'expression_statement', 'children': ['251']}, {'id': '251', 'type': 'assignment', 'children': ['252', '253']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'names'}, {'id': '253', 'type': 'call', 'children': ['254', '257']}; {'id': '254', 'type': 'attribute', 'children': ['255', '256']}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'fnmatch'}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'filter'}, {'id': '257', 'type': 'argument_list', 'children': ['258', '259']}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'names'}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '260', 'type': 'if_statement', 'children': ['261', '262']}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'strings'}; {'id': '262', 'type': 'block', 'children': ['263']}, {'id': '263', 'type': 'return_statement', 'children': ['264']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'names'}, {'id': '265', 'type': 'return_statement', 'children': ['266']}; {'id': '266', 'type': 'list_comprehension', 'children': ['267', '275']}, {'id': '267', 'type': 'subscript', 'children': ['268', '271']}; {'id': '268', 'type': 'attribute', 'children': ['269', '270']}, {'id': '269', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'entries'}, {'id': '271', 'type': 'call', 'children': ['272', '273']}; {'id': '272', 'type': 'identifier', 'children': [], 'value': '_my_normcase'}, {'id': '273', 'type': 'argument_list', 'children': ['274']}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '275', 'type': 'for_in_clause', 'children': ['276', '277']}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'n'}, {'id': '277', 'type': 'identifier', 'children': [], 'value': 'names'}
def _glob1(self, pattern, ondisk=True, source=False, strings=False): search_dir_list = self.get_all_rdirs() for srcdir in self.srcdir_list(): search_dir_list.extend(srcdir.get_all_rdirs()) selfEntry = self.Entry names = [] for dir in search_dir_list: node_names = [ v.name for k, v in dir.entries.items() if k not in ('.', '..') ] names.extend(node_names) if not strings: for name in node_names: selfEntry(name) if ondisk: try: disk_names = os.listdir(dir._abspath) except os.error: continue names.extend(disk_names) if not strings: if pattern[0] != '.': disk_names = [x for x in disk_names if x[0] != '.'] disk_names = fnmatch.filter(disk_names, pattern) dirEntry = dir.Entry for name in disk_names: name = './' + name node = dirEntry(name).disambiguate() n = selfEntry(name) if n.__class__ != node.__class__: n.__class__ = node.__class__ n._morph() names = set(names) if pattern[0] != '.': names = [x for x in names if x[0] != '.'] names = fnmatch.filter(names, pattern) if strings: return names return [self.entries[_my_normcase(n)] for n in names]
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'release_target_info'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6', '19']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '17']}, {'id': '7', 'type': 'parenthesized_expression', 'children': ['8']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '12'], 'value': 'or'}, {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'released_target_info'}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}, {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'Node'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'interactive'}, {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'return_statement', 'children': []}, {'id': '19', 'type': 'if_statement', 'children': ['20', '28']}; {'id': '20', 'type': 'not_operator', 'children': ['21']}, {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'hasattr'}, {'id': '23', 'type': 'argument_list', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'attributes'}, {'id': '27', 'type': 'string', 'children': [], 'value': "'keep_targetinfo'"}; {'id': '28', 'type': 'block', 'children': ['29', '38', '44', '50', '56', '66', '72', '87', '102', '117', '132', '147']}, {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}, {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'changed'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}, {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'allowcache'}, {'id': '37', 'type': 'True', 'children': []}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}, {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'get_contents_sig'}, {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}, {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'get_build_env'}, {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}, {'id': '51', 'type': 'assignment', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'executor'}, {'id': '55', 'type': 'None', 'children': []}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}, {'id': '57', 'type': 'call', 'children': ['58', '63']}; {'id': '58', 'type': 'attribute', 'children': ['59', '62']}, {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '61', 'type': 'identifier', 'children': [], 'value': '_memo'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'pop'}, {'id': '63', 'type': 'argument_list', 'children': ['64', '65']}; {'id': '64', 'type': 'string', 'children': [], 'value': "'rfile'"}, {'id': '65', 'type': 'None', 'children': []}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}, {'id': '67', 'type': 'assignment', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'prerequisites'}, {'id': '71', 'type': 'None', 'children': []}; {'id': '72', 'type': 'if_statement', 'children': ['73', '80']}, {'id': '73', 'type': 'not_operator', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}, {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'ignore_set'}; {'id': '80', 'type': 'block', 'children': ['81']}, {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '86']}, {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'ignore_set'}; {'id': '86', 'type': 'None', 'children': []}, {'id': '87', 'type': 'if_statement', 'children': ['88', '95']}; {'id': '88', 'type': 'not_operator', 'children': ['89']}, {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'implicit_set'}, {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}, {'id': '97', 'type': 'assignment', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'implicit_set'}, {'id': '101', 'type': 'None', 'children': []}; {'id': '102', 'type': 'if_statement', 'children': ['103', '110']}, {'id': '103', 'type': 'not_operator', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}, {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'depends_set'}; {'id': '110', 'type': 'block', 'children': ['111']}, {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'assignment', 'children': ['113', '116']}, {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'depends_set'}; {'id': '116', 'type': 'None', 'children': []}, {'id': '117', 'type': 'if_statement', 'children': ['118', '125']}; {'id': '118', 'type': 'not_operator', 'children': ['119']}, {'id': '119', 'type': 'call', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '121', 'type': 'argument_list', 'children': ['122']}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'ignore'}, {'id': '125', 'type': 'block', 'children': ['126']}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}, {'id': '127', 'type': 'assignment', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'ignore'}, {'id': '131', 'type': 'None', 'children': []}; {'id': '132', 'type': 'if_statement', 'children': ['133', '140']}, {'id': '133', 'type': 'not_operator', 'children': ['134']}; {'id': '134', 'type': 'call', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}, {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'depends'}; {'id': '140', 'type': 'block', 'children': ['141']}, {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'assignment', 'children': ['143', '146']}, {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'depends'}; {'id': '146', 'type': 'None', 'children': []}, {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'assignment', 'children': ['149', '152']}, {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'released_target_info'}
def release_target_info(self): if (self.released_target_info or SCons.Node.interactive): return if not hasattr(self.attributes, 'keep_targetinfo'): self.changed(allowcache=True) self.get_contents_sig() self.get_build_env() self.executor = None self._memo.pop('rfile', None) self.prerequisites = None if not len(self.ignore_set): self.ignore_set = None if not len(self.implicit_set): self.implicit_set = None if not len(self.depends_set): self.depends_set = None if not len(self.ignore): self.ignore = None if not len(self.depends): self.depends = None self.released_target_info = True
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_file'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'paths'}, {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'verbose'}, {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '21', '58', '104', '117', '142', '146', '193', '199']}, {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'memo_key'}; {'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': '_find_file_key'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'paths'}, {'id': '21', 'type': 'try_statement', 'children': ['22', '31', '46']}; {'id': '22', 'type': 'block', 'children': ['23']}, {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'memo_dict'}; {'id': '26', 'type': 'subscript', 'children': ['27', '30']}, {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '29', 'type': 'identifier', 'children': [], 'value': '_memo'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'find_file'"}, {'id': '31', 'type': 'except_clause', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'KeyError'}, {'id': '33', 'type': 'block', 'children': ['34', '38']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}, {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'memo_dict'}, {'id': '37', 'type': 'dictionary', 'children': []}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}, {'id': '39', 'type': 'assignment', 'children': ['40', '45']}; {'id': '40', 'type': 'subscript', 'children': ['41', '44']}, {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '43', 'type': 'identifier', 'children': [], 'value': '_memo'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'find_file'"}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'memo_dict'}; {'id': '46', 'type': 'else_clause', 'children': ['47']}, {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'try_statement', 'children': ['49', '54']}, {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'return_statement', 'children': ['51']}, {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'memo_dict'}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'memo_key'}; {'id': '54', 'type': 'except_clause', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '56', 'type': 'block', 'children': ['57']}, {'id': '57', 'type': 'pass_statement', 'children': []}; {'id': '58', 'type': 'if_statement', 'children': ['59', '66']}, {'id': '59', 'type': 'boolean_operator', 'children': ['60', '61'], 'value': 'and'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'verbose'}, {'id': '61', 'type': 'not_operator', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'callable'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '66', 'type': 'block', 'children': ['67', '82', '88']}, {'id': '67', 'type': 'if_statement', 'children': ['68', '77']}; {'id': '68', 'type': 'not_operator', 'children': ['69']}, {'id': '69', 'type': 'call', 'children': ['70', '75']}; {'id': '70', 'type': 'attribute', 'children': ['71', '74']}, {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'is_String'}, {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'verbose'}, {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}, {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'verbose'}, {'id': '81', 'type': 'string', 'children': [], 'value': '"find_file"'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}, {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': '_verbose'}, {'id': '85', 'type': 'binary_operator', 'children': ['86', '87'], 'value': '%'}; {'id': '86', 'type': 'string', 'children': [], 'value': "u' %s: '"}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}, {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'verbose'}, {'id': '91', 'type': 'lambda', 'children': ['92', '94']}; {'id': '92', 'type': 'lambda_parameters', 'children': ['93']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '94', 'type': 'call', 'children': ['95', '100']}, {'id': '95', 'type': 'attribute', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'stdout'}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '100', 'type': 'argument_list', 'children': ['101']}, {'id': '101', 'type': 'binary_operator', 'children': ['102', '103'], 'value': '+'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': '_verbose'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}, {'id': '105', 'type': 'assignment', 'children': ['106', '109']}; {'id': '106', 'type': 'pattern_list', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'filedir'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'filename'}, {'id': '109', 'type': 'call', 'children': ['110', '115']}; {'id': '110', 'type': 'attribute', 'children': ['111', '114']}, {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'split'}, {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'filename'}, {'id': '117', 'type': 'if_statement', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'filedir'}, {'id': '119', 'type': 'block', 'children': ['120', '126']}; {'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': 'default_filedir'}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'filedir'}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}, {'id': '127', 'type': 'assignment', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'paths'}, {'id': '129', 'type': 'list_comprehension', 'children': ['130', '131', '140']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': '_f'}, {'id': '131', 'type': 'for_in_clause', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': '_f'}, {'id': '133', 'type': 'call', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'map'}, {'id': '135', 'type': 'argument_list', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'filedir_lookup'}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '140', 'type': 'if_clause', 'children': ['141']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': '_f'}; {'id': '142', 'type': 'expression_statement', 'children': ['143']}, {'id': '143', 'type': 'assignment', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '145', 'type': 'None', 'children': []}; {'id': '146', 'type': 'for_statement', 'children': ['147', '148', '149']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'paths'}, {'id': '149', 'type': 'block', 'children': ['150', '162', '173']}; {'id': '150', 'type': 'if_statement', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '152', 'type': 'block', 'children': ['153']}, {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'call', 'children': ['155', '156']}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}, {'id': '157', 'type': 'binary_operator', 'children': ['158', '159'], 'value': '%'}; {'id': '158', 'type': 'string', 'children': [], 'value': '"looking for \'%s\' in \'%s\' ...\\n"'}, {'id': '159', 'type': 'tuple', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'filename'}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '162', 'type': 'expression_statement', 'children': ['163']}, {'id': '163', 'type': 'assignment', 'children': ['164', '167']}; {'id': '164', 'type': 'pattern_list', 'children': ['165', '166']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'd'}, {'id': '167', 'type': 'call', 'children': ['168', '171']}; {'id': '168', 'type': 'attribute', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'srcdir_find_file'}, {'id': '171', 'type': 'argument_list', 'children': ['172']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'filename'}, {'id': '173', 'type': 'if_statement', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '175', 'type': 'block', 'children': ['176', '188', '192']}; {'id': '176', 'type': 'if_statement', 'children': ['177', '178']}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '178', 'type': 'block', 'children': ['179']}, {'id': '179', 'type': 'expression_statement', 'children': ['180']}; {'id': '180', 'type': 'call', 'children': ['181', '182']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '182', 'type': 'argument_list', 'children': ['183']}, {'id': '183', 'type': 'binary_operator', 'children': ['184', '185'], 'value': '%'}; {'id': '184', 'type': 'string', 'children': [], 'value': '"... FOUND \'%s\' in \'%s\'\\n"'}, {'id': '185', 'type': 'tuple', 'children': ['186', '187']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'filename'}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '188', 'type': 'expression_statement', 'children': ['189']}, {'id': '189', 'type': 'assignment', 'children': ['190', '191']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '192', 'type': 'break_statement', 'children': []}, {'id': '193', 'type': 'expression_statement', 'children': ['194']}; {'id': '194', 'type': 'assignment', 'children': ['195', '198']}, {'id': '195', 'type': 'subscript', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'memo_dict'}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'memo_key'}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '199', 'type': 'return_statement', 'children': ['200']}
def find_file(self, filename, paths, verbose=None): memo_key = self._find_file_key(filename, paths) try: memo_dict = self._memo['find_file'] except KeyError: memo_dict = {} self._memo['find_file'] = memo_dict else: try: return memo_dict[memo_key] except KeyError: pass if verbose and not callable(verbose): if not SCons.Util.is_String(verbose): verbose = "find_file" _verbose = u' %s: ' % verbose verbose = lambda s: sys.stdout.write(_verbose + s) filedir, filename = os.path.split(filename) if filedir: self.default_filedir = filedir paths = [_f for _f in map(self.filedir_lookup, paths) if _f] result = None for dir in paths: if verbose: verbose("looking for '%s' in '%s' ...\n" % (filename, dir)) node, d = dir.srcdir_find_file(filename) if node: if verbose: verbose("... FOUND '%s' in '%s'\n" % (filename, d)) result = node break memo_dict[memo_key] = result return result
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_report'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'device_id'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'max_size'}; {'id': '8', 'type': 'None', 'children': []}, {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'device_uptime'}, {'id': '11', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'report_id'}; {'id': '14', 'type': 'None', 'children': []}, {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'auth_chain'}, {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19', '37', '53', '69', '262']}, {'id': '19', 'type': 'if_statement', 'children': ['20', '31']}; {'id': '20', 'type': 'boolean_operator', 'children': ['21', '26'], 'value': 'or'}, {'id': '21', 'type': 'comparison_operator', 'children': ['22', '25'], 'value': 'is'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'walker'}, {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '30'], 'value': 'is'}, {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '30', 'type': 'None', 'children': []}, {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'raise_statement', 'children': ['33']}, {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'InternalError'}, {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': '"You can only build a report with a DataStreamer if you create it with a SensorLog and a streamer index"'}, {'id': '37', 'type': 'if_statement', 'children': ['38', '47']}; {'id': '38', 'type': 'boolean_operator', 'children': ['39', '44'], 'value': 'and'}, {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'requires_signing'}, {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '46'], 'value': 'is'}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'auth_chain'}; {'id': '46', 'type': 'None', 'children': []}, {'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': 'ArgumentError'}, {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'string', 'children': [], 'value': '"You must pass an auth chain to sign this report."'}, {'id': '53', 'type': 'if_statement', 'children': ['54', '63']}; {'id': '54', 'type': 'boolean_operator', 'children': ['55', '60'], 'value': 'and'}, {'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': 'requires_id'}, {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '62'], 'value': 'is'}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'report_id'}; {'id': '62', 'type': 'None', 'children': []}, {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'raise_statement', 'children': ['65']}, {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}, {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'string', 'children': [], 'value': '"You must pass a report_id to serialize this report"'}, {'id': '69', 'type': 'if_statement', 'children': ['70', '75', '135']}; {'id': '70', 'type': 'comparison_operator', 'children': ['71', '74'], 'value': '=='}, {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '74', 'type': 'string', 'children': [], 'value': "'individual'"}, {'id': '75', 'type': 'block', 'children': ['76', '86', '92']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}, {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'reading'}, {'id': '79', 'type': 'call', 'children': ['80', '85']}; {'id': '80', 'type': 'attribute', 'children': ['81', '84']}, {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'walker'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'pop'}, {'id': '85', 'type': 'argument_list', 'children': []}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}, {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'highest_id'}, {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'reading'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'reading_id'}; {'id': '92', 'type': 'if_statement', 'children': ['93', '98', '113']}, {'id': '93', 'type': 'comparison_operator', 'children': ['94', '97'], 'value': '=='}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'report_type'}, {'id': '97', 'type': 'string', 'children': [], 'value': "'telegram'"}; {'id': '98', 'type': 'block', 'children': ['99']}, {'id': '99', 'type': 'return_statement', 'children': ['100']}; {'id': '100', 'type': 'call', 'children': ['101', '102']}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'StreamerReport'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '111', '112']}, {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'IndividualReadingReport'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'FromReadings'}, {'id': '107', 'type': 'argument_list', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'device_id'}, {'id': '109', 'type': 'list', 'children': ['110'], 'value': '[reading]'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'reading'}, {'id': '111', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'highest_id'}, {'id': '113', 'type': 'elif_clause', 'children': ['114', '119']}; {'id': '114', 'type': 'comparison_operator', 'children': ['115', '118'], 'value': '=='}, {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'report_type'}; {'id': '118', 'type': 'string', 'children': [], 'value': "'broadcast'"}, {'id': '119', 'type': 'block', 'children': ['120']}; {'id': '120', 'type': 'return_statement', 'children': ['121']}, {'id': '121', 'type': 'call', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'StreamerReport'}, {'id': '123', 'type': 'argument_list', 'children': ['124', '133', '134']}; {'id': '124', 'type': 'call', 'children': ['125', '128']}, {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'BroadcastReport'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'FromReadings'}; {'id': '128', 'type': 'argument_list', 'children': ['129', '130', '132']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'device_id'}; {'id': '130', 'type': 'list', 'children': ['131'], 'value': '[reading]'}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'reading'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'device_uptime'}, {'id': '133', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'highest_id'}, {'id': '135', 'type': 'elif_clause', 'children': ['136', '141']}; {'id': '136', 'type': 'comparison_operator', 'children': ['137', '140'], 'value': '=='}, {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '140', 'type': 'string', 'children': [], 'value': "'hashedlist'"}, {'id': '141', 'type': 'block', 'children': ['142', '153', '166', '170', '174', '226']}; {'id': '142', 'type': 'expression_statement', 'children': ['143']}, {'id': '143', 'type': 'assignment', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'max_readings'}, {'id': '145', 'type': 'binary_operator', 'children': ['146', '152'], 'value': '//'}; {'id': '146', 'type': 'parenthesized_expression', 'children': ['147']}, {'id': '147', 'type': 'binary_operator', 'children': ['148', '151'], 'value': '-'}; {'id': '148', 'type': 'binary_operator', 'children': ['149', '150'], 'value': '-'}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'max_size'}; {'id': '150', 'type': 'integer', 'children': [], 'value': '20'}, {'id': '151', 'type': 'integer', 'children': [], 'value': '24'}; {'id': '152', 'type': 'integer', 'children': [], 'value': '16'}, {'id': '153', 'type': 'if_statement', 'children': ['154', '157']}; {'id': '154', 'type': 'comparison_operator', 'children': ['155', '156'], 'value': '<='}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 'max_readings'}; {'id': '156', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '157', 'type': 'block', 'children': ['158']}; {'id': '158', 'type': 'raise_statement', 'children': ['159']}, {'id': '159', 'type': 'call', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'InternalError'}, {'id': '161', 'type': 'argument_list', 'children': ['162', '163']}; {'id': '162', 'type': 'string', 'children': [], 'value': '"max_size is too small to hold even a single reading"'}, {'id': '163', 'type': 'keyword_argument', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'max_size'}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'max_size'}; {'id': '166', 'type': 'expression_statement', 'children': ['167']}, {'id': '167', 'type': 'assignment', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'readings'}, {'id': '169', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '170', 'type': 'expression_statement', 'children': ['171']}, {'id': '171', 'type': 'assignment', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'highest_id'}, {'id': '173', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '174', 'type': 'try_statement', 'children': ['175', '214']}, {'id': '175', 'type': 'block', 'children': ['176']}; {'id': '176', 'type': 'while_statement', 'children': ['177', '183']}, {'id': '177', 'type': 'comparison_operator', 'children': ['178', '182'], 'value': '<'}; {'id': '178', 'type': 'call', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '180', 'type': 'argument_list', 'children': ['181']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'readings'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'max_readings'}, {'id': '183', 'type': 'block', 'children': ['184', '194', '201']}; {'id': '184', 'type': 'expression_statement', 'children': ['185']}, {'id': '185', 'type': 'assignment', 'children': ['186', '187']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'reading'}, {'id': '187', 'type': 'call', 'children': ['188', '193']}; {'id': '188', 'type': 'attribute', 'children': ['189', '192']}, {'id': '189', 'type': 'attribute', 'children': ['190', '191']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'walker'}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'pop'}, {'id': '193', 'type': 'argument_list', 'children': []}; {'id': '194', 'type': 'expression_statement', 'children': ['195']}, {'id': '195', 'type': 'call', 'children': ['196', '199']}; {'id': '196', 'type': 'attribute', 'children': ['197', '198']}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'readings'}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '199', 'type': 'argument_list', 'children': ['200']}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'reading'}, {'id': '201', 'type': 'if_statement', 'children': ['202', '207']}; {'id': '202', 'type': 'comparison_operator', 'children': ['203', '206'], 'value': '>'}, {'id': '203', 'type': 'attribute', 'children': ['204', '205']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'reading'}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'reading_id'}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'highest_id'}, {'id': '207', 'type': 'block', 'children': ['208']}; {'id': '208', 'type': 'expression_statement', 'children': ['209']}, {'id': '209', 'type': 'assignment', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'highest_id'}, {'id': '211', 'type': 'attribute', 'children': ['212', '213']}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'reading'}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'reading_id'}; {'id': '214', 'type': 'except_clause', 'children': ['215', '216']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'StreamEmptyError'}; {'id': '216', 'type': 'block', 'children': ['217']}, {'id': '217', 'type': 'if_statement', 'children': ['218', '224']}; {'id': '218', 'type': 'comparison_operator', 'children': ['219', '223'], 'value': '=='}, {'id': '219', 'type': 'call', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '221', 'type': 'argument_list', 'children': ['222']}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'readings'}, {'id': '223', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '224', 'type': 'block', 'children': ['225']}, {'id': '225', 'type': 'raise_statement', 'children': []}; {'id': '226', 'type': 'return_statement', 'children': ['227']}, {'id': '227', 'type': 'call', 'children': ['228', '229']}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'StreamerReport'}, {'id': '229', 'type': 'argument_list', 'children': ['230', '257', '261']}; {'id': '230', 'type': 'call', 'children': ['231', '234']}, {'id': '231', 'type': 'attribute', 'children': ['232', '233']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'SignedListReport'}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'FromReadings'}; {'id': '234', 'type': 'argument_list', 'children': ['235', '236', '237', '240', '249', '254']}, {'id': '235', 'type': 'identifier', 'children': [], 'value': 'device_id'}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'readings'}, {'id': '237', 'type': 'keyword_argument', 'children': ['238', '239']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'report_id'}, {'id': '239', 'type': 'identifier', 'children': [], 'value': 'report_id'}; {'id': '240', 'type': 'keyword_argument', 'children': ['241', '242']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '242', 'type': 'call', 'children': ['243', '248']}, {'id': '243', 'type': 'attribute', 'children': ['244', '247']}; {'id': '244', 'type': 'attribute', 'children': ['245', '246']}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'selector'}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '248', 'type': 'argument_list', 'children': []}, {'id': '249', 'type': 'keyword_argument', 'children': ['250', '251']}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'streamer'}, {'id': '251', 'type': 'attribute', 'children': ['252', '253']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '253', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '254', 'type': 'keyword_argument', 'children': ['255', '256']}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'sent_timestamp'}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'device_uptime'}, {'id': '257', 'type': 'call', 'children': ['258', '259']}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'len'}, {'id': '259', 'type': 'argument_list', 'children': ['260']}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'readings'}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'highest_id'}; {'id': '262', 'type': 'raise_statement', 'children': ['263']}, {'id': '263', 'type': 'call', 'children': ['264', '265']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'InternalError'}, {'id': '265', 'type': 'argument_list', 'children': ['266', '267', '272']}; {'id': '266', 'type': 'string', 'children': [], 'value': '"Streamer report format or type is not supported currently"'}, {'id': '267', 'type': 'keyword_argument', 'children': ['268', '269']}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'report_format'}, {'id': '269', 'type': 'attribute', 'children': ['270', '271']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '271', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '272', 'type': 'keyword_argument', 'children': ['273', '274']}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'report_type'}; {'id': '274', 'type': 'attribute', 'children': ['275', '276']}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 'self'}
def build_report(self, device_id, max_size=None, device_uptime=0, report_id=None, auth_chain=None): if self.walker is None or self.index is None: raise InternalError("You can only build a report with a DataStreamer if you create it with a SensorLog and a streamer index") if self.requires_signing() and auth_chain is None: raise ArgumentError("You must pass an auth chain to sign this report.") if self.requires_id() and report_id is None: raise ArgumentError("You must pass a report_id to serialize this report") if self.format == 'individual': reading = self.walker.pop() highest_id = reading.reading_id if self.report_type == 'telegram': return StreamerReport(IndividualReadingReport.FromReadings(device_id, [reading]), 1, highest_id) elif self.report_type == 'broadcast': return StreamerReport(BroadcastReport.FromReadings(device_id, [reading], device_uptime), 1, highest_id) elif self.format == 'hashedlist': max_readings = (max_size - 20 - 24) // 16 if max_readings <= 0: raise InternalError("max_size is too small to hold even a single reading", max_size=max_size) readings = [] highest_id = 0 try: while len(readings) < max_readings: reading = self.walker.pop() readings.append(reading) if reading.reading_id > highest_id: highest_id = reading.reading_id except StreamEmptyError: if len(readings) == 0: raise return StreamerReport(SignedListReport.FromReadings(device_id, readings, report_id=report_id, selector=self.selector.encode(), streamer=self.index, sent_timestamp=device_uptime), len(readings), highest_id) raise InternalError("Streamer report format or type is not supported currently", report_format=self.format, report_type=self.report_type)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scan'}, {'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': 'wait'}, {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '21', '33', '37', '47', '58', '80', '89', '99', '105', '111', '175']}, {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'min_scan'}; {'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': 'adapter'}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'get_config'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}, {'id': '19', 'type': 'string', 'children': [], 'value': "'minimum_scan_time'"}; {'id': '20', 'type': 'float', 'children': [], 'value': '0.0'}, {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'probe_required'}; {'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': 'adapter'}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'get_config'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}, {'id': '31', 'type': 'string', 'children': [], 'value': "'probe_required'"}; {'id': '32', 'type': 'False', 'children': []}, {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'wait_time'}; {'id': '36', 'type': 'None', 'children': []}, {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'elapsed'}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '44'], 'value': '-'}, {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'monotonic'}, {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_start_time'}, {'id': '47', 'type': 'if_statement', 'children': ['48', '51']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': '<'}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'elapsed'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'min_scan'}, {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}, {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'wait_time'}, {'id': '55', 'type': 'binary_operator', 'children': ['56', '57'], 'value': '-'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'min_scan'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'elapsed'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'probe_required'}; {'id': '60', 'type': 'block', 'children': ['61', '76']}, {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '68']}, {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '_loop'}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'run_coroutine'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}, {'id': '69', 'type': 'call', 'children': ['70', '75']}; {'id': '70', 'type': 'attribute', 'children': ['71', '74']}, {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'adapter'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'probe'}, {'id': '75', 'type': 'argument_list', 'children': []}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}, {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'wait_time'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'min_scan'}; {'id': '80', 'type': 'if_statement', 'children': ['81', '84']}, {'id': '81', 'type': 'comparison_operator', 'children': ['82', '83'], 'value': 'is'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'wait'}, {'id': '83', 'type': 'None', 'children': []}; {'id': '84', 'type': 'block', 'children': ['85']}, {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'wait_time'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'wait'}, {'id': '89', 'type': 'if_statement', 'children': ['90', '93']}; {'id': '90', 'type': 'comparison_operator', 'children': ['91', '92'], 'value': 'is'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'wait_time'}; {'id': '92', 'type': 'None', 'children': []}, {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}, {'id': '95', 'type': 'call', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'sleep'}, {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'wait_time'}, {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '102']}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'to_remove'}; {'id': '102', 'type': 'call', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '104', 'type': 'argument_list', 'children': []}, {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '108', 'type': 'call', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'monotonic'}; {'id': '110', 'type': 'argument_list', 'children': []}, {'id': '111', 'type': 'with_statement', 'children': ['112', '117']}; {'id': '112', 'type': 'with_clause', 'children': ['113']}, {'id': '113', 'type': 'with_item', 'children': ['114']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': '_scan_lock'}, {'id': '117', 'type': 'block', 'children': ['118', '144', '154']}; {'id': '118', 'type': 'for_statement', 'children': ['119', '122', '129']}, {'id': '119', 'type': 'pattern_list', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '122', 'type': 'call', 'children': ['123', '128']}, {'id': '123', 'type': 'attribute', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': '_scanned_devices'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '128', 'type': 'argument_list', 'children': []}, {'id': '129', 'type': 'block', 'children': ['130']}; {'id': '130', 'type': 'if_statement', 'children': ['131', '136']}, {'id': '131', 'type': 'comparison_operator', 'children': ['132', '135'], 'value': '<'}; {'id': '132', 'type': 'subscript', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '134', 'type': 'string', 'children': [], 'value': "'expiration_time'"}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '136', 'type': 'block', 'children': ['137']}, {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '142']}, {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'to_remove'}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '144', 'type': 'for_statement', 'children': ['145', '146', '147']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'to_remove'}, {'id': '147', 'type': 'block', 'children': ['148']}; {'id': '148', 'type': 'delete_statement', 'children': ['149']}, {'id': '149', 'type': 'subscript', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': '_scanned_devices'}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '154', 'type': 'expression_statement', 'children': ['155']}, {'id': '155', 'type': 'assignment', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'devices'}, {'id': '157', 'type': 'call', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'sorted'}, {'id': '159', 'type': 'argument_list', 'children': ['160', '167']}; {'id': '160', 'type': 'call', 'children': ['161', '166']}, {'id': '161', 'type': 'attribute', 'children': ['162', '165']}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': '_scanned_devices'}, {'id': '165', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '166', 'type': 'argument_list', 'children': []}, {'id': '167', 'type': 'keyword_argument', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'key'}, {'id': '169', 'type': 'lambda', 'children': ['170', '172']}; {'id': '170', 'type': 'lambda_parameters', 'children': ['171']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '172', 'type': 'subscript', 'children': ['173', '174']}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '174', 'type': 'string', 'children': [], 'value': "'uuid'"}, {'id': '175', 'type': 'return_statement', 'children': ['176']}
def scan(self, wait=None): min_scan = self.adapter.get_config('minimum_scan_time', 0.0) probe_required = self.adapter.get_config('probe_required', False) wait_time = None elapsed = monotonic() - self._start_time if elapsed < min_scan: wait_time = min_scan - elapsed if probe_required: self._loop.run_coroutine(self.adapter.probe()) wait_time = min_scan if wait is not None: wait_time = wait if wait_time is not None: sleep(wait_time) to_remove = set() now = monotonic() with self._scan_lock: for name, value in self._scanned_devices.items(): if value['expiration_time'] < now: to_remove.add(name) for name in to_remove: del self._scanned_devices[name] devices = sorted(self._scanned_devices.values(), key=lambda x: x['uuid']) return devices
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_rpc'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'rpc_id'}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'call_payload'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '10', 'type': 'float', 'children': [], 'value': '3.0'}, {'id': '11', 'type': 'block', 'children': ['12', '23', '32', '37', '41', '45', '56', '81', '131', '155', '166']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '17']}, {'id': '13', 'type': 'not_operator', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'connected'}, {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'raise_statement', 'children': ['19']}, {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'HardwareError'}, {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"Cannot send an RPC if we are not in a connected state"'}, {'id': '23', 'type': 'if_statement', 'children': ['24', '27']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': 'is'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '26', 'type': 'None', 'children': []}, {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}, {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'timeout'}, {'id': '31', 'type': 'float', 'children': [], 'value': '3.0'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}, {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'status'}, {'id': '35', 'type': 'unary_operator', 'children': ['36'], 'value': '-'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '40', 'type': 'string', 'children': [], 'value': "b''"}, {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'recording'}; {'id': '44', 'type': 'None', 'children': []}, {'id': '45', 'type': 'if_statement', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'connection_interrupted'}, {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}, {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_try_reconnect'}, {'id': '55', 'type': 'argument_list', 'children': []}; {'id': '56', 'type': 'if_statement', 'children': ['57', '62']}, {'id': '57', 'type': 'comparison_operator', 'children': ['58', '61'], 'value': 'is'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '_record'}, {'id': '61', 'type': 'None', 'children': []}; {'id': '62', 'type': 'block', 'children': ['63', '75']}, {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'recording'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': '_RecordedRPC'}; {'id': '68', 'type': 'argument_list', 'children': ['69', '72', '73', '74']}, {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'connection_string'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'address'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'rpc_id'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'call_payload'}, {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}, {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'recording'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '80', 'type': 'argument_list', 'children': []}, {'id': '81', 'type': 'try_statement', 'children': ['82', '115']}; {'id': '82', 'type': 'block', 'children': ['83', '105']}, {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '86', 'type': 'call', 'children': ['87', '92']}, {'id': '87', 'type': 'attribute', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': '_loop'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'run_coroutine'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}, {'id': '93', 'type': 'call', 'children': ['94', '99']}; {'id': '94', 'type': 'attribute', 'children': ['95', '98']}, {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'adapter'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'send_rpc'}, {'id': '99', 'type': 'argument_list', 'children': ['100', '101', '102', '103', '104']}; {'id': '100', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'rpc_id'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'call_payload'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'timeout'}, {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '110']}, {'id': '107', 'type': 'pattern_list', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'status'}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '110', 'type': 'call', 'children': ['111', '112']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'pack_rpc_response'}; {'id': '112', 'type': 'argument_list', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '114', 'type': 'None', 'children': []}, {'id': '115', 'type': 'except_clause', 'children': ['116', '120']}; {'id': '116', 'type': 'as_pattern', 'children': ['117', '118']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'VALID_RPC_EXCEPTIONS'}; {'id': '118', 'type': 'as_pattern_target', 'children': ['119']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '120', 'type': 'block', 'children': ['121']}, {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'assignment', 'children': ['123', '126']}, {'id': '123', 'type': 'pattern_list', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'status'}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '126', 'type': 'call', 'children': ['127', '128']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'pack_rpc_response'}; {'id': '128', 'type': 'argument_list', 'children': ['129', '130']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'exc'}, {'id': '131', 'type': 'if_statement', 'children': ['132', '137']}; {'id': '132', 'type': 'comparison_operator', 'children': ['133', '136'], 'value': 'is'}, {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '135', 'type': 'identifier', 'children': [], 'value': '_record'}; {'id': '136', 'type': 'None', 'children': []}, {'id': '137', 'type': 'block', 'children': ['138', '146']}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}, {'id': '139', 'type': 'call', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'recording'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'finish'}, {'id': '143', 'type': 'argument_list', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'status'}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}, {'id': '147', 'type': 'call', 'children': ['148', '153']}; {'id': '148', 'type': 'attribute', 'children': ['149', '152']}, {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '151', 'type': 'identifier', 'children': [], 'value': '_recording'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '153', 'type': 'argument_list', 'children': ['154']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'recording'}, {'id': '155', 'type': 'if_statement', 'children': ['156', '159']}; {'id': '156', 'type': 'attribute', 'children': ['157', '158']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'connection_interrupted'}, {'id': '159', 'type': 'block', 'children': ['160']}; {'id': '160', 'type': 'expression_statement', 'children': ['161']}, {'id': '161', 'type': 'call', 'children': ['162', '165']}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': '_try_reconnect'}, {'id': '165', 'type': 'argument_list', 'children': []}; {'id': '166', 'type': 'return_statement', 'children': ['167']}, {'id': '167', 'type': 'call', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'unpack_rpc_response'}, {'id': '169', 'type': 'argument_list', 'children': ['170', '171', '172', '173']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'status'}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'rpc_id'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'address'}
def send_rpc(self, address, rpc_id, call_payload, timeout=3.0): if not self.connected: raise HardwareError("Cannot send an RPC if we are not in a connected state") if timeout is None: timeout = 3.0 status = -1 payload = b'' recording = None if self.connection_interrupted: self._try_reconnect() if self._record is not None: recording = _RecordedRPC(self.connection_string, address, rpc_id, call_payload) recording.start() try: payload = self._loop.run_coroutine(self.adapter.send_rpc(0, address, rpc_id, call_payload, timeout)) status, payload = pack_rpc_response(payload, None) except VALID_RPC_EXCEPTIONS as exc: status, payload = pack_rpc_response(payload, exc) if self._record is not None: recording.finish(status, payload) self._recording.append(recording) if self.connection_interrupted: self._try_reconnect() return unpack_rpc_response(status, payload, rpc_id, address)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__xml_scan'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '8', 'type': 'block', 'children': ['9', '25', '49', '62', '241', '250', '259', '275', '285', '289', '332', '338', '344', '350']}, {'id': '9', 'type': 'if_statement', 'children': ['10', '22']}; {'id': '10', 'type': 'not_operator', 'children': ['11']}, {'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': 'os'}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'isfile'}, {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '22', 'type': 'block', 'children': ['23']}, {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '25', 'type': 'if_statement', 'children': ['26', '33']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}, {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}, {'id': '31', 'type': 'string', 'children': [], 'value': "'DOCBOOK_SCANENT'"}; {'id': '32', 'type': 'string', 'children': [], 'value': "''"}, {'id': '33', 'type': 'block', 'children': ['34', '42']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}, {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'contents'}, {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'get_text_contents'}, {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'return_statement', 'children': ['43']}, {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'sentity_re'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'findall'}, {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'contents'}, {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'xsl_file'}; {'id': '52', 'type': 'call', 'children': ['53', '58']}, {'id': '53', 'type': 'attribute', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60', '61']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'scriptpath'}; {'id': '60', 'type': 'string', 'children': [], 'value': "'utils'"}, {'id': '61', 'type': 'string', 'children': [], 'value': "'xmldepend.xsl'"}; {'id': '62', 'type': 'if_statement', 'children': ['63', '67']}, {'id': '63', 'type': 'boolean_operator', 'children': ['64', '66'], 'value': 'or'}; {'id': '64', 'type': 'not_operator', 'children': ['65']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'has_libxml2'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'prefer_xsltproc'}, {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'if_statement', 'children': ['69', '73', '146']}, {'id': '69', 'type': 'boolean_operator', 'children': ['70', '71'], 'value': 'and'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'has_lxml'}, {'id': '71', 'type': 'not_operator', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'prefer_xsltproc'}, {'id': '73', 'type': 'block', 'children': ['74', '79', '88', '100', '109', '144']}; {'id': '74', 'type': 'import_from_statement', 'children': ['75', '77']}, {'id': '75', 'type': 'dotted_name', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'lxml'}, {'id': '77', 'type': 'dotted_name', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'etree'}, {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'xsl_tree'}; {'id': '82', 'type': 'call', 'children': ['83', '86']}, {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'etree'}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'parse'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'xsl_file'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}, {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'doc'}, {'id': '91', 'type': 'call', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'parse'}, {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}, {'id': '101', 'type': 'assignment', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'xslt'}, {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'xsl_tree'}, {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'depfiles'}; {'id': '112', 'type': 'list_comprehension', 'children': ['113', '118', '128']}, {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'strip'}, {'id': '117', 'type': 'argument_list', 'children': []}; {'id': '118', 'type': 'for_in_clause', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '120', 'type': 'call', 'children': ['121', '127']}, {'id': '121', 'type': 'attribute', 'children': ['122', '126']}; {'id': '122', 'type': 'call', 'children': ['123', '124']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'splitlines'}, {'id': '127', 'type': 'argument_list', 'children': []}; {'id': '128', 'type': 'if_clause', 'children': ['129']}, {'id': '129', 'type': 'boolean_operator', 'children': ['130', '137'], 'value': 'and'}; {'id': '130', 'type': 'comparison_operator', 'children': ['131', '136'], 'value': '!='}, {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'strip'}, {'id': '135', 'type': 'argument_list', 'children': []}; {'id': '136', 'type': 'string', 'children': [], 'value': '""'}, {'id': '137', 'type': 'not_operator', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '142']}, {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}, {'id': '143', 'type': 'string', 'children': [], 'value': '"<?xml "'}; {'id': '144', 'type': 'return_statement', 'children': ['145']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'depfiles'}; {'id': '146', 'type': 'else_clause', 'children': ['147']}, {'id': '147', 'type': 'block', 'children': ['148', '157']}; {'id': '148', 'type': 'expression_statement', 'children': ['149']}, {'id': '149', 'type': 'assignment', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'xsltproc'}, {'id': '151', 'type': 'call', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'subst'}, {'id': '155', 'type': 'argument_list', 'children': ['156']}; {'id': '156', 'type': 'string', 'children': [], 'value': '"$DOCBOOK_XSLTPROC"'}, {'id': '157', 'type': 'if_statement', 'children': ['158', '166', '224']}; {'id': '158', 'type': 'boolean_operator', 'children': ['159', '160'], 'value': 'and'}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'xsltproc'}; {'id': '160', 'type': 'call', 'children': ['161', '164']}, {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'xsltproc'}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '164', 'type': 'argument_list', 'children': ['165']}, {'id': '165', 'type': 'string', 'children': [], 'value': "'xsltproc'"}; {'id': '166', 'type': 'block', 'children': ['167', '187', '222']}, {'id': '167', 'type': 'expression_statement', 'children': ['168']}; {'id': '168', 'type': 'assignment', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '170', 'type': 'call', 'children': ['171', '174']}, {'id': '171', 'type': 'attribute', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'backtick'}; {'id': '174', 'type': 'argument_list', 'children': ['175']}, {'id': '175', 'type': 'call', 'children': ['176', '179']}; {'id': '176', 'type': 'attribute', 'children': ['177', '178']}, {'id': '177', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '179', 'type': 'argument_list', 'children': ['180']}; {'id': '180', 'type': 'list', 'children': ['181', '182', '183'], 'value': '[xsltproc, xsl_file, str(node)]'}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'xsltproc'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'xsl_file'}, {'id': '183', 'type': 'call', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '185', 'type': 'argument_list', 'children': ['186']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '187', 'type': 'expression_statement', 'children': ['188']}; {'id': '188', 'type': 'assignment', 'children': ['189', '190']}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'depfiles'}; {'id': '190', 'type': 'list_comprehension', 'children': ['191', '196', '206']}, {'id': '191', 'type': 'call', 'children': ['192', '195']}; {'id': '192', 'type': 'attribute', 'children': ['193', '194']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'strip'}, {'id': '195', 'type': 'argument_list', 'children': []}; {'id': '196', 'type': 'for_in_clause', 'children': ['197', '198']}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '198', 'type': 'call', 'children': ['199', '205']}, {'id': '199', 'type': 'attribute', 'children': ['200', '204']}; {'id': '200', 'type': 'call', 'children': ['201', '202']}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '202', 'type': 'argument_list', 'children': ['203']}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'splitlines'}, {'id': '205', 'type': 'argument_list', 'children': []}; {'id': '206', 'type': 'if_clause', 'children': ['207']}, {'id': '207', 'type': 'boolean_operator', 'children': ['208', '215'], 'value': 'and'}; {'id': '208', 'type': 'comparison_operator', 'children': ['209', '214'], 'value': '!='}, {'id': '209', 'type': 'call', 'children': ['210', '213']}; {'id': '210', 'type': 'attribute', 'children': ['211', '212']}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'strip'}, {'id': '213', 'type': 'argument_list', 'children': []}; {'id': '214', 'type': 'string', 'children': [], 'value': '""'}, {'id': '215', 'type': 'not_operator', 'children': ['216']}; {'id': '216', 'type': 'call', 'children': ['217', '220']}, {'id': '217', 'type': 'attribute', 'children': ['218', '219']}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '219', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '220', 'type': 'argument_list', 'children': ['221']}, {'id': '221', 'type': 'string', 'children': [], 'value': '"<?xml "'}; {'id': '222', 'type': 'return_statement', 'children': ['223']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'depfiles'}; {'id': '224', 'type': 'else_clause', 'children': ['225']}, {'id': '225', 'type': 'block', 'children': ['226', '234']}; {'id': '226', 'type': 'expression_statement', 'children': ['227']}, {'id': '227', 'type': 'assignment', 'children': ['228', '229']}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'contents'}, {'id': '229', 'type': 'call', 'children': ['230', '233']}; {'id': '230', 'type': 'attribute', 'children': ['231', '232']}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'get_text_contents'}, {'id': '233', 'type': 'argument_list', 'children': []}; {'id': '234', 'type': 'return_statement', 'children': ['235']}, {'id': '235', 'type': 'call', 'children': ['236', '239']}; {'id': '236', 'type': 'attribute', 'children': ['237', '238']}, {'id': '237', 'type': 'identifier', 'children': [], 'value': 'include_re'}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'findall'}, {'id': '239', 'type': 'argument_list', 'children': ['240']}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'contents'}, {'id': '241', 'type': 'expression_statement', 'children': ['242']}; {'id': '242', 'type': 'assignment', 'children': ['243', '244']}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'styledoc'}; {'id': '244', 'type': 'call', 'children': ['245', '248']}, {'id': '245', 'type': 'attribute', 'children': ['246', '247']}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'libxml2'}, {'id': '247', 'type': 'identifier', 'children': [], 'value': 'parseFile'}; {'id': '248', 'type': 'argument_list', 'children': ['249']}, {'id': '249', 'type': 'identifier', 'children': [], 'value': 'xsl_file'}; {'id': '250', 'type': 'expression_statement', 'children': ['251']}, {'id': '251', 'type': 'assignment', 'children': ['252', '253']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'style'}, {'id': '253', 'type': 'call', 'children': ['254', '257']}; {'id': '254', 'type': 'attribute', 'children': ['255', '256']}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'libxslt'}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'parseStylesheetDoc'}, {'id': '257', 'type': 'argument_list', 'children': ['258']}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'styledoc'}, {'id': '259', 'type': 'expression_statement', 'children': ['260']}; {'id': '260', 'type': 'assignment', 'children': ['261', '262']}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '262', 'type': 'call', 'children': ['263', '266']}, {'id': '263', 'type': 'attribute', 'children': ['264', '265']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'libxml2'}, {'id': '265', 'type': 'identifier', 'children': [], 'value': 'readFile'}; {'id': '266', 'type': 'argument_list', 'children': ['267', '271', '272']}, {'id': '267', 'type': 'call', 'children': ['268', '269']}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '269', 'type': 'argument_list', 'children': ['270']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '271', 'type': 'None', 'children': []}; {'id': '272', 'type': 'attribute', 'children': ['273', '274']}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'libxml2'}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'XML_PARSE_NOENT'}, {'id': '275', 'type': 'expression_statement', 'children': ['276']}; {'id': '276', 'type': 'assignment', 'children': ['277', '278']}, {'id': '277', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '278', 'type': 'call', 'children': ['279', '282']}, {'id': '279', 'type': 'attribute', 'children': ['280', '281']}; {'id': '280', 'type': 'identifier', 'children': [], 'value': 'style'}, {'id': '281', 'type': 'identifier', 'children': [], 'value': 'applyStylesheet'}; {'id': '282', 'type': 'argument_list', 'children': ['283', '284']}, {'id': '283', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '284', 'type': 'None', 'children': []}, {'id': '285', 'type': 'expression_statement', 'children': ['286']}; {'id': '286', 'type': 'assignment', 'children': ['287', '288']}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'depfiles'}; {'id': '288', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '289', 'type': 'for_statement', 'children': ['290', '291', '299']}; {'id': '290', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '291', 'type': 'call', 'children': ['292', '298']}; {'id': '292', 'type': 'attribute', 'children': ['293', '297']}, {'id': '293', 'type': 'call', 'children': ['294', '295']}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '295', 'type': 'argument_list', 'children': ['296']}; {'id': '296', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '297', 'type': 'identifier', 'children': [], 'value': 'splitlines'}; {'id': '298', 'type': 'argument_list', 'children': []}, {'id': '299', 'type': 'block', 'children': ['300']}; {'id': '300', 'type': 'if_statement', 'children': ['301', '316']}, {'id': '301', 'type': 'boolean_operator', 'children': ['302', '309'], 'value': 'and'}; {'id': '302', 'type': 'comparison_operator', 'children': ['303', '308'], 'value': '!='}, {'id': '303', 'type': 'call', 'children': ['304', '307']}; {'id': '304', 'type': 'attribute', 'children': ['305', '306']}, {'id': '305', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '306', 'type': 'identifier', 'children': [], 'value': 'strip'}, {'id': '307', 'type': 'argument_list', 'children': []}; {'id': '308', 'type': 'string', 'children': [], 'value': '""'}, {'id': '309', 'type': 'not_operator', 'children': ['310']}; {'id': '310', 'type': 'call', 'children': ['311', '314']}, {'id': '311', 'type': 'attribute', 'children': ['312', '313']}; {'id': '312', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '313', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '314', 'type': 'argument_list', 'children': ['315']}, {'id': '315', 'type': 'string', 'children': [], 'value': '"<?xml "'}; {'id': '316', 'type': 'block', 'children': ['317']}, {'id': '317', 'type': 'expression_statement', 'children': ['318']}; {'id': '318', 'type': 'call', 'children': ['319', '322']}, {'id': '319', 'type': 'attribute', 'children': ['320', '321']}; {'id': '320', 'type': 'identifier', 'children': [], 'value': 'depfiles'}, {'id': '321', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '322', 'type': 'argument_list', 'children': ['323']}, {'id': '323', 'type': 'call', 'children': ['324', '331']}; {'id': '324', 'type': 'attribute', 'children': ['325', '330']}, {'id': '325', 'type': 'call', 'children': ['326', '329']}; {'id': '326', 'type': 'attribute', 'children': ['327', '328']}, {'id': '327', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '328', 'type': 'identifier', 'children': [], 'value': 'strip'}, {'id': '329', 'type': 'argument_list', 'children': []}; {'id': '330', 'type': 'identifier', 'children': [], 'value': 'split'}, {'id': '331', 'type': 'argument_list', 'children': []}; {'id': '332', 'type': 'expression_statement', 'children': ['333']}, {'id': '333', 'type': 'call', 'children': ['334', '337']}; {'id': '334', 'type': 'attribute', 'children': ['335', '336']}, {'id': '335', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '336', 'type': 'identifier', 'children': [], 'value': 'freeStylesheet'}, {'id': '337', 'type': 'argument_list', 'children': []}; {'id': '338', 'type': 'expression_statement', 'children': ['339']}, {'id': '339', 'type': 'call', 'children': ['340', '343']}; {'id': '340', 'type': 'attribute', 'children': ['341', '342']}, {'id': '341', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '342', 'type': 'identifier', 'children': [], 'value': 'freeDoc'}, {'id': '343', 'type': 'argument_list', 'children': []}; {'id': '344', 'type': 'expression_statement', 'children': ['345']}, {'id': '345', 'type': 'call', 'children': ['346', '349']}; {'id': '346', 'type': 'attribute', 'children': ['347', '348']}, {'id': '347', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '348', 'type': 'identifier', 'children': [], 'value': 'freeDoc'}, {'id': '349', 'type': 'argument_list', 'children': []}; {'id': '350', 'type': 'return_statement', 'children': ['351']}, {'id': '351', 'type': 'identifier', 'children': [], 'value': 'depfiles'}
def __xml_scan(node, env, path, arg): if not os.path.isfile(str(node)): return [] if env.get('DOCBOOK_SCANENT',''): contents = node.get_text_contents() return sentity_re.findall(contents) xsl_file = os.path.join(scriptpath,'utils','xmldepend.xsl') if not has_libxml2 or prefer_xsltproc: if has_lxml and not prefer_xsltproc: from lxml import etree xsl_tree = etree.parse(xsl_file) doc = etree.parse(str(node)) result = doc.xslt(xsl_tree) depfiles = [x.strip() for x in str(result).splitlines() if x.strip() != "" and not x.startswith("<?xml ")] return depfiles else: xsltproc = env.subst("$DOCBOOK_XSLTPROC") if xsltproc and xsltproc.endswith('xsltproc'): result = env.backtick(' '.join([xsltproc, xsl_file, str(node)])) depfiles = [x.strip() for x in str(result).splitlines() if x.strip() != "" and not x.startswith("<?xml ")] return depfiles else: contents = node.get_text_contents() return include_re.findall(contents) styledoc = libxml2.parseFile(xsl_file) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.readFile(str(node), None, libxml2.XML_PARSE_NOENT) result = style.applyStylesheet(doc, None) depfiles = [] for x in str(result).splitlines(): if x.strip() != "" and not x.startswith("<?xml "): depfiles.extend(x.strip().split()) style.freeStylesheet() doc.freeDoc() result.freeDoc() return depfiles
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'DocbookMan'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '8', 'type': 'None', 'children': []}, {'id': '9', 'type': 'list_splat_pattern', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '11', 'type': 'dictionary_splat_pattern', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '13', 'type': 'block', 'children': ['14', '24', '34', '43', '47', '366']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}, {'id': '15', 'type': 'assignment', 'children': ['16', '19']}; {'id': '16', 'type': 'pattern_list', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'source'}, {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '__extend_targets_sources'}, {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}, {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '__init_xsl_stylesheet'}, {'id': '27', 'type': 'argument_list', 'children': ['28', '29', '30', '31']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'$DOCBOOK_DEFAULT_XSL_MAN'"}, {'id': '31', 'type': 'list', 'children': ['32', '33'], 'value': "['manpages','docbook.xsl']"}; {'id': '32', 'type': 'string', 'children': [], 'value': "'manpages'"}, {'id': '33', 'type': 'string', 'children': [], 'value': "'docbook.xsl'"}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}, {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '__builder'}, {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '__select_builder'}, {'id': '39', 'type': 'argument_list', 'children': ['40', '41', '42']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '__lxml_builder'}, {'id': '41', 'type': 'identifier', 'children': [], 'value': '__libxml2_builder'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '__xsltproc_builder'}, {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '46', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '47', 'type': 'for_statement', 'children': ['48', '51', '56']}; {'id': '48', 'type': 'pattern_list', 'children': ['49', '50']}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'zip'}, {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '56', 'type': 'block', 'children': ['57', '61', '65', '76', '310', '323', '335', '344']}, {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 'volnum'}; {'id': '60', 'type': 'string', 'children': [], 'value': '"1"'}, {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'outfiles'}; {'id': '64', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}, {'id': '67', 'type': 'identifier', 'children': [], 'value': 'srcfile'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': '__ensure_suffix'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '75']}, {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '75', 'type': 'string', 'children': [], 'value': "'.xml'"}; {'id': '76', 'type': 'if_statement', 'children': ['77', '85', '301']}, {'id': '77', 'type': 'call', 'children': ['78', '83']}; {'id': '78', 'type': 'attribute', 'children': ['79', '82']}, {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'isfile'}, {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'srcfile'}, {'id': '85', 'type': 'block', 'children': ['86', '244']}; {'id': '86', 'type': 'try_statement', 'children': ['87', '170']}, {'id': '87', 'type': 'block', 'children': ['88', '93', '113', '138']}; {'id': '88', 'type': 'import_statement', 'children': ['89']}, {'id': '89', 'type': 'dotted_name', 'children': ['90', '91', '92']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'xml'}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'dom'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'minidom'}, {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'dom'}; {'id': '96', 'type': 'call', 'children': ['97', '104']}, {'id': '97', 'type': 'attribute', 'children': ['98', '103']}; {'id': '98', 'type': 'attribute', 'children': ['99', '102']}, {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'xml'}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'dom'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'minidom'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'parse'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}, {'id': '105', 'type': 'call', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': '__ensure_suffix'}, {'id': '107', 'type': 'argument_list', 'children': ['108', '112']}; {'id': '108', 'type': 'call', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '112', 'type': 'string', 'children': [], 'value': "'.xml'"}, {'id': '113', 'type': 'for_statement', 'children': ['114', '115', '121']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '115', 'type': 'call', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'dom'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'getElementsByTagName'}, {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'string', 'children': [], 'value': "'refmeta'"}, {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'for_statement', 'children': ['123', '124', '130']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'vol'}; {'id': '124', 'type': 'call', 'children': ['125', '128']}, {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'node'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'getElementsByTagName'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}, {'id': '129', 'type': 'string', 'children': [], 'value': "'manvolnum'"}; {'id': '130', 'type': 'block', 'children': ['131']}, {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'assignment', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'volnum'}; {'id': '134', 'type': 'call', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': '__get_xml_text'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'vol'}; {'id': '138', 'type': 'for_statement', 'children': ['139', '140', '146']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '140', 'type': 'call', 'children': ['141', '144']}, {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'dom'}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'getElementsByTagName'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}, {'id': '145', 'type': 'string', 'children': [], 'value': "'refnamediv'"}; {'id': '146', 'type': 'block', 'children': ['147']}, {'id': '147', 'type': 'for_statement', 'children': ['148', '149', '155']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'ref'}, {'id': '149', 'type': 'call', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'getElementsByTagName'}, {'id': '153', 'type': 'argument_list', 'children': ['154']}; {'id': '154', 'type': 'string', 'children': [], 'value': "'refname'"}, {'id': '155', 'type': 'block', 'children': ['156']}; {'id': '156', 'type': 'expression_statement', 'children': ['157']}, {'id': '157', 'type': 'call', 'children': ['158', '161']}; {'id': '158', 'type': 'attribute', 'children': ['159', '160']}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'outfiles'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '161', 'type': 'argument_list', 'children': ['162']}; {'id': '162', 'type': 'binary_operator', 'children': ['163', '169'], 'value': '+'}, {'id': '163', 'type': 'binary_operator', 'children': ['164', '168'], 'value': '+'}; {'id': '164', 'type': 'call', 'children': ['165', '166']}, {'id': '165', 'type': 'identifier', 'children': [], 'value': '__get_xml_text'}; {'id': '166', 'type': 'argument_list', 'children': ['167']}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '168', 'type': 'string', 'children': [], 'value': "'.'"}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'volnum'}; {'id': '170', 'type': 'except_clause', 'children': ['171']}, {'id': '171', 'type': 'block', 'children': ['172', '187', '195', '201', '219']}; {'id': '172', 'type': 'expression_statement', 'children': ['173']}, {'id': '173', 'type': 'assignment', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '175', 'type': 'call', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'open'}, {'id': '177', 'type': 'argument_list', 'children': ['178', '186']}; {'id': '178', 'type': 'call', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': '__ensure_suffix'}; {'id': '180', 'type': 'argument_list', 'children': ['181', '185']}, {'id': '181', 'type': 'call', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '183', 'type': 'argument_list', 'children': ['184']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '185', 'type': 'string', 'children': [], 'value': "'.xml'"}; {'id': '186', 'type': 'string', 'children': [], 'value': "'r'"}, {'id': '187', 'type': 'expression_statement', 'children': ['188']}; {'id': '188', 'type': 'assignment', 'children': ['189', '190']}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '190', 'type': 'call', 'children': ['191', '194']}, {'id': '191', 'type': 'attribute', 'children': ['192', '193']}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '194', 'type': 'argument_list', 'children': []}, {'id': '195', 'type': 'expression_statement', 'children': ['196']}; {'id': '196', 'type': 'call', 'children': ['197', '200']}, {'id': '197', 'type': 'attribute', 'children': ['198', '199']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '200', 'type': 'argument_list', 'children': []}, {'id': '201', 'type': 'for_statement', 'children': ['202', '203', '209']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '203', 'type': 'call', 'children': ['204', '207']}; {'id': '204', 'type': 'attribute', 'children': ['205', '206']}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 're_manvolnum'}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'finditer'}, {'id': '207', 'type': 'argument_list', 'children': ['208']}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'content'}, {'id': '209', 'type': 'block', 'children': ['210']}; {'id': '210', 'type': 'expression_statement', 'children': ['211']}, {'id': '211', 'type': 'assignment', 'children': ['212', '213']}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'volnum'}, {'id': '213', 'type': 'call', 'children': ['214', '217']}; {'id': '214', 'type': 'attribute', 'children': ['215', '216']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'group'}, {'id': '217', 'type': 'argument_list', 'children': ['218']}; {'id': '218', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '219', 'type': 'for_statement', 'children': ['220', '221', '227']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '221', 'type': 'call', 'children': ['222', '225']}; {'id': '222', 'type': 'attribute', 'children': ['223', '224']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 're_refname'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'finditer'}, {'id': '225', 'type': 'argument_list', 'children': ['226']}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'content'}, {'id': '227', 'type': 'block', 'children': ['228']}; {'id': '228', 'type': 'expression_statement', 'children': ['229']}, {'id': '229', 'type': 'call', 'children': ['230', '233']}; {'id': '230', 'type': 'attribute', 'children': ['231', '232']}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'outfiles'}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '233', 'type': 'argument_list', 'children': ['234']}; {'id': '234', 'type': 'binary_operator', 'children': ['235', '243'], 'value': '+'}, {'id': '235', 'type': 'binary_operator', 'children': ['236', '242'], 'value': '+'}; {'id': '236', 'type': 'call', 'children': ['237', '240']}, {'id': '237', 'type': 'attribute', 'children': ['238', '239']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'm'}, {'id': '239', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '240', 'type': 'argument_list', 'children': ['241']}, {'id': '241', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '242', 'type': 'string', 'children': [], 'value': "'.'"}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'volnum'}; {'id': '244', 'type': 'if_statement', 'children': ['245', '247']}, {'id': '245', 'type': 'not_operator', 'children': ['246']}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'outfiles'}, {'id': '247', 'type': 'block', 'children': ['248', '255']}; {'id': '248', 'type': 'expression_statement', 'children': ['249']}, {'id': '249', 'type': 'assignment', 'children': ['250', '251']}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'spath'}, {'id': '251', 'type': 'call', 'children': ['252', '253']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '253', 'type': 'argument_list', 'children': ['254']}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '255', 'type': 'if_statement', 'children': ['256', '263', '275']}; {'id': '256', 'type': 'not_operator', 'children': ['257']}, {'id': '257', 'type': 'call', 'children': ['258', '261']}; {'id': '258', 'type': 'attribute', 'children': ['259', '260']}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'spath'}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'endswith'}, {'id': '261', 'type': 'argument_list', 'children': ['262']}; {'id': '262', 'type': 'string', 'children': [], 'value': "'.xml'"}, {'id': '263', 'type': 'block', 'children': ['264']}; {'id': '264', 'type': 'expression_statement', 'children': ['265']}, {'id': '265', 'type': 'call', 'children': ['266', '269']}; {'id': '266', 'type': 'attribute', 'children': ['267', '268']}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'outfiles'}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '269', 'type': 'argument_list', 'children': ['270']}; {'id': '270', 'type': 'binary_operator', 'children': ['271', '274'], 'value': '+'}, {'id': '271', 'type': 'binary_operator', 'children': ['272', '273'], 'value': '+'}; {'id': '272', 'type': 'identifier', 'children': [], 'value': 'spath'}, {'id': '273', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'volnum'}, {'id': '275', 'type': 'else_clause', 'children': ['276']}; {'id': '276', 'type': 'block', 'children': ['277', '290']}, {'id': '277', 'type': 'expression_statement', 'children': ['278']}; {'id': '278', 'type': 'assignment', 'children': ['279', '282']}, {'id': '279', 'type': 'pattern_list', 'children': ['280', '281']}; {'id': '280', 'type': 'identifier', 'children': [], 'value': 'stem'}, {'id': '281', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '282', 'type': 'call', 'children': ['283', '288']}, {'id': '283', 'type': 'attribute', 'children': ['284', '287']}; {'id': '284', 'type': 'attribute', 'children': ['285', '286']}, {'id': '285', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '286', 'type': 'identifier', 'children': [], 'value': 'path'}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'splitext'}; {'id': '288', 'type': 'argument_list', 'children': ['289']}, {'id': '289', 'type': 'identifier', 'children': [], 'value': 'spath'}; {'id': '290', 'type': 'expression_statement', 'children': ['291']}, {'id': '291', 'type': 'call', 'children': ['292', '295']}; {'id': '292', 'type': 'attribute', 'children': ['293', '294']}, {'id': '293', 'type': 'identifier', 'children': [], 'value': 'outfiles'}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '295', 'type': 'argument_list', 'children': ['296']}; {'id': '296', 'type': 'binary_operator', 'children': ['297', '300'], 'value': '+'}, {'id': '297', 'type': 'binary_operator', 'children': ['298', '299'], 'value': '+'}; {'id': '298', 'type': 'identifier', 'children': [], 'value': 'stem'}, {'id': '299', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '300', 'type': 'identifier', 'children': [], 'value': 'volnum'}, {'id': '301', 'type': 'else_clause', 'children': ['302']}; {'id': '302', 'type': 'block', 'children': ['303']}, {'id': '303', 'type': 'expression_statement', 'children': ['304']}; {'id': '304', 'type': 'call', 'children': ['305', '308']}, {'id': '305', 'type': 'attribute', 'children': ['306', '307']}; {'id': '306', 'type': 'identifier', 'children': [], 'value': 'outfiles'}, {'id': '307', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '308', 'type': 'argument_list', 'children': ['309']}, {'id': '309', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '310', 'type': 'expression_statement', 'children': ['311']}, {'id': '311', 'type': 'call', 'children': ['312', '315']}; {'id': '312', 'type': 'attribute', 'children': ['313', '314']}, {'id': '313', 'type': 'identifier', 'children': [], 'value': '__builder'}; {'id': '314', 'type': 'identifier', 'children': [], 'value': '__call__'}, {'id': '315', 'type': 'argument_list', 'children': ['316', '317', '320', '321']}; {'id': '316', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '317', 'type': 'subscript', 'children': ['318', '319']}; {'id': '318', 'type': 'identifier', 'children': [], 'value': 'outfiles'}, {'id': '319', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '320', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '321', 'type': 'dictionary_splat', 'children': ['322']}; {'id': '322', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '323', 'type': 'expression_statement', 'children': ['324']}; {'id': '324', 'type': 'call', 'children': ['325', '328']}, {'id': '325', 'type': 'attribute', 'children': ['326', '327']}; {'id': '326', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '327', 'type': 'identifier', 'children': [], 'value': 'Depends'}; {'id': '328', 'type': 'argument_list', 'children': ['329', '332']}, {'id': '329', 'type': 'subscript', 'children': ['330', '331']}; {'id': '330', 'type': 'identifier', 'children': [], 'value': 'outfiles'}, {'id': '331', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '332', 'type': 'subscript', 'children': ['333', '334']}, {'id': '333', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '334', 'type': 'string', 'children': [], 'value': "'DOCBOOK_XSL'"}, {'id': '335', 'type': 'expression_statement', 'children': ['336']}; {'id': '336', 'type': 'call', 'children': ['337', '340']}, {'id': '337', 'type': 'attribute', 'children': ['338', '339']}; {'id': '338', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '339', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '340', 'type': 'argument_list', 'children': ['341']}, {'id': '341', 'type': 'subscript', 'children': ['342', '343']}; {'id': '342', 'type': 'identifier', 'children': [], 'value': 'outfiles'}, {'id': '343', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '344', 'type': 'if_statement', 'children': ['345', '351']}, {'id': '345', 'type': 'comparison_operator', 'children': ['346', '350'], 'value': '>'}; {'id': '346', 'type': 'call', 'children': ['347', '348']}, {'id': '347', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '348', 'type': 'argument_list', 'children': ['349']}, {'id': '349', 'type': 'identifier', 'children': [], 'value': 'outfiles'}; {'id': '350', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '351', 'type': 'block', 'children': ['352']}; {'id': '352', 'type': 'expression_statement', 'children': ['353']}, {'id': '353', 'type': 'call', 'children': ['354', '357']}; {'id': '354', 'type': 'attribute', 'children': ['355', '356']}, {'id': '355', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '356', 'type': 'identifier', 'children': [], 'value': 'Clean'}, {'id': '357', 'type': 'argument_list', 'children': ['358', '361']}; {'id': '358', 'type': 'subscript', 'children': ['359', '360']}, {'id': '359', 'type': 'identifier', 'children': [], 'value': 'outfiles'}; {'id': '360', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '361', 'type': 'subscript', 'children': ['362', '363']}; {'id': '362', 'type': 'identifier', 'children': [], 'value': 'outfiles'}, {'id': '363', 'type': 'slice', 'children': ['364', '365']}; {'id': '364', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '365', 'type': 'colon', 'children': []}; {'id': '366', 'type': 'return_statement', 'children': ['367']}, {'id': '367', 'type': 'identifier', 'children': [], 'value': 'result'}
def DocbookMan(env, target, source=None, *args, **kw): target, source = __extend_targets_sources(target, source) __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_MAN', ['manpages','docbook.xsl']) __builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder) result = [] for t,s in zip(target,source): volnum = "1" outfiles = [] srcfile = __ensure_suffix(str(s),'.xml') if os.path.isfile(srcfile): try: import xml.dom.minidom dom = xml.dom.minidom.parse(__ensure_suffix(str(s),'.xml')) for node in dom.getElementsByTagName('refmeta'): for vol in node.getElementsByTagName('manvolnum'): volnum = __get_xml_text(vol) for node in dom.getElementsByTagName('refnamediv'): for ref in node.getElementsByTagName('refname'): outfiles.append(__get_xml_text(ref)+'.'+volnum) except: f = open(__ensure_suffix(str(s),'.xml'), 'r') content = f.read() f.close() for m in re_manvolnum.finditer(content): volnum = m.group(1) for m in re_refname.finditer(content): outfiles.append(m.group(1)+'.'+volnum) if not outfiles: spath = str(s) if not spath.endswith('.xml'): outfiles.append(spath+'.'+volnum) else: stem, ext = os.path.splitext(spath) outfiles.append(stem+'.'+volnum) else: outfiles.append(t) __builder.__call__(env, outfiles[0], s, **kw) env.Depends(outfiles[0], kw['DOCBOOK_XSL']) result.append(outfiles[0]) if len(outfiles) > 1: env.Clean(outfiles[0], outfiles[1:]) return result
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Builder'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'dictionary_splat_pattern', 'children': ['5']}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '133', '223', '231', '245']}, {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'composite'}; {'id': '10', 'type': 'None', 'children': []}, {'id': '11', 'type': 'if_statement', 'children': ['12', '15', '46']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'in'}, {'id': '13', 'type': 'string', 'children': [], 'value': "'generator'"}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '15', 'type': 'block', 'children': ['16', '26', '42']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '20']}, {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': 'in'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'action'"}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '20', 'type': 'block', 'children': ['21']}, {'id': '21', 'type': 'raise_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'UserError'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}, {'id': '25', 'type': 'string', 'children': [], 'value': '"You must not specify both an action and a generator."'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}, {'id': '27', 'type': 'assignment', 'children': ['28', '31']}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'action'"}, {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}, {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'Action'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'CommandGeneratorAction'}, {'id': '37', 'type': 'argument_list', 'children': ['38', '41']}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'generator'"}, {'id': '41', 'type': 'dictionary', 'children': []}; {'id': '42', 'type': 'delete_statement', 'children': ['43']}, {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '45', 'type': 'string', 'children': [], 'value': "'generator'"}; {'id': '46', 'type': 'elif_clause', 'children': ['47', '50']}, {'id': '47', 'type': 'comparison_operator', 'children': ['48', '49'], 'value': 'in'}; {'id': '48', 'type': 'string', 'children': [], 'value': "'action'"}, {'id': '49', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '50', 'type': 'block', 'children': ['51', '61', '70']}, {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'source_ext_match'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}, {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}, {'id': '59', 'type': 'string', 'children': [], 'value': "'source_ext_match'"}; {'id': '60', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '61', 'type': 'if_statement', 'children': ['62', '65']}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '64'], 'value': 'in'}, {'id': '63', 'type': 'string', 'children': [], 'value': "'source_ext_match'"}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'delete_statement', 'children': ['67']}, {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '69', 'type': 'string', 'children': [], 'value': "'source_ext_match'"}; {'id': '70', 'type': 'if_statement', 'children': ['71', '81', '116']}, {'id': '71', 'type': 'call', 'children': ['72', '77']}; {'id': '72', 'type': 'attribute', 'children': ['73', '76']}, {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'is_Dict'}, {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'subscript', 'children': ['79', '80']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '80', 'type': 'string', 'children': [], 'value': "'action'"}, {'id': '81', 'type': 'block', 'children': ['82', '92', '106']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}, {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'composite'}, {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'DictCmdGenerator'}, {'id': '87', 'type': 'argument_list', 'children': ['88', '91']}; {'id': '88', 'type': 'subscript', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '90', 'type': 'string', 'children': [], 'value': "'action'"}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 'source_ext_match'}; {'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': 'kw'}; {'id': '96', 'type': 'string', 'children': [], 'value': "'action'"}, {'id': '97', 'type': 'call', 'children': ['98', '103']}; {'id': '98', 'type': 'attribute', 'children': ['99', '102']}, {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'Action'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'CommandGeneratorAction'}, {'id': '103', 'type': 'argument_list', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'composite'}, {'id': '105', 'type': 'dictionary', 'children': []}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}, {'id': '107', 'type': 'assignment', 'children': ['108', '111']}; {'id': '108', 'type': 'subscript', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '110', 'type': 'string', 'children': [], 'value': "'src_suffix'"}, {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'composite'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'src_suffixes'}, {'id': '115', 'type': 'argument_list', 'children': []}; {'id': '116', 'type': 'else_clause', 'children': ['117']}, {'id': '117', 'type': 'block', 'children': ['118']}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}, {'id': '119', 'type': 'assignment', 'children': ['120', '123']}; {'id': '120', 'type': 'subscript', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '122', 'type': 'string', 'children': [], 'value': "'action'"}, {'id': '123', 'type': 'call', 'children': ['124', '129']}; {'id': '124', 'type': 'attribute', 'children': ['125', '128']}, {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'Action'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'Action'}, {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'subscript', 'children': ['131', '132']}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '132', 'type': 'string', 'children': [], 'value': "'action'"}, {'id': '133', 'type': 'if_statement', 'children': ['134', '137']}; {'id': '134', 'type': 'comparison_operator', 'children': ['135', '136'], 'value': 'in'}, {'id': '135', 'type': 'string', 'children': [], 'value': "'emitter'"}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '137', 'type': 'block', 'children': ['138', '144']}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}, {'id': '139', 'type': 'assignment', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'emitter'}, {'id': '141', 'type': 'subscript', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '143', 'type': 'string', 'children': [], 'value': "'emitter'"}; {'id': '144', 'type': 'if_statement', 'children': ['145', '153', '185', '204']}, {'id': '145', 'type': 'call', 'children': ['146', '151']}; {'id': '146', 'type': 'attribute', 'children': ['147', '150']}, {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'is_String'}, {'id': '151', 'type': 'argument_list', 'children': ['152']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'emitter'}, {'id': '153', 'type': 'block', 'children': ['154', '165', '176']}; {'id': '154', 'type': 'expression_statement', 'children': ['155']}, {'id': '155', 'type': 'assignment', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'var'}, {'id': '157', 'type': 'call', 'children': ['158', '163']}; {'id': '158', 'type': 'attribute', 'children': ['159', '162']}, {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'get_environment_var'}, {'id': '163', 'type': 'argument_list', 'children': ['164']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'emitter'}, {'id': '165', 'type': 'if_statement', 'children': ['166', '168']}; {'id': '166', 'type': 'not_operator', 'children': ['167']}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '168', 'type': 'block', 'children': ['169']}, {'id': '169', 'type': 'raise_statement', 'children': ['170']}; {'id': '170', 'type': 'call', 'children': ['171', '172']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'UserError'}; {'id': '172', 'type': 'argument_list', 'children': ['173']}, {'id': '173', 'type': 'binary_operator', 'children': ['174', '175'], 'value': '%'}; {'id': '174', 'type': 'string', 'children': [], 'value': '"Supplied emitter \'%s\' does not appear to refer to an Environment variable"'}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'emitter'}; {'id': '176', 'type': 'expression_statement', 'children': ['177']}, {'id': '177', 'type': 'assignment', 'children': ['178', '181']}; {'id': '178', 'type': 'subscript', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '180', 'type': 'string', 'children': [], 'value': "'emitter'"}, {'id': '181', 'type': 'call', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'EmitterProxy'}, {'id': '183', 'type': 'argument_list', 'children': ['184']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'var'}, {'id': '185', 'type': 'elif_clause', 'children': ['186', '194']}; {'id': '186', 'type': 'call', 'children': ['187', '192']}, {'id': '187', 'type': 'attribute', 'children': ['188', '191']}; {'id': '188', 'type': 'attribute', 'children': ['189', '190']}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'Util'}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'is_Dict'}; {'id': '192', 'type': 'argument_list', 'children': ['193']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'emitter'}; {'id': '194', 'type': 'block', 'children': ['195']}, {'id': '195', 'type': 'expression_statement', 'children': ['196']}; {'id': '196', 'type': 'assignment', 'children': ['197', '200']}, {'id': '197', 'type': 'subscript', 'children': ['198', '199']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '199', 'type': 'string', 'children': [], 'value': "'emitter'"}; {'id': '200', 'type': 'call', 'children': ['201', '202']}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'DictEmitter'}; {'id': '202', 'type': 'argument_list', 'children': ['203']}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'emitter'}; {'id': '204', 'type': 'elif_clause', 'children': ['205', '213']}, {'id': '205', 'type': 'call', 'children': ['206', '211']}; {'id': '206', 'type': 'attribute', 'children': ['207', '210']}, {'id': '207', 'type': 'attribute', 'children': ['208', '209']}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'is_List'}, {'id': '211', 'type': 'argument_list', 'children': ['212']}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'emitter'}, {'id': '213', 'type': 'block', 'children': ['214']}; {'id': '214', 'type': 'expression_statement', 'children': ['215']}, {'id': '215', 'type': 'assignment', 'children': ['216', '219']}; {'id': '216', 'type': 'subscript', 'children': ['217', '218']}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '218', 'type': 'string', 'children': [], 'value': "'emitter'"}, {'id': '219', 'type': 'call', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'ListEmitter'}, {'id': '221', 'type': 'argument_list', 'children': ['222']}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'emitter'}, {'id': '223', 'type': 'expression_statement', 'children': ['224']}; {'id': '224', 'type': 'assignment', 'children': ['225', '226']}, {'id': '225', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '226', 'type': 'call', 'children': ['227', '228']}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'BuilderBase'}; {'id': '228', 'type': 'argument_list', 'children': ['229']}, {'id': '229', 'type': 'dictionary_splat', 'children': ['230']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'kw'}, {'id': '231', 'type': 'if_statement', 'children': ['232', '236']}; {'id': '232', 'type': 'not_operator', 'children': ['233']}, {'id': '233', 'type': 'comparison_operator', 'children': ['234', '235'], 'value': 'is'}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'composite'}, {'id': '235', 'type': 'None', 'children': []}; {'id': '236', 'type': 'block', 'children': ['237']}, {'id': '237', 'type': 'expression_statement', 'children': ['238']}; {'id': '238', 'type': 'assignment', 'children': ['239', '240']}, {'id': '239', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '240', 'type': 'call', 'children': ['241', '242']}, {'id': '241', 'type': 'identifier', 'children': [], 'value': 'CompositeBuilder'}; {'id': '242', 'type': 'argument_list', 'children': ['243', '244']}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'composite'}, {'id': '245', 'type': 'return_statement', 'children': ['246']}
def Builder(**kw): composite = None if 'generator' in kw: if 'action' in kw: raise UserError("You must not specify both an action and a generator.") kw['action'] = SCons.Action.CommandGeneratorAction(kw['generator'], {}) del kw['generator'] elif 'action' in kw: source_ext_match = kw.get('source_ext_match', 1) if 'source_ext_match' in kw: del kw['source_ext_match'] if SCons.Util.is_Dict(kw['action']): composite = DictCmdGenerator(kw['action'], source_ext_match) kw['action'] = SCons.Action.CommandGeneratorAction(composite, {}) kw['src_suffix'] = composite.src_suffixes() else: kw['action'] = SCons.Action.Action(kw['action']) if 'emitter' in kw: emitter = kw['emitter'] if SCons.Util.is_String(emitter): var = SCons.Util.get_environment_var(emitter) if not var: raise UserError("Supplied emitter '%s' does not appear to refer to an Environment variable" % emitter) kw['emitter'] = EmitterProxy(var) elif SCons.Util.is_Dict(emitter): kw['emitter'] = DictEmitter(emitter) elif SCons.Util.is_List(emitter): kw['emitter'] = ListEmitter(emitter) result = BuilderBase(**kw) if not composite is None: result = CompositeBuilder(result, composite) return result
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_node_errors'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'builder'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'tlist'}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'slist'}; {'id': '8', 'type': 'block', 'children': ['9', '325']}, {'id': '9', 'type': 'for_statement', 'children': ['10', '11', '12']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'tlist'}; {'id': '12', 'type': 'block', 'children': ['13', '25']}, {'id': '13', 'type': 'if_statement', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'side_effect'}, {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'raise_statement', 'children': ['19']}, {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'UserError'}, {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '24'], 'value': '%'}, {'id': '23', 'type': 'string', 'children': [], 'value': '"Multiple ways to build the same target were specified for: %s"'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '25', 'type': 'if_statement', 'children': ['26', '31']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}, {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'has_explicit_builder'}; {'id': '30', 'type': 'argument_list', 'children': []}, {'id': '31', 'type': 'block', 'children': ['32', '201']}; {'id': '32', 'type': 'if_statement', 'children': ['33', '86']}, {'id': '33', 'type': 'parenthesized_expression', 'children': ['34']}; {'id': '34', 'type': 'boolean_operator', 'children': ['35', '48'], 'value': 'and'}, {'id': '35', 'type': 'boolean_operator', 'children': ['36', '42'], 'value': 'and'}; {'id': '36', 'type': 'not_operator', 'children': ['37']}, {'id': '37', 'type': 'comparison_operator', 'children': ['38', '41'], 'value': 'is'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '41', 'type': 'None', 'children': []}; {'id': '42', 'type': 'not_operator', 'children': ['43']}, {'id': '43', 'type': 'comparison_operator', 'children': ['44', '47'], 'value': 'is'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '48', 'type': 'not_operator', 'children': ['49']}, {'id': '49', 'type': 'parenthesized_expression', 'children': ['50']}; {'id': '50', 'type': 'boolean_operator', 'children': ['51', '82'], 'value': 'and'}, {'id': '51', 'type': 'boolean_operator', 'children': ['52', '67'], 'value': 'and'}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '61'], 'value': 'is'}, {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'getattr'}, {'id': '55', 'type': 'argument_list', 'children': ['56', '59', '60']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '59', 'type': 'string', 'children': [], 'value': "'__subject'"}; {'id': '60', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'getattr'}, {'id': '63', 'type': 'argument_list', 'children': ['64', '65', '66']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '65', 'type': 'string', 'children': [], 'value': "'__subject'"}; {'id': '66', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '67', 'type': 'comparison_operator', 'children': ['68', '76'], 'value': '=='}; {'id': '68', 'type': 'call', 'children': ['69', '70']}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '74', '75']}, {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '74', 'type': 'string', 'children': [], 'value': "'overrides'"}, {'id': '75', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '76', 'type': 'call', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80', '81']}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '80', 'type': 'string', 'children': [], 'value': "'overrides'"}, {'id': '81', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '82', 'type': 'not_operator', 'children': ['83']}, {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'builder'}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'multi'}; {'id': '86', 'type': 'block', 'children': ['87', '95', '112', '125']}, {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '90', 'type': 'attribute', 'children': ['91', '94']}, {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'builder'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'action'}, {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 't_contents'}; {'id': '98', 'type': 'call', 'children': ['99', '106']}, {'id': '99', 'type': 'attribute', 'children': ['100', '105']}; {'id': '100', 'type': 'attribute', 'children': ['101', '104']}, {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'builder'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'action'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'get_contents'}; {'id': '106', 'type': 'argument_list', 'children': ['107', '108', '109']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'tlist'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'slist'}, {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}, {'id': '113', 'type': 'assignment', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'contents'}, {'id': '115', 'type': 'call', 'children': ['116', '121']}; {'id': '116', 'type': 'attribute', 'children': ['117', '120']}, {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'builder'}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'get_contents'}, {'id': '121', 'type': 'argument_list', 'children': ['122', '123', '124']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'tlist'}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'slist'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '125', 'type': 'if_statement', 'children': ['126', '129', '161']}; {'id': '126', 'type': 'comparison_operator', 'children': ['127', '128'], 'value': '=='}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 't_contents'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'contents'}, {'id': '129', 'type': 'block', 'children': ['130', '147']}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}, {'id': '131', 'type': 'assignment', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '133', 'type': 'binary_operator', 'children': ['134', '135'], 'value': '%'}; {'id': '134', 'type': 'string', 'children': [], 'value': '"Two different environments were specified for target %s,\\n\\tbut they appear to have the same action: %s"'}, {'id': '135', 'type': 'tuple', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}, {'id': '139', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'genstring'}, {'id': '141', 'type': 'argument_list', 'children': ['142', '143', '144']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'tlist'}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'slist'}; {'id': '144', 'type': 'attribute', 'children': ['145', '146']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'call', 'children': ['149', '154']}, {'id': '149', 'type': 'attribute', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}, {'id': '151', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'Warnings'}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '154', 'type': 'argument_list', 'children': ['155', '160']}, {'id': '155', 'type': 'attribute', 'children': ['156', '159']}; {'id': '156', 'type': 'attribute', 'children': ['157', '158']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'Warnings'}, {'id': '159', 'type': 'identifier', 'children': [], 'value': 'DuplicateEnvironmentWarning'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '161', 'type': 'else_clause', 'children': ['162']}; {'id': '162', 'type': 'block', 'children': ['163', '196']}, {'id': '163', 'type': 'try_statement', 'children': ['164', '184']}; {'id': '164', 'type': 'block', 'children': ['165']}, {'id': '165', 'type': 'expression_statement', 'children': ['166']}; {'id': '166', 'type': 'assignment', 'children': ['167', '168']}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '168', 'type': 'binary_operator', 'children': ['169', '170'], 'value': '%'}, {'id': '169', 'type': 'string', 'children': [], 'value': '"Two environments with different actions were specified for the same target: %s\\n(action 1: %s)\\n(action 2: %s)"'}; {'id': '170', 'type': 'tuple', 'children': ['171', '172', '178']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '172', 'type': 'call', 'children': ['173', '176']}, {'id': '173', 'type': 'attribute', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 't_contents'}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '176', 'type': 'argument_list', 'children': ['177']}, {'id': '177', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '178', 'type': 'call', 'children': ['179', '182']}, {'id': '179', 'type': 'attribute', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'contents'}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '182', 'type': 'argument_list', 'children': ['183']}, {'id': '183', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '184', 'type': 'except_clause', 'children': ['185', '189']}, {'id': '185', 'type': 'as_pattern', 'children': ['186', '187']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'UnicodeDecodeError'}, {'id': '187', 'type': 'as_pattern_target', 'children': ['188']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'e'}, {'id': '189', 'type': 'block', 'children': ['190']}; {'id': '190', 'type': 'expression_statement', 'children': ['191']}, {'id': '191', 'type': 'assignment', 'children': ['192', '193']}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '193', 'type': 'binary_operator', 'children': ['194', '195'], 'value': '%'}; {'id': '194', 'type': 'string', 'children': [], 'value': '"Two environments with different actions were specified for the same target: %s"'}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '196', 'type': 'raise_statement', 'children': ['197']}, {'id': '197', 'type': 'call', 'children': ['198', '199']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'UserError'}, {'id': '199', 'type': 'argument_list', 'children': ['200']}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '201', 'type': 'if_statement', 'children': ['202', '205', '288']}; {'id': '202', 'type': 'attribute', 'children': ['203', '204']}, {'id': '203', 'type': 'identifier', 'children': [], 'value': 'builder'}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'multi'}, {'id': '205', 'type': 'block', 'children': ['206', '239']}; {'id': '206', 'type': 'if_statement', 'children': ['207', '212']}, {'id': '207', 'type': 'comparison_operator', 'children': ['208', '211'], 'value': '!='}; {'id': '208', 'type': 'attribute', 'children': ['209', '210']}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'builder'}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'builder'}; {'id': '212', 'type': 'block', 'children': ['213', '234']}, {'id': '213', 'type': 'expression_statement', 'children': ['214']}; {'id': '214', 'type': 'assignment', 'children': ['215', '216']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '216', 'type': 'binary_operator', 'children': ['217', '218'], 'value': '%'}, {'id': '217', 'type': 'string', 'children': [], 'value': '"Two different builders (%s and %s) were specified for the same target: %s"'}; {'id': '218', 'type': 'tuple', 'children': ['219', '227', '233']}, {'id': '219', 'type': 'call', 'children': ['220', '225']}; {'id': '220', 'type': 'attribute', 'children': ['221', '224']}, {'id': '221', 'type': 'attribute', 'children': ['222', '223']}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'builder'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'get_name'}, {'id': '225', 'type': 'argument_list', 'children': ['226']}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '227', 'type': 'call', 'children': ['228', '231']}; {'id': '228', 'type': 'attribute', 'children': ['229', '230']}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'builder'}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'get_name'}, {'id': '231', 'type': 'argument_list', 'children': ['232']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '234', 'type': 'raise_statement', 'children': ['235']}, {'id': '235', 'type': 'call', 'children': ['236', '237']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'UserError'}, {'id': '237', 'type': 'argument_list', 'children': ['238']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '239', 'type': 'if_statement', 'children': ['240', '251']}; {'id': '240', 'type': 'comparison_operator', 'children': ['241', '250'], 'value': '!='}, {'id': '241', 'type': 'call', 'children': ['242', '249']}; {'id': '242', 'type': 'attribute', 'children': ['243', '248']}, {'id': '243', 'type': 'call', 'children': ['244', '247']}; {'id': '244', 'type': 'attribute', 'children': ['245', '246']}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'get_executor'}, {'id': '247', 'type': 'argument_list', 'children': []}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 'get_all_targets'}, {'id': '249', 'type': 'argument_list', 'children': []}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'tlist'}, {'id': '251', 'type': 'block', 'children': ['252', '283']}; {'id': '252', 'type': 'expression_statement', 'children': ['253']}, {'id': '253', 'type': 'assignment', 'children': ['254', '255']}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '255', 'type': 'binary_operator', 'children': ['256', '257'], 'value': '%'}; {'id': '256', 'type': 'string', 'children': [], 'value': '"Two different target lists have a target in common: %s (from %s and from %s)"'}, {'id': '257', 'type': 'tuple', 'children': ['258', '259', '275']}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '259', 'type': 'call', 'children': ['260', '261']}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'list'}, {'id': '261', 'type': 'argument_list', 'children': ['262']}; {'id': '262', 'type': 'call', 'children': ['263', '264']}, {'id': '263', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '264', 'type': 'argument_list', 'children': ['265', '266']}, {'id': '265', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '266', 'type': 'call', 'children': ['267', '274']}, {'id': '267', 'type': 'attribute', 'children': ['268', '273']}; {'id': '268', 'type': 'call', 'children': ['269', '272']}, {'id': '269', 'type': 'attribute', 'children': ['270', '271']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '271', 'type': 'identifier', 'children': [], 'value': 'get_executor'}; {'id': '272', 'type': 'argument_list', 'children': []}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'get_all_targets'}; {'id': '274', 'type': 'argument_list', 'children': []}, {'id': '275', 'type': 'call', 'children': ['276', '277']}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'list'}, {'id': '277', 'type': 'argument_list', 'children': ['278']}; {'id': '278', 'type': 'call', 'children': ['279', '280']}, {'id': '279', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '280', 'type': 'argument_list', 'children': ['281', '282']}, {'id': '281', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '282', 'type': 'identifier', 'children': [], 'value': 'tlist'}, {'id': '283', 'type': 'raise_statement', 'children': ['284']}; {'id': '284', 'type': 'call', 'children': ['285', '286']}, {'id': '285', 'type': 'identifier', 'children': [], 'value': 'UserError'}; {'id': '286', 'type': 'argument_list', 'children': ['287']}, {'id': '287', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '288', 'type': 'elif_clause', 'children': ['289', '294']}, {'id': '289', 'type': 'comparison_operator', 'children': ['290', '293'], 'value': '!='}; {'id': '290', 'type': 'attribute', 'children': ['291', '292']}, {'id': '291', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '292', 'type': 'identifier', 'children': [], 'value': 'sources'}, {'id': '293', 'type': 'identifier', 'children': [], 'value': 'slist'}; {'id': '294', 'type': 'block', 'children': ['295', '320']}, {'id': '295', 'type': 'expression_statement', 'children': ['296']}; {'id': '296', 'type': 'assignment', 'children': ['297', '298']}, {'id': '297', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '298', 'type': 'binary_operator', 'children': ['299', '300'], 'value': '%'}, {'id': '299', 'type': 'string', 'children': [], 'value': '"Multiple ways to build the same target were specified for: %s (from %s and from %s)"'}; {'id': '300', 'type': 'tuple', 'children': ['301', '302', '312']}, {'id': '301', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '302', 'type': 'call', 'children': ['303', '304']}, {'id': '303', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '304', 'type': 'argument_list', 'children': ['305']}, {'id': '305', 'type': 'call', 'children': ['306', '307']}; {'id': '306', 'type': 'identifier', 'children': [], 'value': 'map'}, {'id': '307', 'type': 'argument_list', 'children': ['308', '309']}; {'id': '308', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '309', 'type': 'attribute', 'children': ['310', '311']}; {'id': '310', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '311', 'type': 'identifier', 'children': [], 'value': 'sources'}; {'id': '312', 'type': 'call', 'children': ['313', '314']}, {'id': '313', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '314', 'type': 'argument_list', 'children': ['315']}, {'id': '315', 'type': 'call', 'children': ['316', '317']}; {'id': '316', 'type': 'identifier', 'children': [], 'value': 'map'}, {'id': '317', 'type': 'argument_list', 'children': ['318', '319']}; {'id': '318', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '319', 'type': 'identifier', 'children': [], 'value': 'slist'}; {'id': '320', 'type': 'raise_statement', 'children': ['321']}, {'id': '321', 'type': 'call', 'children': ['322', '323']}; {'id': '322', 'type': 'identifier', 'children': [], 'value': 'UserError'}, {'id': '323', 'type': 'argument_list', 'children': ['324']}; {'id': '324', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '325', 'type': 'if_statement', 'children': ['326', '329']}; {'id': '326', 'type': 'attribute', 'children': ['327', '328']}, {'id': '327', 'type': 'identifier', 'children': [], 'value': 'builder'}; {'id': '328', 'type': 'identifier', 'children': [], 'value': 'single_source'}, {'id': '329', 'type': 'block', 'children': ['330']}; {'id': '330', 'type': 'if_statement', 'children': ['331', '337']}, {'id': '331', 'type': 'comparison_operator', 'children': ['332', '336'], 'value': '>'}; {'id': '332', 'type': 'call', 'children': ['333', '334']}, {'id': '333', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '334', 'type': 'argument_list', 'children': ['335']}, {'id': '335', 'type': 'identifier', 'children': [], 'value': 'slist'}; {'id': '336', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '337', 'type': 'block', 'children': ['338']}; {'id': '338', 'type': 'raise_statement', 'children': ['339']}, {'id': '339', 'type': 'call', 'children': ['340', '341']}; {'id': '340', 'type': 'identifier', 'children': [], 'value': 'UserError'}, {'id': '341', 'type': 'argument_list', 'children': ['342']}; {'id': '342', 'type': 'binary_operator', 'children': ['343', '344'], 'value': '%'}, {'id': '343', 'type': 'string', 'children': [], 'value': '"More than one source given for single-source builder: targets=%s sources=%s"'}; {'id': '344', 'type': 'tuple', 'children': ['345', '353']}, {'id': '345', 'type': 'call', 'children': ['346', '347']}; {'id': '346', 'type': 'identifier', 'children': [], 'value': 'list'}, {'id': '347', 'type': 'argument_list', 'children': ['348']}; {'id': '348', 'type': 'call', 'children': ['349', '350']}, {'id': '349', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '350', 'type': 'argument_list', 'children': ['351', '352']}, {'id': '351', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '352', 'type': 'identifier', 'children': [], 'value': 'tlist'}, {'id': '353', 'type': 'call', 'children': ['354', '355']}; {'id': '354', 'type': 'identifier', 'children': [], 'value': 'list'}, {'id': '355', 'type': 'argument_list', 'children': ['356']}; {'id': '356', 'type': 'call', 'children': ['357', '358']}, {'id': '357', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '358', 'type': 'argument_list', 'children': ['359', '360']}, {'id': '359', 'type': 'identifier', 'children': [], 'value': 'str'}
def _node_errors(builder, env, tlist, slist): for t in tlist: if t.side_effect: raise UserError("Multiple ways to build the same target were specified for: %s" % t) if t.has_explicit_builder(): if (not t.env is None and not t.env is env and not (getattr(t.env, '__subject', 0) is getattr(env, '__subject', 1) and getattr(t.env, 'overrides', 0) == getattr(env, 'overrides', 1) and not builder.multi)): action = t.builder.action t_contents = t.builder.action.get_contents(tlist, slist, t.env) contents = builder.action.get_contents(tlist, slist, env) if t_contents == contents: msg = "Two different environments were specified for target %s,\n\tbut they appear to have the same action: %s" % (t, action.genstring(tlist, slist, t.env)) SCons.Warnings.warn(SCons.Warnings.DuplicateEnvironmentWarning, msg) else: try: msg = "Two environments with different actions were specified for the same target: %s\n(action 1: %s)\n(action 2: %s)" % (t,t_contents.decode('utf-8'),contents.decode('utf-8')) except UnicodeDecodeError as e: msg = "Two environments with different actions were specified for the same target: %s"%t raise UserError(msg) if builder.multi: if t.builder != builder: msg = "Two different builders (%s and %s) were specified for the same target: %s" % (t.builder.get_name(env), builder.get_name(env), t) raise UserError(msg) if t.get_executor().get_all_targets() != tlist: msg = "Two different target lists have a target in common: %s (from %s and from %s)" % (t, list(map(str, t.get_executor().get_all_targets())), list(map(str, tlist))) raise UserError(msg) elif t.sources != slist: msg = "Multiple ways to build the same target were specified for: %s (from %s and from %s)" % (t, list(map(str, t.sources)), list(map(str, slist))) raise UserError(msg) if builder.single_source: if len(slist) > 1: raise UserError("More than one source given for single-source builder: targets=%s sources=%s" % (list(map(str,tlist)), list(map(str,slist))))
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_order_pases'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'passes'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '18', '91']}, {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'passes'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}, {'id': '11', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'passes'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}, {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'pass_deps'}, {'id': '17', 'type': 'dictionary', 'children': []}; {'id': '18', 'type': 'for_statement', 'children': ['19', '20', '21']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'passes'}, {'id': '21', 'type': 'block', 'children': ['22', '33', '46', '59']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}, {'id': '23', 'type': 'assignment', 'children': ['24', '28']}; {'id': '24', 'type': 'pattern_list', 'children': ['25', '26', '27']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'before'}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'after'}; {'id': '28', 'type': 'subscript', 'children': ['29', '32']}, {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '31', 'type': 'identifier', 'children': [], 'value': '_known_passes'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'opt'}, {'id': '33', 'type': 'if_statement', 'children': ['34', '37']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '36'], 'value': 'not'}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'pass_deps'}, {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}, {'id': '39', 'type': 'assignment', 'children': ['40', '43']}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'pass_deps'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'opt'}, {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'set'}, {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'for_statement', 'children': ['47', '48', '49']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'after_pass'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'after'}, {'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': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'pass_deps'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'add'}, {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'after_pass'}, {'id': '59', 'type': 'for_statement', 'children': ['60', '61', '62']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'other'}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'before'}; {'id': '62', 'type': 'block', 'children': ['63', '69', '82']}, {'id': '63', 'type': 'if_statement', 'children': ['64', '67']}; {'id': '64', 'type': 'comparison_operator', 'children': ['65', '66'], 'value': 'not'}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'passes'}, {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'continue_statement', 'children': []}, {'id': '69', 'type': 'if_statement', 'children': ['70', '73']}; {'id': '70', 'type': 'comparison_operator', 'children': ['71', '72'], 'value': 'not'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'pass_deps'}, {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}, {'id': '75', 'type': 'assignment', 'children': ['76', '79']}; {'id': '76', 'type': 'subscript', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'pass_deps'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'other'}, {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'set'}, {'id': '81', 'type': 'argument_list', 'children': []}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}, {'id': '83', 'type': 'call', 'children': ['84', '89']}; {'id': '84', 'type': 'attribute', 'children': ['85', '88']}, {'id': '85', 'type': 'subscript', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'pass_deps'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'add'}, {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'opt'}, {'id': '91', 'type': 'return_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'toposort_flatten'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'pass_deps'}
def _order_pases(self, passes): passes = set(passes) pass_deps = {} for opt in passes: _, before, after = self._known_passes[opt] if opt not in pass_deps: pass_deps[opt] = set() for after_pass in after: pass_deps[opt].add(after_pass) for other in before: if other not in passes: continue if other not in pass_deps: pass_deps[other] = set() pass_deps[other].add(opt) return toposort_flatten(pass_deps)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prepare'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6', '8', '16', '34', '40', '66', '78', '84', '90']}; {'id': '6', 'type': 'global_statement', 'children': ['7']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'print_prepare'}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}, {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'T'}, {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'tm'}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'trace'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '18', 'type': 'block', 'children': ['19']}, {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}, {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'T'}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}, {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'trace_message'}, {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': "u'Task.prepare()'"}, {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'node'}; {'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': 'exception_raise'}, {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'if_statement', 'children': ['41', '46']}, {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'tm'}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '46', 'type': 'block', 'children': ['47', '58']}, {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}, {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'display'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}, {'id': '53', 'type': 'attribute', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'tm'}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}, {'id': '59', 'type': 'assignment', 'children': ['60', '65']}; {'id': '60', 'type': 'attribute', 'children': ['61', '64']}, {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'tm'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'message'}, {'id': '65', 'type': 'None', 'children': []}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}, {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'executor'}, {'id': '69', 'type': 'call', 'children': ['70', '77']}; {'id': '70', 'type': 'attribute', 'children': ['71', '76']}, {'id': '71', 'type': 'subscript', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'targets'}, {'id': '75', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'get_executor'}, {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'if_statement', 'children': ['79', '82']}, {'id': '79', 'type': 'comparison_operator', 'children': ['80', '81'], 'value': 'is'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'executor'}, {'id': '81', 'type': 'None', 'children': []}; {'id': '82', 'type': 'block', 'children': ['83']}, {'id': '83', 'type': 'return_statement', 'children': []}; {'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': 'executor'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'prepare'}, {'id': '89', 'type': 'argument_list', 'children': []}; {'id': '90', 'type': 'for_statement', 'children': ['91', '92', '97']}, {'id': '91', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '92', 'type': 'call', 'children': ['93', '96']}, {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'executor'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'get_action_targets'}; {'id': '96', 'type': 'argument_list', 'children': []}, {'id': '97', 'type': 'block', 'children': ['98', '121', '127']}; {'id': '98', 'type': 'if_statement', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'print_prepare'}; {'id': '100', 'type': 'block', 'children': ['101', '108']}, {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}, {'id': '105', 'type': 'binary_operator', 'children': ['106', '107'], 'value': '%'}; {'id': '106', 'type': 'string', 'children': [], 'value': '"Preparing target %s..."'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '108', 'type': 'for_statement', 'children': ['109', '110', '113']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'side_effects'}, {'id': '113', 'type': 'block', 'children': ['114']}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}, {'id': '115', 'type': 'call', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'print'}, {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'binary_operator', 'children': ['119', '120'], 'value': '%'}, {'id': '119', 'type': 'string', 'children': [], 'value': '"...with side-effect %s..."'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 's'}, {'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': 't'}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'prepare'}; {'id': '126', 'type': 'argument_list', 'children': []}, {'id': '127', 'type': 'for_statement', 'children': ['128', '129', '132']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'side_effects'}; {'id': '132', 'type': 'block', 'children': ['133', '143']}, {'id': '133', 'type': 'if_statement', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'print_prepare'}, {'id': '135', 'type': 'block', 'children': ['136']}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}, {'id': '137', 'type': 'call', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'print'}, {'id': '139', 'type': 'argument_list', 'children': ['140']}; {'id': '140', 'type': 'binary_operator', 'children': ['141', '142'], 'value': '%'}, {'id': '141', 'type': 'string', 'children': [], 'value': '"...Preparing side-effect %s..."'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '143', 'type': 'expression_statement', 'children': ['144']}; {'id': '144', 'type': 'call', 'children': ['145', '148']}, {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'prepare'}
def prepare(self): global print_prepare T = self.tm.trace if T: T.write(self.trace_message(u'Task.prepare()', self.node)) self.exception_raise() if self.tm.message: self.display(self.tm.message) self.tm.message = None executor = self.targets[0].get_executor() if executor is None: return executor.prepare() for t in executor.get_action_targets(): if print_prepare: print("Preparing target %s..."%t) for s in t.side_effects: print("...with side-effect %s..."%s) t.prepare() for s in t.side_effects: if print_prepare: print("...Preparing side-effect %s..."%s) s.prepare()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_ready_current'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6', '8', '16', '34', '40', '44', '128']}; {'id': '6', 'type': 'global_statement', 'children': ['7']}, {'id': '7', 'type': 'identifier', 'children': [], 'value': 'print_prepare'}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}, {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'T'}, {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'tm'}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'trace'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '18', 'type': 'block', 'children': ['19']}, {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}, {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'T'}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}, {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'trace_message'}, {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': "u'Task.make_ready_current()'"}, {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}, {'id': '35', 'type': 'assignment', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'out_of_date'}, {'id': '39', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}, {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'needs_executing'}, {'id': '43', 'type': 'False', 'children': []}; {'id': '44', 'type': 'for_statement', 'children': ['45', '46', '49']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'targets'}, {'id': '49', 'type': 'block', 'children': ['50', '111']}; {'id': '50', 'type': 'try_statement', 'children': ['51', '84']}, {'id': '51', 'type': 'block', 'children': ['52', '62']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}, {'id': '53', 'type': 'call', 'children': ['54', '61']}; {'id': '54', 'type': 'attribute', 'children': ['55', '60']}, {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'disambiguate'}, {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'make_ready'}, {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}, {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'is_up_to_date'}, {'id': '65', 'type': 'boolean_operator', 'children': ['66', '72', '73'], 'value': 'or'}; {'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': 't'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'has_builder'}, {'id': '71', 'type': 'argument_list', 'children': []}; {'id': '72', 'type': 'line_continuation', 'children': [], 'value': '\\'}, {'id': '73', 'type': 'parenthesized_expression', 'children': ['74']}; {'id': '74', 'type': 'boolean_operator', 'children': ['75', '79'], 'value': 'and'}, {'id': '75', 'type': 'not_operator', 'children': ['76']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'always_build'}, {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'is_up_to_date'}, {'id': '83', 'type': 'argument_list', 'children': []}; {'id': '84', 'type': 'except_clause', 'children': ['85', '89']}, {'id': '85', 'type': 'as_pattern', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'EnvironmentError'}, {'id': '87', 'type': 'as_pattern_target', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'e'}, {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'raise_statement', 'children': ['91']}, {'id': '91', 'type': 'call', 'children': ['92', '97']}; {'id': '92', 'type': 'attribute', 'children': ['93', '96']}, {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'Errors'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'BuildError'}, {'id': '97', 'type': 'argument_list', 'children': ['98', '101', '106']}; {'id': '98', 'type': 'keyword_argument', 'children': ['99', '100']}, {'id': '99', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '101', 'type': 'keyword_argument', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'errstr'}, {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'e'}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'strerror'}; {'id': '106', 'type': 'keyword_argument', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'filename'}, {'id': '111', 'type': 'if_statement', 'children': ['112', '114']}; {'id': '112', 'type': 'not_operator', 'children': ['113']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'is_up_to_date'}; {'id': '114', 'type': 'block', 'children': ['115', '124']}, {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '122']}, {'id': '117', 'type': 'attribute', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'out_of_date'}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}, {'id': '125', 'type': 'assignment', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'needs_executing'}, {'id': '127', 'type': 'True', 'children': []}; {'id': '128', 'type': 'if_statement', 'children': ['129', '130', '161']}, {'id': '129', 'type': 'identifier', 'children': [], 'value': 'needs_executing'}; {'id': '130', 'type': 'block', 'children': ['131']}, {'id': '131', 'type': 'for_statement', 'children': ['132', '133', '136']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'targets'}; {'id': '136', 'type': 'block', 'children': ['137', '144']}, {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '142']}, {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'set_state'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'NODE_EXECUTING'}; {'id': '144', 'type': 'for_statement', 'children': ['145', '146', '149']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'side_effects'}, {'id': '149', 'type': 'block', 'children': ['150']}; {'id': '150', 'type': 'expression_statement', 'children': ['151']}, {'id': '151', 'type': 'call', 'children': ['152', '159']}; {'id': '152', 'type': 'attribute', 'children': ['153', '158']}, {'id': '153', 'type': 'call', 'children': ['154', '157']}; {'id': '154', 'type': 'attribute', 'children': ['155', '156']}, {'id': '155', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'disambiguate'}, {'id': '157', 'type': 'argument_list', 'children': []}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'set_state'}, {'id': '159', 'type': 'argument_list', 'children': ['160']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'NODE_EXECUTING'}, {'id': '161', 'type': 'else_clause', 'children': ['162']}; {'id': '162', 'type': 'block', 'children': ['163']}, {'id': '163', 'type': 'for_statement', 'children': ['164', '165', '168']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '165', 'type': 'attribute', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'targets'}; {'id': '168', 'type': 'block', 'children': ['169', '175', '182']}, {'id': '169', 'type': 'expression_statement', 'children': ['170']}; {'id': '170', 'type': 'call', 'children': ['171', '174']}, {'id': '171', 'type': 'attribute', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '174', 'type': 'argument_list', 'children': []}, {'id': '175', 'type': 'expression_statement', 'children': ['176']}; {'id': '176', 'type': 'call', 'children': ['177', '180']}, {'id': '177', 'type': 'attribute', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'set_state'}; {'id': '180', 'type': 'argument_list', 'children': ['181']}, {'id': '181', 'type': 'identifier', 'children': [], 'value': 'NODE_UP_TO_DATE'}; {'id': '182', 'type': 'if_statement', 'children': ['183', '201']}, {'id': '183', 'type': 'parenthesized_expression', 'children': ['184']}; {'id': '184', 'type': 'boolean_operator', 'children': ['185', '187'], 'value': 'and'}, {'id': '185', 'type': 'not_operator', 'children': ['186']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'print_prepare'}, {'id': '187', 'type': 'parenthesized_expression', 'children': ['188']}; {'id': '188', 'type': 'boolean_operator', 'children': ['189', '195'], 'value': 'or'}, {'id': '189', 'type': 'not_operator', 'children': ['190']}; {'id': '190', 'type': 'call', 'children': ['191', '192']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '192', 'type': 'argument_list', 'children': ['193', '194']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '194', 'type': 'string', 'children': [], 'value': "'options'"}, {'id': '195', 'type': 'not_operator', 'children': ['196']}; {'id': '196', 'type': 'attribute', 'children': ['197', '200']}, {'id': '197', 'type': 'attribute', 'children': ['198', '199']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'debug_includes'}, {'id': '201', 'type': 'block', 'children': ['202']}; {'id': '202', 'type': 'expression_statement', 'children': ['203']}, {'id': '203', 'type': 'call', 'children': ['204', '207']}; {'id': '204', 'type': 'attribute', 'children': ['205', '206']}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'release_target_info'}, {'id': '207', 'type': 'argument_list', 'children': []}
def make_ready_current(self): global print_prepare T = self.tm.trace if T: T.write(self.trace_message(u'Task.make_ready_current()', self.node)) self.out_of_date = [] needs_executing = False for t in self.targets: try: t.disambiguate().make_ready() is_up_to_date = not t.has_builder() or \ (not t.always_build and t.is_up_to_date()) except EnvironmentError as e: raise SCons.Errors.BuildError(node=t, errstr=e.strerror, filename=e.filename) if not is_up_to_date: self.out_of_date.append(t) needs_executing = True if needs_executing: for t in self.targets: t.set_state(NODE_EXECUTING) for s in t.side_effects: s.disambiguate().set_state(NODE_EXECUTING) else: for t in self.targets: t.visited() t.set_state(NODE_UP_TO_DATE) if (not print_prepare and (not hasattr(self, 'options') or not self.options.debug_includes)): t.release_target_info()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'postprocess'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'block', 'children': ['6', '14', '32', '41', '49', '53', '106', '183', '238']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}, {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'T'}, {'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': 'tm'}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'trace'}; {'id': '14', 'type': 'if_statement', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '16', 'type': 'block', 'children': ['17']}, {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}, {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'T'}, {'id': '21', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}, {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'trace_message'}, {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "u'Task.postprocess()'"}, {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}, {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'targets'}, {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'set'}, {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'targets'}, {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'pending_children'}; {'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': 'tm'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'pending_children'}, {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}, {'id': '51', 'type': 'identifier', 'children': [], 'value': 'parents'}; {'id': '52', 'type': 'dictionary', 'children': []}, {'id': '53', 'type': 'for_statement', 'children': ['54', '55', '56']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'targets'}; {'id': '56', 'type': 'block', 'children': ['57', '86']}, {'id': '57', 'type': 'if_statement', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}, {'id': '59', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'waiting_parents'}, {'id': '61', 'type': 'block', 'children': ['62', '79']}; {'id': '62', 'type': 'if_statement', 'children': ['63', '64']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'T'}; {'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': 'T'}, {'id': '69', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}, {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'trace_message'}, {'id': '75', 'type': 'argument_list', 'children': ['76', '77', '78']}; {'id': '76', 'type': 'string', 'children': [], 'value': "u'Task.postprocess()'"}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '78', 'type': 'string', 'children': [], 'value': "'removing'"}, {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '84']}, {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'pending_children'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'discard'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '86', 'type': 'for_statement', 'children': ['87', '88', '91']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'waiting_parents'}, {'id': '91', 'type': 'block', 'children': ['92']}; {'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': 'parents'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '97', 'type': 'binary_operator', 'children': ['98', '105'], 'value': '+'}; {'id': '98', 'type': 'call', 'children': ['99', '102']}, {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'parents'}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '104', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '105', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '106', 'type': 'for_statement', 'children': ['107', '108', '109']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'targets'}, {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'if_statement', 'children': ['111', '116']}, {'id': '111', 'type': 'comparison_operator', 'children': ['112', '115'], 'value': 'is'}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'side_effects'}, {'id': '115', 'type': 'None', 'children': []}; {'id': '116', 'type': 'block', 'children': ['117']}, {'id': '117', 'type': 'for_statement', 'children': ['118', '119', '122']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 't'}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'side_effects'}; {'id': '122', 'type': 'block', 'children': ['123', '159']}, {'id': '123', 'type': 'if_statement', 'children': ['124', '131']}; {'id': '124', 'type': 'comparison_operator', 'children': ['125', '130'], 'value': '=='}, {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'get_state'}, {'id': '129', 'type': 'argument_list', 'children': []}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'NODE_EXECUTING'}, {'id': '131', 'type': 'block', 'children': ['132', '139']}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}, {'id': '133', 'type': 'call', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'set_state'}, {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'NODE_NO_STATE'}, {'id': '139', 'type': 'for_statement', 'children': ['140', '141', '144']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'waiting_parents'}; {'id': '144', 'type': 'block', 'children': ['145']}, {'id': '145', 'type': 'expression_statement', 'children': ['146']}; {'id': '146', 'type': 'assignment', 'children': ['147', '150']}, {'id': '147', 'type': 'subscript', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'parents'}, {'id': '149', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '150', 'type': 'binary_operator', 'children': ['151', '158'], 'value': '+'}, {'id': '151', 'type': 'call', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'parents'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'get'}, {'id': '155', 'type': 'argument_list', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '157', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '158', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '159', 'type': 'for_statement', 'children': ['160', '161', '164']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 's'}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'waiting_s_e'}; {'id': '164', 'type': 'block', 'children': ['165']}, {'id': '165', 'type': 'if_statement', 'children': ['166', '171']}; {'id': '166', 'type': 'comparison_operator', 'children': ['167', '170'], 'value': '=='}, {'id': '167', 'type': 'attribute', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'ref_count'}; {'id': '170', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '171', 'type': 'block', 'children': ['172']}; {'id': '172', 'type': 'expression_statement', 'children': ['173']}, {'id': '173', 'type': 'call', 'children': ['174', '181']}; {'id': '174', 'type': 'attribute', 'children': ['175', '180']}, {'id': '175', 'type': 'attribute', 'children': ['176', '179']}; {'id': '176', 'type': 'attribute', 'children': ['177', '178']}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'tm'}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'candidates'}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'append'}, {'id': '181', 'type': 'argument_list', 'children': ['182']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '183', 'type': 'for_statement', 'children': ['184', '187', '192']}; {'id': '184', 'type': 'pattern_list', 'children': ['185', '186']}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'subtract'}, {'id': '187', 'type': 'call', 'children': ['188', '191']}; {'id': '188', 'type': 'attribute', 'children': ['189', '190']}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'parents'}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'items'}, {'id': '191', 'type': 'argument_list', 'children': []}; {'id': '192', 'type': 'block', 'children': ['193', '203', '220']}, {'id': '193', 'type': 'expression_statement', 'children': ['194']}; {'id': '194', 'type': 'assignment', 'children': ['195', '198']}, {'id': '195', 'type': 'attribute', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'ref_count'}; {'id': '198', 'type': 'binary_operator', 'children': ['199', '202'], 'value': '-'}, {'id': '199', 'type': 'attribute', 'children': ['200', '201']}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'ref_count'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'subtract'}, {'id': '203', 'type': 'if_statement', 'children': ['204', '205']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'T'}, {'id': '205', 'type': 'block', 'children': ['206']}; {'id': '206', 'type': 'expression_statement', 'children': ['207']}, {'id': '207', 'type': 'call', 'children': ['208', '211']}; {'id': '208', 'type': 'attribute', 'children': ['209', '210']}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'write'}, {'id': '211', 'type': 'argument_list', 'children': ['212']}; {'id': '212', 'type': 'call', 'children': ['213', '216']}, {'id': '213', 'type': 'attribute', 'children': ['214', '215']}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'trace_message'}; {'id': '216', 'type': 'argument_list', 'children': ['217', '218', '219']}, {'id': '217', 'type': 'string', 'children': [], 'value': "u'Task.postprocess()'"}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'p'}, {'id': '219', 'type': 'string', 'children': [], 'value': "'adjusted parent ref count'"}; {'id': '220', 'type': 'if_statement', 'children': ['221', '226']}, {'id': '221', 'type': 'comparison_operator', 'children': ['222', '225'], 'value': '=='}; {'id': '222', 'type': 'attribute', 'children': ['223', '224']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'ref_count'}, {'id': '225', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '226', 'type': 'block', 'children': ['227']}, {'id': '227', 'type': 'expression_statement', 'children': ['228']}; {'id': '228', 'type': 'call', 'children': ['229', '236']}, {'id': '229', 'type': 'attribute', 'children': ['230', '235']}; {'id': '230', 'type': 'attribute', 'children': ['231', '234']}, {'id': '231', 'type': 'attribute', 'children': ['232', '233']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '233', 'type': 'identifier', 'children': [], 'value': 'tm'}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'candidates'}, {'id': '235', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '236', 'type': 'argument_list', 'children': ['237']}, {'id': '237', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '238', 'type': 'for_statement', 'children': ['239', '240', '241']}, {'id': '239', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'targets'}, {'id': '241', 'type': 'block', 'children': ['242']}; {'id': '242', 'type': 'expression_statement', 'children': ['243']}, {'id': '243', 'type': 'call', 'children': ['244', '247']}; {'id': '244', 'type': 'attribute', 'children': ['245', '246']}, {'id': '245', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'postprocess'}, {'id': '247', 'type': 'argument_list', 'children': []}
def postprocess(self): T = self.tm.trace if T: T.write(self.trace_message(u'Task.postprocess()', self.node)) targets = set(self.targets) pending_children = self.tm.pending_children parents = {} for t in targets: if t.waiting_parents: if T: T.write(self.trace_message(u'Task.postprocess()', t, 'removing')) pending_children.discard(t) for p in t.waiting_parents: parents[p] = parents.get(p, 0) + 1 for t in targets: if t.side_effects is not None: for s in t.side_effects: if s.get_state() == NODE_EXECUTING: s.set_state(NODE_NO_STATE) for p in s.waiting_parents: parents[p] = parents.get(p, 0) + 1 for p in s.waiting_s_e: if p.ref_count == 0: self.tm.candidates.append(p) for p, subtract in parents.items(): p.ref_count = p.ref_count - subtract if T: T.write(self.trace_message(u'Task.postprocess()', p, 'adjusted parent ref count')) if p.ref_count == 0: self.tm.candidates.append(p) for t in targets: t.postprocess()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_dependency'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tile'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'depinfo'}, {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'destdir'}, {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '34', '38', '42', '60', '205', '210']}, {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'is'}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'destdir'}; {'id': '14', 'type': 'None', 'children': []}, {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}, {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'destdir'}, {'id': '19', 'type': 'call', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}, {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'join'}, {'id': '25', 'type': 'argument_list', 'children': ['26', '29', '30', '31']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'tile'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'folder'}, {'id': '29', 'type': 'string', 'children': [], 'value': "'build'"}; {'id': '30', 'type': 'string', 'children': [], 'value': "'deps'"}, {'id': '31', 'type': 'subscript', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'depinfo'}, {'id': '33', 'type': 'string', 'children': [], 'value': "'unique_id'"}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}, {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'has_version'}, {'id': '37', 'type': 'False', 'children': []}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}, {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'had_version'}, {'id': '41', 'type': 'False', 'children': []}; {'id': '42', 'type': 'if_statement', 'children': ['43', '51']}, {'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': 'os'}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'exists'}, {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'destdir'}, {'id': '51', 'type': 'block', 'children': ['52', '56']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}, {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'has_version'}, {'id': '55', 'type': 'True', 'children': []}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}, {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'had_version'}, {'id': '59', 'type': 'True', 'children': []}; {'id': '60', 'type': 'for_statement', 'children': ['61', '64', '67']}, {'id': '61', 'type': 'pattern_list', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'priority'}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'rule'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'rules'}, {'id': '67', 'type': 'block', 'children': ['68', '79', '88', '128', '138', '154', '161', '177', '190', '198', '203']}; {'id': '68', 'type': 'if_statement', 'children': ['69', '77']}, {'id': '69', 'type': 'not_operator', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}, {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '73', 'type': 'identifier', 'children': [], 'value': '_check_rule'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'rule'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'depinfo'}, {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'continue_statement', 'children': []}, {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '82']}, {'id': '81', 'type': 'identifier', 'children': [], 'value': 'resolver'}; {'id': '82', 'type': 'call', 'children': ['83', '86']}, {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '85', 'type': 'identifier', 'children': [], 'value': '_find_resolver'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'rule'}; {'id': '88', 'type': 'if_statement', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'has_version'}; {'id': '90', 'type': 'block', 'children': ['91', '98', '109']}, {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'deptile'}; {'id': '94', 'type': 'call', 'children': ['95', '96']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'IOTile'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'destdir'}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}, {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'depstatus'}, {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': '_check_dep'}, {'id': '105', 'type': 'argument_list', 'children': ['106', '107', '108']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'depinfo'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'deptile'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'resolver'}, {'id': '109', 'type': 'if_statement', 'children': ['110', '113', '125']}; {'id': '110', 'type': 'comparison_operator', 'children': ['111', '112'], 'value': 'is'}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'depstatus'}; {'id': '112', 'type': 'False', 'children': []}, {'id': '113', 'type': 'block', 'children': ['114', '121']}; {'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': 'shutil'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'rmtree'}, {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'destdir'}, {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'assignment', 'children': ['123', '124']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'has_version'}; {'id': '124', 'type': 'False', 'children': []}, {'id': '125', 'type': 'else_clause', 'children': ['126']}; {'id': '126', 'type': 'block', 'children': ['127']}, {'id': '127', 'type': 'continue_statement', 'children': []}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}, {'id': '129', 'type': 'assignment', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}, {'id': '133', 'type': 'identifier', 'children': [], 'value': 'resolver'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'resolve'}, {'id': '135', 'type': 'argument_list', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'depinfo'}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'destdir'}; {'id': '138', 'type': 'if_statement', 'children': ['139', '151']}, {'id': '139', 'type': 'boolean_operator', 'children': ['140', '144'], 'value': 'and'}; {'id': '140', 'type': 'not_operator', 'children': ['141']}, {'id': '141', 'type': 'subscript', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '143', 'type': 'string', 'children': [], 'value': "'found'"}; {'id': '144', 'type': 'call', 'children': ['145', '148']}, {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '148', 'type': 'argument_list', 'children': ['149', '150']}, {'id': '149', 'type': 'string', 'children': [], 'value': "'stop'"}; {'id': '150', 'type': 'False', 'children': []}, {'id': '151', 'type': 'block', 'children': ['152']}; {'id': '152', 'type': 'return_statement', 'children': ['153']}, {'id': '153', 'type': 'string', 'children': [], 'value': "'not found'"}; {'id': '154', 'type': 'if_statement', 'children': ['155', '159']}, {'id': '155', 'type': 'not_operator', 'children': ['156']}; {'id': '156', 'type': 'subscript', 'children': ['157', '158']}, {'id': '157', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '158', 'type': 'string', 'children': [], 'value': "'found'"}, {'id': '159', 'type': 'block', 'children': ['160']}; {'id': '160', 'type': 'continue_statement', 'children': []}, {'id': '161', 'type': 'expression_statement', 'children': ['162']}; {'id': '162', 'type': 'assignment', 'children': ['163', '164']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '164', 'type': 'dictionary', 'children': ['165', '172']}, {'id': '165', 'type': 'pair', 'children': ['166', '167']}; {'id': '166', 'type': 'string', 'children': [], 'value': "'resolver'"}, {'id': '167', 'type': 'attribute', 'children': ['168', '171']}; {'id': '168', 'type': 'attribute', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'resolver'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': '__class__'}, {'id': '171', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '172', 'type': 'pair', 'children': ['173', '174']}, {'id': '173', 'type': 'string', 'children': [], 'value': "'factory_args'"}; {'id': '174', 'type': 'subscript', 'children': ['175', '176']}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'rule'}; {'id': '176', 'type': 'integer', 'children': [], 'value': '2'}, {'id': '177', 'type': 'if_statement', 'children': ['178', '181']}; {'id': '178', 'type': 'comparison_operator', 'children': ['179', '180'], 'value': 'in'}, {'id': '179', 'type': 'string', 'children': [], 'value': "'settings'"}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '181', 'type': 'block', 'children': ['182']}; {'id': '182', 'type': 'expression_statement', 'children': ['183']}, {'id': '183', 'type': 'assignment', 'children': ['184', '187']}; {'id': '184', 'type': 'subscript', 'children': ['185', '186']}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '186', 'type': 'string', 'children': [], 'value': "'settings'"}, {'id': '187', 'type': 'subscript', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '189', 'type': 'string', 'children': [], 'value': "'settings'"}; {'id': '190', 'type': 'expression_statement', 'children': ['191']}, {'id': '191', 'type': 'call', 'children': ['192', '195']}; {'id': '192', 'type': 'attribute', 'children': ['193', '194']}, {'id': '193', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '194', 'type': 'identifier', 'children': [], 'value': '_save_depsettings'}, {'id': '195', 'type': 'argument_list', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'destdir'}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '198', 'type': 'if_statement', 'children': ['199', '200']}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'had_version'}; {'id': '200', 'type': 'block', 'children': ['201']}, {'id': '201', 'type': 'return_statement', 'children': ['202']}; {'id': '202', 'type': 'string', 'children': [], 'value': '"updated"'}, {'id': '203', 'type': 'return_statement', 'children': ['204']}; {'id': '204', 'type': 'string', 'children': [], 'value': '"installed"'}, {'id': '205', 'type': 'if_statement', 'children': ['206', '207']}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'has_version'}, {'id': '207', 'type': 'block', 'children': ['208']}; {'id': '208', 'type': 'return_statement', 'children': ['209']}, {'id': '209', 'type': 'string', 'children': [], 'value': '"already installed"'}; {'id': '210', 'type': 'return_statement', 'children': ['211']}, {'id': '211', 'type': 'string', 'children': [], 'value': '"not found"'}
def update_dependency(self, tile, depinfo, destdir=None): if destdir is None: destdir = os.path.join(tile.folder, 'build', 'deps', depinfo['unique_id']) has_version = False had_version = False if os.path.exists(destdir): has_version = True had_version = True for priority, rule in self.rules: if not self._check_rule(rule, depinfo): continue resolver = self._find_resolver(rule) if has_version: deptile = IOTile(destdir) depstatus = self._check_dep(depinfo, deptile, resolver) if depstatus is False: shutil.rmtree(destdir) has_version = False else: continue result = resolver.resolve(depinfo, destdir) if not result['found'] and result.get('stop', False): return 'not found' if not result['found']: continue settings = { 'resolver': resolver.__class__.__name__, 'factory_args': rule[2] } if 'settings' in result: settings['settings'] = result['settings'] self._save_depsettings(destdir, settings) if had_version: return "updated" return "installed" if has_version: return "already installed" return "not found"
{'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', '12', '24', '82', '86', '102', '116', '129', '133']}; {'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': 'stopped'}; {'id': '10', 'type': 'block', 'children': ['11']}, {'id': '11', 'type': 'return_statement', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}, {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}, {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '17', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'debug'}, {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"Stopping task %s"'}, {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '30', '67']}, {'id': '25', 'type': 'comparison_operator', 'children': ['26', '29'], 'value': 'is'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_finalizer'}, {'id': '29', 'type': 'None', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31']}, {'id': '31', 'type': 'try_statement', 'children': ['32', '53']}; {'id': '32', 'type': 'block', 'children': ['33', '42']}, {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}, {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '39', 'type': 'identifier', 'children': [], 'value': '_finalizer'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '49']}, {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'inspect'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'isawaitable'}, {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}, {'id': '51', 'type': 'await', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'result'}, {'id': '53', 'type': 'except_clause', 'children': ['54']}; {'id': '54', 'type': 'block', 'children': ['55']}, {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '62']}, {'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': '_logger'}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'exception'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}, {'id': '63', 'type': 'string', 'children': [], 'value': '"Error running finalizer for task %s"'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'name'}, {'id': '67', 'type': 'elif_clause', 'children': ['68', '73']}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '72'], 'value': 'is'}, {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '72', 'type': 'None', 'children': []}, {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}, {'id': '75', 'type': 'call', 'children': ['76', '81']}; {'id': '76', 'type': 'attribute', 'children': ['77', '80']}, {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'cancel'}, {'id': '81', 'type': 'argument_list', 'children': []}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}, {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'tasks'}, {'id': '85', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '86', 'type': 'if_statement', 'children': ['87', '92']}, {'id': '87', 'type': 'comparison_operator', 'children': ['88', '91'], 'value': 'is'}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'task'}, {'id': '91', 'type': 'None', 'children': []}; {'id': '92', 'type': 'block', 'children': ['93']}, {'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': 'tasks'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}, {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}, {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}, {'id': '105', 'type': 'identifier', 'children': [], 'value': 'tasks'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'extend'}, {'id': '107', 'type': 'generator_expression', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'task'}, {'id': '111', 'type': 'for_in_clause', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'x'}, {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'subtasks'}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}, {'id': '117', 'type': 'assignment', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'finished'}, {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'asyncio'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'gather'}, {'id': '123', 'type': 'argument_list', 'children': ['124', '126']}; {'id': '124', 'type': 'list_splat', 'children': ['125']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'tasks'}; {'id': '126', 'type': 'keyword_argument', 'children': ['127', '128']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'return_exceptions'}; {'id': '128', 'type': 'True', 'children': []}, {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'assignment', 'children': ['131', '132']}, {'id': '131', 'type': 'identifier', 'children': [], 'value': 'outcomes'}; {'id': '132', 'type': 'list', 'children': [], 'value': '[]'}, {'id': '133', 'type': 'try_statement', 'children': ['134', '150', '173']}; {'id': '134', 'type': 'block', 'children': ['135']}, {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'assignment', 'children': ['137', '138']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'outcomes'}; {'id': '138', 'type': 'await', 'children': ['139']}, {'id': '139', 'type': 'call', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'asyncio'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'wait_for'}, {'id': '143', 'type': 'argument_list', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'finished'}, {'id': '145', 'type': 'keyword_argument', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'timeout'}, {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '149', 'type': 'identifier', 'children': [], 'value': '_stop_timeout'}; {'id': '150', 'type': 'except_clause', 'children': ['151', '157']}, {'id': '151', 'type': 'as_pattern', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'asyncio'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'TimeoutError'}, {'id': '155', 'type': 'as_pattern_target', 'children': ['156']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'err'}, {'id': '157', 'type': 'block', 'children': ['158', '171']}; {'id': '158', 'type': 'try_statement', 'children': ['159', '165']}, {'id': '159', 'type': 'block', 'children': ['160']}; {'id': '160', 'type': 'expression_statement', 'children': ['161']}, {'id': '161', 'type': 'assignment', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'outcomes'}, {'id': '163', 'type': 'await', 'children': ['164']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'finished'}, {'id': '165', 'type': 'except_clause', 'children': ['166', '169']}; {'id': '166', 'type': 'attribute', 'children': ['167', '168']}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'asyncio'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'CancelledError'}, {'id': '169', 'type': 'block', 'children': ['170']}; {'id': '170', 'type': 'pass_statement', 'children': []}, {'id': '171', 'type': 'raise_statement', 'children': ['172']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'err'}, {'id': '173', 'type': 'finally_clause', 'children': ['174']}; {'id': '174', 'type': 'block', 'children': ['175', '181', '210']}, {'id': '175', 'type': 'expression_statement', 'children': ['176']}; {'id': '176', 'type': 'assignment', 'children': ['177', '180']}, {'id': '177', 'type': 'attribute', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'stopped'}; {'id': '180', 'type': 'True', 'children': []}, {'id': '181', 'type': 'for_statement', 'children': ['182', '183', '184']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'outcome'}, {'id': '183', 'type': 'identifier', 'children': [], 'value': 'outcomes'}; {'id': '184', 'type': 'block', 'children': ['185']}, {'id': '185', 'type': 'if_statement', 'children': ['186', '200']}; {'id': '186', 'type': 'boolean_operator', 'children': ['187', '192'], 'value': 'and'}, {'id': '187', 'type': 'call', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'isinstance'}, {'id': '189', 'type': 'argument_list', 'children': ['190', '191']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'outcome'}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '192', 'type': 'not_operator', 'children': ['193']}, {'id': '193', 'type': 'call', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'isinstance'}, {'id': '195', 'type': 'argument_list', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'outcome'}, {'id': '197', 'type': 'attribute', 'children': ['198', '199']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'asyncio'}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'CancelledError'}; {'id': '200', 'type': 'block', 'children': ['201']}, {'id': '201', 'type': 'expression_statement', 'children': ['202']}; {'id': '202', 'type': 'call', 'children': ['203', '208']}, {'id': '203', 'type': 'attribute', 'children': ['204', '207']}; {'id': '204', 'type': 'attribute', 'children': ['205', '206']}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '206', 'type': 'identifier', 'children': [], 'value': '_logger'}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '208', 'type': 'argument_list', 'children': ['209']}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'outcome'}; {'id': '210', 'type': 'if_statement', 'children': ['211', '218']}, {'id': '211', 'type': 'comparison_operator', 'children': ['212', '213'], 'value': 'in'}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '213', 'type': 'attribute', 'children': ['214', '217']}; {'id': '214', 'type': 'attribute', 'children': ['215', '216']}, {'id': '215', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '216', 'type': 'identifier', 'children': [], 'value': '_loop'}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'tasks'}; {'id': '218', 'type': 'block', 'children': ['219']}, {'id': '219', 'type': 'expression_statement', 'children': ['220']}; {'id': '220', 'type': 'call', 'children': ['221', '228']}, {'id': '221', 'type': 'attribute', 'children': ['222', '227']}; {'id': '222', 'type': 'attribute', 'children': ['223', '226']}, {'id': '223', 'type': 'attribute', 'children': ['224', '225']}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id': '225', 'type': 'identifier', 'children': [], 'value': '_loop'}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'tasks'}, {'id': '227', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '228', 'type': 'argument_list', 'children': ['229']}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'self'}
async def stop(self): if self.stopped: return self._logger.debug("Stopping task %s", self.name) if self._finalizer is not None: try: result = self._finalizer(self) if inspect.isawaitable(result): await result except: self._logger.exception("Error running finalizer for task %s", self.name) elif self.task is not None: self.task.cancel() tasks = [] if self.task is not None: tasks.append(self.task) tasks.extend(x.task for x in self.subtasks) finished = asyncio.gather(*tasks, return_exceptions=True) outcomes = [] try: outcomes = await asyncio.wait_for(finished, timeout=self._stop_timeout) except asyncio.TimeoutError as err: try: outcomes = await finished except asyncio.CancelledError: pass raise err finally: self.stopped = True for outcome in outcomes: if isinstance(outcome, Exception) and not isinstance(outcome, asyncio.CancelledError): self._logger.error(outcome) if self in self._loop.tasks: self._loop.tasks.remove(self)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'link_cloud'}, {'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': 'username'}, {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}, {'id': '9', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '10', 'type': 'None', 'children': []}, {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'device_id'}, {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '21', '30', '46', '64', '73', '87', '98', '108', '118', '128']}, {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'reg'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ComponentRegistry'}; {'id': '20', 'type': 'argument_list', 'children': []}, {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'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'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}, {'id': '29', 'type': 'string', 'children': [], 'value': "'cloud:server'"}; {'id': '30', 'type': 'if_statement', 'children': ['31', '34']}, {'id': '31', 'type': 'comparison_operator', 'children': ['32', '33'], 'value': 'is'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'username'}, {'id': '33', 'type': 'None', 'children': []}; {'id': '34', 'type': 'block', 'children': ['35', '39']}, {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'prompt_str'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"Please enter your IOTile.cloud email: "'}, {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'input'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'prompt_str'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '50']}, {'id': '47', 'type': 'comparison_operator', 'children': ['48', '49'], 'value': 'is'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'password'}, {'id': '49', 'type': 'None', 'children': []}; {'id': '50', 'type': 'block', 'children': ['51', '55']}, {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}, {'id': '53', 'type': 'identifier', 'children': [], 'value': 'prompt_str'}; {'id': '54', 'type': 'string', 'children': [], 'value': '"Please enter your IOTile.cloud password: "'}, {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '58', 'type': 'call', 'children': ['59', '62']}, {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'getpass'}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'getpass'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}, {'id': '63', 'type': 'identifier', 'children': [], 'value': 'prompt_str'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}, {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'cloud'}, {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'Api'}, {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'keyword_argument', 'children': ['71', '72']}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'domain'}, {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'ok_resp'}; {'id': '76', 'type': 'call', 'children': ['77', '80']}, {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'cloud'}, {'id': '79', 'type': 'identifier', 'children': [], 'value': 'login'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '84']}, {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'email'}, {'id': '83', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '84', 'type': 'keyword_argument', 'children': ['85', '86']}, {'id': '85', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'password'}, {'id': '87', 'type': 'if_statement', 'children': ['88', '90']}; {'id': '88', 'type': 'not_operator', 'children': ['89']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'ok_resp'}; {'id': '90', 'type': 'block', 'children': ['91']}, {'id': '91', 'type': 'raise_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}, {'id': '95', 'type': 'binary_operator', 'children': ['96', '97'], 'value': '%'}; {'id': '96', 'type': 'string', 'children': [], 'value': '"Could not login to iotile.cloud as user %s"'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}, {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}, {'id': '101', 'type': 'identifier', 'children': [], 'value': 'reg'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'set_config'}, {'id': '103', 'type': 'argument_list', 'children': ['104', '105']}; {'id': '104', 'type': 'string', 'children': [], 'value': "'arch:cloud_user'"}, {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'cloud'}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}, {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'reg'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'set_config'}, {'id': '113', 'type': 'argument_list', 'children': ['114', '115']}; {'id': '114', 'type': 'string', 'children': [], 'value': "'arch:cloud_token'"}, {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'cloud'}, {'id': '117', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}, {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'reg'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'set_config'}, {'id': '123', 'type': 'argument_list', 'children': ['124', '125']}; {'id': '124', 'type': 'string', 'children': [], 'value': "'arch:cloud_token_type'"}, {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'cloud'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'token_type'}; {'id': '128', 'type': 'if_statement', 'children': ['129', '132']}, {'id': '129', 'type': 'comparison_operator', 'children': ['130', '131'], 'value': 'is'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'device_id'}, {'id': '131', 'type': 'None', 'children': []}; {'id': '132', 'type': 'block', 'children': ['133', '139']}, {'id': '133', 'type': 'expression_statement', 'children': ['134']}; {'id': '134', 'type': 'assignment', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'cloud'}; {'id': '136', 'type': 'call', 'children': ['137', '138']}, {'id': '137', 'type': 'identifier', 'children': [], 'value': 'IOTileCloud'}; {'id': '138', 'type': 'argument_list', 'children': []}, {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'call', 'children': ['141', '144']}, {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'cloud'}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'impersonate_device'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'device_id'}
def link_cloud(self, username=None, password=None, device_id=None): reg = ComponentRegistry() domain = self.get('cloud:server') if username is None: prompt_str = "Please enter your IOTile.cloud email: " username = input(prompt_str) if password is None: prompt_str = "Please enter your IOTile.cloud password: " password = getpass.getpass(prompt_str) cloud = Api(domain=domain) ok_resp = cloud.login(email=username, password=password) if not ok_resp: raise ArgumentError("Could not login to iotile.cloud as user %s" % username) reg.set_config('arch:cloud_user', cloud.username) reg.set_config('arch:cloud_token', cloud.token) reg.set_config('arch:cloud_token_type', cloud.token_type) if device_id is not None: cloud = IOTileCloud() cloud.impersonate_device(device_id)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '6', 'type': 'None', 'children': []}, {'id': '7', 'type': 'block', 'children': ['8', '23', '297']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12']}, {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'is'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'argv'}, {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}, {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}, {'id': '15', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '16', 'type': 'subscript', 'children': ['17', '20']}, {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'sys'}, {'id': '19', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '20', 'type': 'slice', 'children': ['21', '22']}, {'id': '21', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '22', 'type': 'colon', 'children': []}, {'id': '23', 'type': 'try_statement', 'children': ['24', '282']}; {'id': '24', 'type': 'block', 'children': ['25', '29', '35', '46', '52', '58', '67', '74', '98', '104', '111', '124', '149', '174', '201', '214', '220', '233', '264']}, {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}, {'id': '27', 'type': 'identifier', 'children': [], 'value': 'executor'}; {'id': '28', 'type': 'None', 'children': []}, {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}, {'id': '31', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'build_args'}; {'id': '34', 'type': 'argument_list', 'children': []}, {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}, {'id': '37', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}, {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'parser'}, {'id': '41', 'type': 'identifier', 'children': [], 'value': 'parse_args'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}, {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '45', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}, {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'model'}, {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'DeviceModel'}, {'id': '51', 'type': 'argument_list', 'children': []}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}, {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'parser'}, {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'SensorGraphFileParser'}, {'id': '57', 'type': 'argument_list', 'children': []}; {'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': 'parser'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'parse_file'}, {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}, {'id': '65', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'sensor_graph'}, {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '72']}, {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'parser'}, {'id': '71', 'type': 'identifier', 'children': [], 'value': 'compile'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '74', 'type': 'if_statement', 'children': ['75', '79']}, {'id': '75', 'type': 'not_operator', 'children': ['76']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'disable_optimizer'}, {'id': '79', 'type': 'block', 'children': ['80', '86']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}, {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'opt'}, {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'SensorGraphOptimizer'}, {'id': '85', 'type': 'argument_list', 'children': []}; {'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': 'opt'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'optimize'}, {'id': '91', 'type': 'argument_list', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}, {'id': '93', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'sensor_graph'}, {'id': '95', 'type': 'keyword_argument', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'model'}, {'id': '97', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}, {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'graph'}, {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'parser'}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'sensor_graph'}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}, {'id': '105', 'type': 'assignment', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'sim'}, {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'SensorGraphSimulator'}, {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'graph'}, {'id': '111', 'type': 'for_statement', 'children': ['112', '113', '116']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'stop'}, {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '116', 'type': 'block', 'children': ['117']}, {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'call', 'children': ['119', '122']}, {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'sim'}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'stop_condition'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}, {'id': '123', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '124', 'type': 'for_statement', 'children': ['125', '126', '129']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'watch'}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'watch'}, {'id': '129', 'type': 'block', 'children': ['130', '139']}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}, {'id': '131', 'type': 'assignment', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'watch_sel'}, {'id': '133', 'type': 'call', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'DataStreamSelector'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'FromString'}, {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'watch'}, {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'call', 'children': ['141', '146']}, {'id': '141', 'type': 'attribute', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}, {'id': '143', 'type': 'identifier', 'children': [], 'value': 'graph'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'sensor_log'}, {'id': '145', 'type': 'identifier', 'children': [], 'value': 'watch'}; {'id': '146', 'type': 'argument_list', 'children': ['147', '148']}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'watch_sel'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'watch_printer'}, {'id': '149', 'type': 'if_statement', 'children': ['150', '155']}; {'id': '150', 'type': 'comparison_operator', 'children': ['151', '154'], 'value': 'is'}, {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'semihost_device'}; {'id': '154', 'type': 'None', 'children': []}, {'id': '155', 'type': 'block', 'children': ['156', '168']}; {'id': '156', 'type': 'expression_statement', 'children': ['157']}, {'id': '157', 'type': 'assignment', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'executor'}, {'id': '159', 'type': 'call', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'SemihostedRPCExecutor'}, {'id': '161', 'type': 'argument_list', 'children': ['162', '165']}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}, {'id': '163', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'port'}, {'id': '165', 'type': 'attribute', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '167', 'type': 'identifier', 'children': [], 'value': 'semihost_device'}; {'id': '168', 'type': 'expression_statement', 'children': ['169']}, {'id': '169', 'type': 'assignment', 'children': ['170', '173']}; {'id': '170', 'type': 'attribute', 'children': ['171', '172']}, {'id': '171', 'type': 'identifier', 'children': [], 'value': 'sim'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'rpc_executor'}, {'id': '173', 'type': 'identifier', 'children': [], 'value': 'executor'}; {'id': '174', 'type': 'for_statement', 'children': ['175', '176', '179']}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'mock'}; {'id': '176', 'type': 'attribute', 'children': ['177', '178']}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'mock_rpc'}, {'id': '179', 'type': 'block', 'children': ['180', '190']}; {'id': '180', 'type': 'expression_statement', 'children': ['181']}, {'id': '181', 'type': 'assignment', 'children': ['182', '186']}; {'id': '182', 'type': 'pattern_list', 'children': ['183', '184', '185']}, {'id': '183', 'type': 'identifier', 'children': [], 'value': 'slot'}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'rpc_id'}, {'id': '185', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '186', 'type': 'call', 'children': ['187', '188']}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'process_mock_rpc'}; {'id': '188', 'type': 'argument_list', 'children': ['189']}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'mock'}; {'id': '190', 'type': 'expression_statement', 'children': ['191']}, {'id': '191', 'type': 'call', 'children': ['192', '197']}; {'id': '192', 'type': 'attribute', 'children': ['193', '196']}, {'id': '193', 'type': 'attribute', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'sim'}, {'id': '195', 'type': 'identifier', 'children': [], 'value': 'rpc_executor'}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'mock'}, {'id': '197', 'type': 'argument_list', 'children': ['198', '199', '200']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'slot'}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'rpc_id'}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'value'}, {'id': '201', 'type': 'for_statement', 'children': ['202', '203', '206']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'stim'}, {'id': '203', 'type': 'attribute', 'children': ['204', '205']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '205', 'type': 'identifier', 'children': [], 'value': 'stimulus'}; {'id': '206', 'type': 'block', 'children': ['207']}, {'id': '207', 'type': 'expression_statement', 'children': ['208']}; {'id': '208', 'type': 'call', 'children': ['209', '212']}, {'id': '209', 'type': 'attribute', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'sim'}, {'id': '211', 'type': 'identifier', 'children': [], 'value': 'stimulus'}; {'id': '212', 'type': 'argument_list', 'children': ['213']}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'stim'}; {'id': '214', 'type': 'expression_statement', 'children': ['215']}, {'id': '215', 'type': 'call', 'children': ['216', '219']}; {'id': '216', 'type': 'attribute', 'children': ['217', '218']}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'graph'}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'load_constants'}, {'id': '219', 'type': 'argument_list', 'children': []}; {'id': '220', 'type': 'if_statement', 'children': ['221', '226']}, {'id': '221', 'type': 'comparison_operator', 'children': ['222', '225'], 'value': 'is'}; {'id': '222', 'type': 'attribute', 'children': ['223', '224']}, {'id': '223', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'trace'}, {'id': '225', 'type': 'None', 'children': []}; {'id': '226', 'type': 'block', 'children': ['227']}, {'id': '227', 'type': 'expression_statement', 'children': ['228']}; {'id': '228', 'type': 'call', 'children': ['229', '232']}, {'id': '229', 'type': 'attribute', 'children': ['230', '231']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'sim'}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'record_trace'}; {'id': '232', 'type': 'argument_list', 'children': []}, {'id': '233', 'type': 'try_statement', 'children': ['234', '260']}; {'id': '234', 'type': 'block', 'children': ['235', '248']}, {'id': '235', 'type': 'if_statement', 'children': ['236', '239']}; {'id': '236', 'type': 'attribute', 'children': ['237', '238']}, {'id': '237', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'connected'}, {'id': '239', 'type': 'block', 'children': ['240']}; {'id': '240', 'type': 'expression_statement', 'children': ['241']}, {'id': '241', 'type': 'call', 'children': ['242', '245']}; {'id': '242', 'type': 'attribute', 'children': ['243', '244']}, {'id': '243', 'type': 'identifier', 'children': [], 'value': 'sim'}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'step'}, {'id': '245', 'type': 'argument_list', 'children': ['246', '247']}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'user_connected'}, {'id': '247', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '248', 'type': 'expression_statement', 'children': ['249']}, {'id': '249', 'type': 'call', 'children': ['250', '253']}; {'id': '250', 'type': 'attribute', 'children': ['251', '252']}, {'id': '251', 'type': 'identifier', 'children': [], 'value': 'sim'}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'run'}, {'id': '253', 'type': 'argument_list', 'children': ['254']}; {'id': '254', 'type': 'keyword_argument', 'children': ['255', '256']}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'accelerated'}; {'id': '256', 'type': 'not_operator', 'children': ['257']}, {'id': '257', 'type': 'attribute', 'children': ['258', '259']}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '259', 'type': 'identifier', 'children': [], 'value': 'realtime'}; {'id': '260', 'type': 'except_clause', 'children': ['261', '262']}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 'KeyboardInterrupt'}; {'id': '262', 'type': 'block', 'children': ['263']}, {'id': '263', 'type': 'pass_statement', 'children': []}; {'id': '264', 'type': 'if_statement', 'children': ['265', '270']}, {'id': '265', 'type': 'comparison_operator', 'children': ['266', '269'], 'value': 'is'}; {'id': '266', 'type': 'attribute', 'children': ['267', '268']}, {'id': '267', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'trace'}, {'id': '269', 'type': 'None', 'children': []}; {'id': '270', 'type': 'block', 'children': ['271']}, {'id': '271', 'type': 'expression_statement', 'children': ['272']}; {'id': '272', 'type': 'call', 'children': ['273', '278']}, {'id': '273', 'type': 'attribute', 'children': ['274', '277']}; {'id': '274', 'type': 'attribute', 'children': ['275', '276']}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 'sim'}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'trace'}, {'id': '277', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '278', 'type': 'argument_list', 'children': ['279']}, {'id': '279', 'type': 'attribute', 'children': ['280', '281']}; {'id': '280', 'type': 'identifier', 'children': [], 'value': 'args'}, {'id': '281', 'type': 'identifier', 'children': [], 'value': 'trace'}; {'id': '282', 'type': 'finally_clause', 'children': ['283']}, {'id': '283', 'type': 'block', 'children': ['284']}; {'id': '284', 'type': 'if_statement', 'children': ['285', '288']}, {'id': '285', 'type': 'comparison_operator', 'children': ['286', '287'], 'value': 'is'}; {'id': '286', 'type': 'identifier', 'children': [], 'value': 'executor'}, {'id': '287', 'type': 'None', 'children': []}; {'id': '288', 'type': 'block', 'children': ['289']}, {'id': '289', 'type': 'expression_statement', 'children': ['290']}; {'id': '290', 'type': 'call', 'children': ['291', '296']}, {'id': '291', 'type': 'attribute', 'children': ['292', '295']}; {'id': '292', 'type': 'attribute', 'children': ['293', '294']}, {'id': '293', 'type': 'identifier', 'children': [], 'value': 'executor'}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'hw'}, {'id': '295', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '296', 'type': 'argument_list', 'children': []}, {'id': '297', 'type': 'return_statement', 'children': ['298']}
def main(argv=None): if argv is None: argv = sys.argv[1:] try: executor = None parser = build_args() args = parser.parse_args(args=argv) model = DeviceModel() parser = SensorGraphFileParser() parser.parse_file(args.sensor_graph) parser.compile(model) if not args.disable_optimizer: opt = SensorGraphOptimizer() opt.optimize(parser.sensor_graph, model=model) graph = parser.sensor_graph sim = SensorGraphSimulator(graph) for stop in args.stop: sim.stop_condition(stop) for watch in args.watch: watch_sel = DataStreamSelector.FromString(watch) graph.sensor_log.watch(watch_sel, watch_printer) if args.semihost_device is not None: executor = SemihostedRPCExecutor(args.port, args.semihost_device) sim.rpc_executor = executor for mock in args.mock_rpc: slot, rpc_id, value = process_mock_rpc(mock) sim.rpc_executor.mock(slot, rpc_id, value) for stim in args.stimulus: sim.stimulus(stim) graph.load_constants() if args.trace is not None: sim.record_trace() try: if args.connected: sim.step(user_connected, 8) sim.run(accelerated=not args.realtime) except KeyboardInterrupt: pass if args.trace is not None: sim.trace.save(args.trace) finally: if executor is not None: executor.hw.close() return 0
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_pot_file'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '5', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '7', 'type': 'block', 'children': ['8', '11', '14', '18', '27', '37', '45', '53', '64', '81', '91', '166', '183', '193', '200', '205', '211', '312']}; {'id': '8', 'type': 'import_statement', 'children': ['9']}, {'id': '9', 'type': 'dotted_name', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 're'}, {'id': '11', 'type': 'import_statement', 'children': ['12']}; {'id': '12', 'type': 'dotted_name', 'children': ['13']}, {'id': '13', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '14', 'type': 'import_statement', 'children': ['15']}, {'id': '15', 'type': 'dotted_name', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Action'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}, {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'nop'}, {'id': '21', 'type': 'lambda', 'children': ['22', '26']}; {'id': '22', 'type': 'lambda_parameters', 'children': ['23', '24', '25']}, {'id': '23', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'source'}, {'id': '25', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}, {'id': '29', 'type': 'identifier', 'children': [], 'value': 'save_cwd'}; {'id': '30', 'type': 'call', 'children': ['31', '36']}, {'id': '31', 'type': 'attribute', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}, {'id': '33', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'fs'}, {'id': '35', 'type': 'identifier', 'children': [], 'value': 'getcwd'}; {'id': '36', 'type': 'argument_list', 'children': []}, {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}, {'id': '39', 'type': 'identifier', 'children': [], 'value': 'save_os_cwd'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}, {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '43', 'type': 'identifier', 'children': [], 'value': 'getcwd'}; {'id': '44', 'type': 'argument_list', 'children': []}, {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}, {'id': '47', 'type': 'identifier', 'children': [], 'value': 'chdir'}; {'id': '48', 'type': 'attribute', 'children': ['49', '52']}, {'id': '49', 'type': 'subscript', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '51', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'dir'}, {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}, {'id': '55', 'type': 'identifier', 'children': [], 'value': 'chdir_str'}; {'id': '56', 'type': 'call', 'children': ['57', '58']}, {'id': '57', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}, {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}, {'id': '61', 'type': 'identifier', 'children': [], 'value': 'chdir'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'get_abspath'}, {'id': '63', 'type': 'argument_list', 'children': []}; {'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': 'env'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'Execute'}, {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '76']}, {'id': '71', 'type': 'attribute', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}, {'id': '73', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'Action'}, {'id': '75', 'type': 'identifier', 'children': [], 'value': 'Action'}; {'id': '76', 'type': 'argument_list', 'children': ['77', '78']}, {'id': '77', 'type': 'identifier', 'children': [], 'value': 'nop'}; {'id': '78', 'type': 'binary_operator', 'children': ['79', '80'], 'value': '+'}, {'id': '79', 'type': 'string', 'children': [], 'value': '"Entering "'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'chdir_str'}, {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'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': 'env'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'fs'}, {'id': '87', 'type': 'identifier', 'children': [], 'value': 'chdir'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '90']}, {'id': '89', 'type': 'identifier', 'children': [], 'value': 'chdir'}; {'id': '90', 'type': 'integer', 'children': [], 'value': '1'}, {'id': '91', 'type': 'try_statement', 'children': ['92', '129']}; {'id': '92', 'type': 'block', 'children': ['93', '101', '117']}, {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}, {'id': '95', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '96', 'type': 'call', 'children': ['97', '98']}, {'id': '97', 'type': 'identifier', 'children': [], 'value': '_CmdRunner'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100']}, {'id': '99', 'type': 'string', 'children': [], 'value': "'$XGETTEXTCOM'"}; {'id': '100', 'type': 'string', 'children': [], 'value': "'$XGETTEXTCOMSTR'"}, {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '104']}, {'id': '103', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '104', 'type': 'call', 'children': ['105', '110']}, {'id': '105', 'type': 'attribute', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}, {'id': '107', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'Action'}, {'id': '109', 'type': 'identifier', 'children': [], 'value': 'Action'}; {'id': '110', 'type': 'argument_list', 'children': ['111', '112']}, {'id': '111', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '112', 'type': 'keyword_argument', 'children': ['113', '114']}, {'id': '113', 'type': 'identifier', 'children': [], 'value': 'strfunction'}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}, {'id': '115', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'strfunction'}, {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'assignment', 'children': ['119', '120']}, {'id': '119', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '120', 'type': 'call', 'children': ['121', '122']}, {'id': '121', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '122', 'type': 'argument_list', 'children': ['123', '127', '128']}, {'id': '123', 'type': 'list', 'children': ['124'], 'value': '[target[0]]'}; {'id': '124', 'type': 'subscript', 'children': ['125', '126']}, {'id': '125', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '126', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '127', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '129', 'type': 'except_clause', 'children': ['130']}; {'id': '130', 'type': 'block', 'children': ['131', '148', '158', '165']}, {'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': 'env'}, {'id': '135', 'type': 'identifier', 'children': [], 'value': 'Execute'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}, {'id': '137', 'type': 'call', 'children': ['138', '143']}; {'id': '138', 'type': 'attribute', 'children': ['139', '142']}, {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '141', 'type': 'identifier', 'children': [], 'value': 'Action'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'Action'}, {'id': '143', 'type': 'argument_list', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'nop'}, {'id': '145', 'type': 'binary_operator', 'children': ['146', '147'], 'value': '+'}; {'id': '146', 'type': 'string', 'children': [], 'value': '"Leaving "'}, {'id': '147', 'type': 'identifier', 'children': [], 'value': 'chdir_str'}; {'id': '148', 'type': 'expression_statement', 'children': ['149']}, {'id': '149', 'type': 'call', 'children': ['150', '155']}; {'id': '150', 'type': 'attribute', 'children': ['151', '154']}, {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '153', 'type': 'identifier', 'children': [], 'value': 'fs'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'chdir'}, {'id': '155', 'type': 'argument_list', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'save_cwd'}, {'id': '157', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '158', 'type': 'expression_statement', 'children': ['159']}, {'id': '159', 'type': 'call', 'children': ['160', '163']}; {'id': '160', 'type': 'attribute', 'children': ['161', '162']}, {'id': '161', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'chdir'}, {'id': '163', 'type': 'argument_list', 'children': ['164']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'save_os_cwd'}, {'id': '165', 'type': 'raise_statement', 'children': []}; {'id': '166', 'type': 'expression_statement', 'children': ['167']}, {'id': '167', 'type': 'call', 'children': ['168', '171']}; {'id': '168', 'type': 'attribute', 'children': ['169', '170']}, {'id': '169', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'Execute'}, {'id': '171', 'type': 'argument_list', 'children': ['172']}; {'id': '172', 'type': 'call', 'children': ['173', '178']}, {'id': '173', 'type': 'attribute', 'children': ['174', '177']}; {'id': '174', 'type': 'attribute', 'children': ['175', '176']}, {'id': '175', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'Action'}, {'id': '177', 'type': 'identifier', 'children': [], 'value': 'Action'}; {'id': '178', 'type': 'argument_list', 'children': ['179', '180']}, {'id': '179', 'type': 'identifier', 'children': [], 'value': 'nop'}; {'id': '180', 'type': 'binary_operator', 'children': ['181', '182'], 'value': '+'}, {'id': '181', 'type': 'string', 'children': [], 'value': '"Leaving "'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'chdir_str'}, {'id': '183', 'type': 'expression_statement', 'children': ['184']}; {'id': '184', 'type': 'call', 'children': ['185', '190']}, {'id': '185', 'type': 'attribute', 'children': ['186', '189']}; {'id': '186', 'type': 'attribute', 'children': ['187', '188']}, {'id': '187', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'fs'}, {'id': '189', 'type': 'identifier', 'children': [], 'value': 'chdir'}; {'id': '190', 'type': 'argument_list', 'children': ['191', '192']}, {'id': '191', 'type': 'identifier', 'children': [], 'value': 'save_cwd'}; {'id': '192', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '193', 'type': 'expression_statement', 'children': ['194']}; {'id': '194', 'type': 'call', 'children': ['195', '198']}, {'id': '195', 'type': 'attribute', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'os'}, {'id': '197', 'type': 'identifier', 'children': [], 'value': 'chdir'}; {'id': '198', 'type': 'argument_list', 'children': ['199']}, {'id': '199', 'type': 'identifier', 'children': [], 'value': 'save_os_cwd'}; {'id': '200', 'type': 'if_statement', 'children': ['201', '202']}, {'id': '201', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '202', 'type': 'block', 'children': ['203']}, {'id': '203', 'type': 'return_statement', 'children': ['204']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'status'}, {'id': '205', 'type': 'expression_statement', 'children': ['206']}; {'id': '206', 'type': 'assignment', 'children': ['207', '208']}, {'id': '207', 'type': 'identifier', 'children': [], 'value': 'new_content'}; {'id': '208', 'type': 'attribute', 'children': ['209', '210']}, {'id': '209', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'out'}, {'id': '211', 'type': 'if_statement', 'children': ['212', '214', '223']}; {'id': '212', 'type': 'not_operator', 'children': ['213']}, {'id': '213', 'type': 'identifier', 'children': [], 'value': 'new_content'}; {'id': '214', 'type': 'block', 'children': ['215', '219']}, {'id': '215', 'type': 'expression_statement', 'children': ['216']}; {'id': '216', 'type': 'assignment', 'children': ['217', '218']}, {'id': '217', 'type': 'identifier', 'children': [], 'value': 'needs_update'}; {'id': '218', 'type': 'False', 'children': []}, {'id': '219', 'type': 'expression_statement', 'children': ['220']}; {'id': '220', 'type': 'assignment', 'children': ['221', '222']}, {'id': '221', 'type': 'identifier', 'children': [], 'value': 'explain'}; {'id': '222', 'type': 'string', 'children': [], 'value': '"no internationalized messages encountered"'}, {'id': '223', 'type': 'else_clause', 'children': ['224']}; {'id': '224', 'type': 'block', 'children': ['225']}, {'id': '225', 'type': 'if_statement', 'children': ['226', '233', '302']}; {'id': '226', 'type': 'call', 'children': ['227', '232']}, {'id': '227', 'type': 'attribute', 'children': ['228', '231']}; {'id': '228', 'type': 'subscript', 'children': ['229', '230']}, {'id': '229', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '230', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '231', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '232', 'type': 'argument_list', 'children': []}, {'id': '233', 'type': 'block', 'children': ['234', '244', '256', '267', '278']}; {'id': '234', 'type': 'expression_statement', 'children': ['235']}, {'id': '235', 'type': 'assignment', 'children': ['236', '237']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'old_content'}, {'id': '237', 'type': 'call', 'children': ['238', '243']}; {'id': '238', 'type': 'attribute', 'children': ['239', '242']}, {'id': '239', 'type': 'subscript', 'children': ['240', '241']}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '241', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'get_text_contents'}, {'id': '243', 'type': 'argument_list', 'children': []}; {'id': '244', 'type': 'expression_statement', 'children': ['245']}, {'id': '245', 'type': 'assignment', 'children': ['246', '247']}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 're_cdate'}, {'id': '247', 'type': 'call', 'children': ['248', '251']}; {'id': '248', 'type': 'attribute', 'children': ['249', '250']}, {'id': '249', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'compile'}, {'id': '251', 'type': 'argument_list', 'children': ['252', '253']}; {'id': '252', 'type': 'string', 'children': [], 'value': 'r\'^"POT-Creation-Date: .*"$[\\r\\n]?\''}, {'id': '253', 'type': 'attribute', 'children': ['254', '255']}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 're'}, {'id': '255', 'type': 'identifier', 'children': [], 'value': 'M'}; {'id': '256', 'type': 'expression_statement', 'children': ['257']}, {'id': '257', 'type': 'assignment', 'children': ['258', '259']}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'old_content_nocdate'}, {'id': '259', 'type': 'call', 'children': ['260', '263']}; {'id': '260', 'type': 'attribute', 'children': ['261', '262']}, {'id': '261', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '262', 'type': 'identifier', 'children': [], 'value': 'sub'}, {'id': '263', 'type': 'argument_list', 'children': ['264', '265', '266']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 're_cdate'}, {'id': '265', 'type': 'string', 'children': [], 'value': '""'}; {'id': '266', 'type': 'identifier', 'children': [], 'value': 'old_content'}, {'id': '267', 'type': 'expression_statement', 'children': ['268']}; {'id': '268', 'type': 'assignment', 'children': ['269', '270']}, {'id': '269', 'type': 'identifier', 'children': [], 'value': 'new_content_nocdate'}; {'id': '270', 'type': 'call', 'children': ['271', '274']}, {'id': '271', 'type': 'attribute', 'children': ['272', '273']}; {'id': '272', 'type': 'identifier', 'children': [], 'value': 're'}, {'id': '273', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '274', 'type': 'argument_list', 'children': ['275', '276', '277']}, {'id': '275', 'type': 'identifier', 'children': [], 'value': 're_cdate'}; {'id': '276', 'type': 'string', 'children': [], 'value': '""'}, {'id': '277', 'type': 'identifier', 'children': [], 'value': 'new_content'}; {'id': '278', 'type': 'if_statement', 'children': ['279', '283', '292']}, {'id': '279', 'type': 'parenthesized_expression', 'children': ['280']}; {'id': '280', 'type': 'comparison_operator', 'children': ['281', '282'], 'value': '=='}, {'id': '281', 'type': 'identifier', 'children': [], 'value': 'old_content_nocdate'}; {'id': '282', 'type': 'identifier', 'children': [], 'value': 'new_content_nocdate'}, {'id': '283', 'type': 'block', 'children': ['284', '288']}; {'id': '284', 'type': 'expression_statement', 'children': ['285']}, {'id': '285', 'type': 'assignment', 'children': ['286', '287']}; {'id': '286', 'type': 'identifier', 'children': [], 'value': 'needs_update'}, {'id': '287', 'type': 'False', 'children': []}; {'id': '288', 'type': 'expression_statement', 'children': ['289']}, {'id': '289', 'type': 'assignment', 'children': ['290', '291']}; {'id': '290', 'type': 'identifier', 'children': [], 'value': 'explain'}, {'id': '291', 'type': 'string', 'children': [], 'value': '"messages in file found to be up-to-date"'}; {'id': '292', 'type': 'else_clause', 'children': ['293']}, {'id': '293', 'type': 'block', 'children': ['294', '298']}; {'id': '294', 'type': 'expression_statement', 'children': ['295']}, {'id': '295', 'type': 'assignment', 'children': ['296', '297']}; {'id': '296', 'type': 'identifier', 'children': [], 'value': 'needs_update'}, {'id': '297', 'type': 'True', 'children': []}; {'id': '298', 'type': 'expression_statement', 'children': ['299']}, {'id': '299', 'type': 'assignment', 'children': ['300', '301']}; {'id': '300', 'type': 'identifier', 'children': [], 'value': 'explain'}, {'id': '301', 'type': 'string', 'children': [], 'value': '"messages in file were outdated"'}; {'id': '302', 'type': 'else_clause', 'children': ['303']}, {'id': '303', 'type': 'block', 'children': ['304', '308']}; {'id': '304', 'type': 'expression_statement', 'children': ['305']}, {'id': '305', 'type': 'assignment', 'children': ['306', '307']}; {'id': '306', 'type': 'identifier', 'children': [], 'value': 'needs_update'}, {'id': '307', 'type': 'True', 'children': []}; {'id': '308', 'type': 'expression_statement', 'children': ['309']}, {'id': '309', 'type': 'assignment', 'children': ['310', '311']}; {'id': '310', 'type': 'identifier', 'children': [], 'value': 'explain'}, {'id': '311', 'type': 'string', 'children': [], 'value': '"new file"'}; {'id': '312', 'type': 'if_statement', 'children': ['313', '314', '378']}, {'id': '313', 'type': 'identifier', 'children': [], 'value': 'needs_update'}; {'id': '314', 'type': 'block', 'children': ['315', '335', '350', '363', '370', '376']}, {'id': '315', 'type': 'expression_statement', 'children': ['316']}; {'id': '316', 'type': 'assignment', 'children': ['317', '318']}, {'id': '317', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '318', 'type': 'binary_operator', 'children': ['319', '334'], 'value': '+'}, {'id': '319', 'type': 'binary_operator', 'children': ['320', '333'], 'value': '+'}; {'id': '320', 'type': 'binary_operator', 'children': ['321', '332'], 'value': '+'}, {'id': '321', 'type': 'binary_operator', 'children': ['322', '323'], 'value': '+'}; {'id': '322', 'type': 'string', 'children': [], 'value': '"Writing "'}, {'id': '323', 'type': 'call', 'children': ['324', '325']}; {'id': '324', 'type': 'identifier', 'children': [], 'value': 'repr'}, {'id': '325', 'type': 'argument_list', 'children': ['326']}; {'id': '326', 'type': 'call', 'children': ['327', '328']}, {'id': '327', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '328', 'type': 'argument_list', 'children': ['329']}, {'id': '329', 'type': 'subscript', 'children': ['330', '331']}; {'id': '330', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '331', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '332', 'type': 'string', 'children': [], 'value': '" ("'}, {'id': '333', 'type': 'identifier', 'children': [], 'value': 'explain'}; {'id': '334', 'type': 'string', 'children': [], 'value': '")"'}, {'id': '335', 'type': 'expression_statement', 'children': ['336']}; {'id': '336', 'type': 'call', 'children': ['337', '340']}, {'id': '337', 'type': 'attribute', 'children': ['338', '339']}; {'id': '338', 'type': 'identifier', 'children': [], 'value': 'env'}, {'id': '339', 'type': 'identifier', 'children': [], 'value': 'Execute'}; {'id': '340', 'type': 'argument_list', 'children': ['341']}, {'id': '341', 'type': 'call', 'children': ['342', '347']}; {'id': '342', 'type': 'attribute', 'children': ['343', '346']}, {'id': '343', 'type': 'attribute', 'children': ['344', '345']}; {'id': '344', 'type': 'identifier', 'children': [], 'value': 'SCons'}, {'id': '345', 'type': 'identifier', 'children': [], 'value': 'Action'}; {'id': '346', 'type': 'identifier', 'children': [], 'value': 'Action'}, {'id': '347', 'type': 'argument_list', 'children': ['348', '349']}; {'id': '348', 'type': 'identifier', 'children': [], 'value': 'nop'}, {'id': '349', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '350', 'type': 'expression_statement', 'children': ['351']}, {'id': '351', 'type': 'assignment', 'children': ['352', '353']}; {'id': '352', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '353', 'type': 'call', 'children': ['354', '355']}; {'id': '354', 'type': 'identifier', 'children': [], 'value': 'open'}, {'id': '355', 'type': 'argument_list', 'children': ['356', '362']}; {'id': '356', 'type': 'call', 'children': ['357', '358']}, {'id': '357', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '358', 'type': 'argument_list', 'children': ['359']}, {'id': '359', 'type': 'subscript', 'children': ['360', '361']}; {'id': '360', 'type': 'identifier', 'children': [], 'value': 'target'}, {'id': '361', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '362', 'type': 'string', 'children': [], 'value': '"w"'}, {'id': '363', 'type': 'expression_statement', 'children': ['364']}; {'id': '364', 'type': 'call', 'children': ['365', '368']}, {'id': '365', 'type': 'attribute', 'children': ['366', '367']}; {'id': '366', 'type': 'identifier', 'children': [], 'value': 'f'}, {'id': '367', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '368', 'type': 'argument_list', 'children': ['369']}, {'id': '369', 'type': 'identifier', 'children': [], 'value': 'new_content'}; {'id': '370', 'type': 'expression_statement', 'children': ['371']}, {'id': '371', 'type': 'call', 'children': ['372', '375']}; {'id': '372', 'type': 'attribute', 'children': ['373', '374']}, {'id': '373', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '374', 'type': 'identifier', 'children': [], 'value': 'close'}, {'id': '375', 'type': 'argument_list', 'children': []}; {'id': '376', 'type': 'return_statement', 'children': ['377']}, {'id': '377', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '378', 'type': 'else_clause', 'children': ['379']}, {'id': '379', 'type': 'block', 'children': ['380', '400', '415']}; {'id': '380', 'type': 'expression_statement', 'children': ['381']}, {'id': '381', 'type': 'assignment', 'children': ['382', '383']}; {'id': '382', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '383', 'type': 'binary_operator', 'children': ['384', '399'], 'value': '+'}; {'id': '384', 'type': 'binary_operator', 'children': ['385', '398'], 'value': '+'}, {'id': '385', 'type': 'binary_operator', 'children': ['386', '397'], 'value': '+'}; {'id': '386', 'type': 'binary_operator', 'children': ['387', '388'], 'value': '+'}, {'id': '387', 'type': 'string', 'children': [], 'value': '"Not writing "'}; {'id': '388', 'type': 'call', 'children': ['389', '390']}, {'id': '389', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '390', 'type': 'argument_list', 'children': ['391']}, {'id': '391', 'type': 'call', 'children': ['392', '393']}; {'id': '392', 'type': 'identifier', 'children': [], 'value': 'str'}, {'id': '393', 'type': 'argument_list', 'children': ['394']}; {'id': '394', 'type': 'subscript', 'children': ['395', '396']}, {'id': '395', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '396', 'type': 'integer', 'children': [], 'value': '0'}, {'id': '397', 'type': 'string', 'children': [], 'value': '" ("'}; {'id': '398', 'type': 'identifier', 'children': [], 'value': 'explain'}, {'id': '399', 'type': 'string', 'children': [], 'value': '")"'}; {'id': '400', 'type': 'expression_statement', 'children': ['401']}, {'id': '401', 'type': 'call', 'children': ['402', '405']}; {'id': '402', 'type': 'attribute', 'children': ['403', '404']}, {'id': '403', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '404', 'type': 'identifier', 'children': [], 'value': 'Execute'}, {'id': '405', 'type': 'argument_list', 'children': ['406']}; {'id': '406', 'type': 'call', 'children': ['407', '412']}, {'id': '407', 'type': 'attribute', 'children': ['408', '411']}; {'id': '408', 'type': 'attribute', 'children': ['409', '410']}, {'id': '409', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '410', 'type': 'identifier', 'children': [], 'value': 'Action'}, {'id': '411', 'type': 'identifier', 'children': [], 'value': 'Action'}; {'id': '412', 'type': 'argument_list', 'children': ['413', '414']}, {'id': '413', 'type': 'identifier', 'children': [], 'value': 'nop'}; {'id': '414', 'type': 'identifier', 'children': [], 'value': 'msg'}, {'id': '415', 'type': 'return_statement', 'children': ['416']}
def _update_pot_file(target, source, env): import re import os import SCons.Action nop = lambda target, source, env: 0 save_cwd = env.fs.getcwd() save_os_cwd = os.getcwd() chdir = target[0].dir chdir_str = repr(chdir.get_abspath()) env.Execute(SCons.Action.Action(nop, "Entering " + chdir_str)) env.fs.chdir(chdir, 1) try: cmd = _CmdRunner('$XGETTEXTCOM', '$XGETTEXTCOMSTR') action = SCons.Action.Action(cmd, strfunction=cmd.strfunction) status = action([target[0]], source, env) except: env.Execute(SCons.Action.Action(nop, "Leaving " + chdir_str)) env.fs.chdir(save_cwd, 0) os.chdir(save_os_cwd) raise env.Execute(SCons.Action.Action(nop, "Leaving " + chdir_str)) env.fs.chdir(save_cwd, 0) os.chdir(save_os_cwd) if status: return status new_content = cmd.out if not new_content: needs_update = False explain = "no internationalized messages encountered" else: if target[0].exists(): old_content = target[0].get_text_contents() re_cdate = re.compile(r'^"POT-Creation-Date: .*"$[\r\n]?', re.M) old_content_nocdate = re.sub(re_cdate, "", old_content) new_content_nocdate = re.sub(re_cdate, "", new_content) if (old_content_nocdate == new_content_nocdate): needs_update = False explain = "messages in file found to be up-to-date" else: needs_update = True explain = "messages in file were outdated" else: needs_update = True explain = "new file" if needs_update: msg = "Writing " + repr(str(target[0])) + " (" + explain + ")" env.Execute(SCons.Action.Action(nop, msg)) f = open(str(target[0]), "w") f.write(new_content) f.close() return 0 else: msg = "Not writing " + repr(str(target[0])) + " (" + explain + ")" env.Execute(SCons.Action.Action(nop, msg)) return 0