code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def network_create(self, name, **kwargs): nt_ks = self.compute_conn kwargs['label'] = name kwargs = self._sanatize_network_params(kwargs) net = nt_ks.networks.create(**kwargs) return net.__dict__
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'network_create'}; {'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': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '8', 'type': 'block', 'children': ['9', '15', '21', '30', '42']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'nt_ks'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'compute_conn'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '20']}; {'id': '17', 'type': 'subscript', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'label'"}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'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': '_sanatize_network_params'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'net'}; {'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': 'nt_ks'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'networks'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'create'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'dictionary_splat', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'net'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': '__dict__'}
Create extra private network
def do_status(self, line): print('{} {}'.format(bold('Pyrene version'), green(get_version()))) pip_conf = os.path.expanduser('~/.pip/pip.conf') if os.path.exists(pip_conf): conf = read_file(pip_conf) repo = self._get_repo_for_pip_conf(conf) if repo: print( '{} is configured for repository "{}"' .format(bold(pip_conf), green(repo.name)) ) else: print( '{} exists, but is a {}' .format(bold(pip_conf), red('custom configuration')) ) else: print('{} {}'.format(bold(pip_conf), red('does not exists'))) if os.path.exists(self.pypirc): template = green('exists') else: template = red('does not exists') template = '{} ' + template print(template.format(bold(self.pypirc)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_status'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '6', 'type': 'block', 'children': ['7', '26', '37', '123', '151', '157']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'{} {}'"}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '20']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'bold'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'Pyrene version'"}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'green'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'get_version'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'pip_conf'}; {'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': 'os'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'expanduser'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'~/.pip/pip.conf'"}; {'id': '37', 'type': 'if_statement', 'children': ['38', '46', '104']}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'pip_conf'}; {'id': '46', 'type': 'block', 'children': ['47', '54', '63']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'conf'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'read_file'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'pip_conf'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '_get_repo_for_pip_conf'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'conf'}; {'id': '63', 'type': 'if_statement', 'children': ['64', '65', '85']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': '\'{} is configured for repository "{}"\''}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '79']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'bold'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'pip_conf'}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'green'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '85', 'type': 'else_clause', 'children': ['86']}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'string', 'children': [], 'value': "'{} exists, but is a {}'"}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '95', 'type': 'argument_list', 'children': ['96', '100']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'bold'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'pip_conf'}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'red'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'string', 'children': [], 'value': "'custom configuration'"}; {'id': '104', 'type': 'else_clause', 'children': ['105']}; {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'string', 'children': [], 'value': "'{} {}'"}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '114', 'type': 'argument_list', 'children': ['115', '119']}; {'id': '115', 'type': 'call', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'bold'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'pip_conf'}; {'id': '119', 'type': 'call', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'red'}; {'id': '121', 'type': 'argument_list', 'children': ['122']}; {'id': '122', 'type': 'string', 'children': [], 'value': "'does not exists'"}; {'id': '123', 'type': 'if_statement', 'children': ['124', '134', '142']}; {'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': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'pypirc'}; {'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': 'template'}; {'id': '138', 'type': 'call', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'green'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}; {'id': '141', 'type': 'string', 'children': [], 'value': "'exists'"}; {'id': '142', 'type': 'else_clause', 'children': ['143']}; {'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': 'template'}; {'id': '147', 'type': 'call', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'red'}; {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'string', 'children': [], 'value': "'does not exists'"}; {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'assignment', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '154', 'type': 'binary_operator', 'children': ['155', '156'], 'value': '+'}; {'id': '155', 'type': 'string', 'children': [], 'value': "'{} '"}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '157', 'type': 'expression_statement', 'children': ['158']}; {'id': '158', 'type': 'call', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '160', 'type': 'argument_list', 'children': ['161']}; {'id': '161', 'type': 'call', 'children': ['162', '165']}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '165', 'type': 'argument_list', 'children': ['166']}; {'id': '166', 'type': 'call', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'bold'}; {'id': '168', 'type': 'argument_list', 'children': ['169']}; {'id': '169', 'type': 'attribute', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'pypirc'}
Show python packaging configuration status
def _expand(self, line: str) -> str: tmp_aliases = list(self.aliases.keys()) keep_expanding = bool(tmp_aliases) while keep_expanding: for cur_alias in tmp_aliases: keep_expanding = False match = self._command_pattern.search(line) if match: command = match.group(1) if command and command == cur_alias: line = self.aliases[cur_alias] + match.group(2) + line[match.end(2):] tmp_aliases.remove(cur_alias) keep_expanding = bool(tmp_aliases) break for (shortcut, expansion) in self.shortcuts: if line.startswith(shortcut): shortcut_len = len(shortcut) if len(line) == shortcut_len or line[shortcut_len] != ' ': expansion += ' ' line = line.replace(shortcut, expansion, 1) break return line
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_expand'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '9', 'type': 'type', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '11', 'type': 'block', 'children': ['12', '25', '32', '114', '167']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'tmp_aliases'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'aliases'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'keep_expanding'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'tmp_aliases'}; {'id': '32', 'type': 'while_statement', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'keep_expanding'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'for_statement', 'children': ['36', '37', '38']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'cur_alias'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'tmp_aliases'}; {'id': '38', 'type': 'block', 'children': ['39', '43', '54']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'keep_expanding'}; {'id': '42', 'type': 'False', 'children': []}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'match'}; {'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': '_command_pattern'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '54', 'type': 'if_statement', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '56', 'type': 'block', 'children': ['57', '66']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '66', 'type': 'if_statement', 'children': ['67', '72']}; {'id': '67', 'type': 'boolean_operator', 'children': ['68', '69'], 'value': 'and'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '69', 'type': 'comparison_operator', 'children': ['70', '71'], 'value': '=='}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'cur_alias'}; {'id': '72', 'type': 'block', 'children': ['73', '99', '106', '113']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '76', 'type': 'binary_operator', 'children': ['77', '89'], 'value': '+'}; {'id': '77', 'type': 'binary_operator', 'children': ['78', '83'], 'value': '+'}; {'id': '78', 'type': 'subscript', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'aliases'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'cur_alias'}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '91', 'type': 'slice', 'children': ['92', '98']}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '98', 'type': 'colon', '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': 'tmp_aliases'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'cur_alias'}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'assignment', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'keep_expanding'}; {'id': '109', 'type': 'call', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'tmp_aliases'}; {'id': '113', 'type': 'break_statement', 'children': []}; {'id': '114', 'type': 'for_statement', 'children': ['115', '118', '121']}; {'id': '115', 'type': 'tuple_pattern', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'shortcut'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'expansion'}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'shortcuts'}; {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'if_statement', 'children': ['123', '129']}; {'id': '123', 'type': 'call', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'shortcut'}; {'id': '129', 'type': 'block', 'children': ['130', '137', '155', '166']}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'assignment', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'shortcut_len'}; {'id': '133', 'type': 'call', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'shortcut'}; {'id': '137', 'type': 'if_statement', 'children': ['138', '150']}; {'id': '138', 'type': 'boolean_operator', 'children': ['139', '145'], 'value': 'or'}; {'id': '139', 'type': 'comparison_operator', 'children': ['140', '144'], 'value': '=='}; {'id': '140', 'type': 'call', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'shortcut_len'}; {'id': '145', 'type': 'comparison_operator', 'children': ['146', '149'], 'value': '!='}; {'id': '146', 'type': 'subscript', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'shortcut_len'}; {'id': '149', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '150', 'type': 'block', 'children': ['151']}; {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'augmented_assignment', 'children': ['153', '154'], 'value': '+='}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'expansion'}; {'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': 'line'}; {'id': '158', 'type': 'call', 'children': ['159', '162']}; {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '162', 'type': 'argument_list', 'children': ['163', '164', '165']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'shortcut'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'expansion'}; {'id': '165', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '166', 'type': 'break_statement', 'children': []}; {'id': '167', 'type': 'return_statement', 'children': ['168']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'line'}
Expand shortcuts and aliases
def _setable_get_(name, self): "Used to raise an exception for attributes unable to be evaluated yet." raise AttributeError( "'{typename}' object has no attribute '{name}'".format( typename=type(self).__name__, name=name ) )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_setable_get_'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '6', 'type': 'block', 'children': ['7', '9']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': '"Used to raise an exception for attributes unable to be evaluated yet."'}; {'id': '9', 'type': 'raise_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"\'{typename}\' object has no attribute \'{name}\'"'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '26']}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'typename'}; {'id': '20', 'type': 'attribute', 'children': ['21', '25']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'name'}
Used to raise an exception for attributes unable to be evaluated yet.
def record_leaving(self, time, code, frame_key, parent_stats): try: stats = parent_stats.get_child(code) time_entered = self._times_entered.pop((code, frame_key)) except KeyError: return time_elapsed = time - time_entered stats.deep_time += max(0, time_elapsed)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'record_leaving'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'frame_key'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'parent_stats'}; {'id': '9', 'type': 'block', 'children': ['10', '38', '44']}; {'id': '10', 'type': 'try_statement', 'children': ['11', '34']}; {'id': '11', 'type': 'block', 'children': ['12', '21']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'parent_stats'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get_child'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'time_entered'}; {'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': '_times_entered'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'tuple', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'frame_key'}; {'id': '34', 'type': 'except_clause', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'return_statement', 'children': []}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'time_elapsed'}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '43'], 'value': '-'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'time_entered'}; {'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': 'stats'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'deep_time'}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'time_elapsed'}
Left from a function call.
def download_content(**args): args = validate_args(**args) if not args['directory']: args['directory'] = args['query'].replace(' ', '-') print("Downloading {0} {1} files on topic {2} from {3} and saving to directory: {4}" .format(args['limit'], args['file_type'], args['query'], args['website'], args['directory'])) links = search(args['query'], args['engine'], args['website'], args['file_type'], args['limit']) if args['parallel']: download_parallel(links, args['directory'], args['min_file_size'], args['max_file_size'], args['no_redirects']) else: download_series(links, args['directory'], args['min_file_size'], args['max_file_size'], args['no_redirects'])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'download_content'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'dictionary_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '35', '59', '80']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'validate_args'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'dictionary_splat', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '20']}; {'id': '16', 'type': 'not_operator', 'children': ['17']}; {'id': '17', 'type': 'subscript', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'directory'"}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '26']}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'directory'"}; {'id': '26', 'type': 'call', 'children': ['27', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'query'"}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '34', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'string', 'children': [], 'value': '"Downloading {0} {1} files on topic {2} from {3} and saving to directory: {4}"'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '47', '50', '53', '56']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'limit'"}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '49', 'type': 'string', 'children': [], 'value': "'file_type'"}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '52', 'type': 'string', 'children': [], 'value': "'query'"}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '55', 'type': 'string', 'children': [], 'value': "'website'"}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '58', 'type': 'string', 'children': [], 'value': "'directory'"}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'links'}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '68', '71', '74', '77']}; {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'query'"}; {'id': '68', 'type': 'subscript', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '70', 'type': 'string', 'children': [], 'value': "'engine'"}; {'id': '71', 'type': 'subscript', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '73', 'type': 'string', 'children': [], 'value': "'website'"}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'file_type'"}; {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '79', 'type': 'string', 'children': [], 'value': "'limit'"}; {'id': '80', 'type': 'if_statement', 'children': ['81', '84', '102']}; {'id': '81', 'type': 'subscript', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '83', 'type': 'string', 'children': [], 'value': "'parallel'"}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'download_parallel'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '90', '93', '96', '99']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'links'}; {'id': '90', 'type': 'subscript', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '92', 'type': 'string', 'children': [], 'value': "'directory'"}; {'id': '93', 'type': 'subscript', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '95', 'type': 'string', 'children': [], 'value': "'min_file_size'"}; {'id': '96', 'type': 'subscript', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '98', 'type': 'string', 'children': [], 'value': "'max_file_size'"}; {'id': '99', 'type': 'subscript', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '101', 'type': 'string', 'children': [], 'value': "'no_redirects'"}; {'id': '102', 'type': 'else_clause', 'children': ['103']}; {'id': '103', 'type': 'block', 'children': ['104']}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'download_series'}; {'id': '107', 'type': 'argument_list', 'children': ['108', '109', '112', '115', '118']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'links'}; {'id': '109', 'type': 'subscript', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '111', 'type': 'string', 'children': [], 'value': "'directory'"}; {'id': '112', 'type': 'subscript', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '114', 'type': 'string', 'children': [], 'value': "'min_file_size'"}; {'id': '115', 'type': 'subscript', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '117', 'type': 'string', 'children': [], 'value': "'max_file_size'"}; {'id': '118', 'type': 'subscript', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '120', 'type': 'string', 'children': [], 'value': "'no_redirects'"}
main function to fetch links and download them
def _get_existing_report(self, mask, report): for existing_report in self._reports: if existing_report['namespace'] == report['namespace']: if mask == existing_report['queryMask']: return existing_report return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_existing_report'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '7', 'type': 'block', 'children': ['8', '32']}; {'id': '8', 'type': 'for_statement', 'children': ['9', '10', '13']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'existing_report'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_reports'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '22']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '19'], 'value': '=='}; {'id': '16', 'type': 'subscript', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'existing_report'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'namespace'"}; {'id': '19', 'type': 'subscript', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'namespace'"}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'if_statement', 'children': ['24', '29']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': '=='}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'existing_report'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'queryMask'"}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'existing_report'}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'None', 'children': []}
Returns the aggregated report that matches report
def expand_folder(files): expfiles = [] for file in files: if os.path.isdir(file): for dirpath, dirnames, filenames in os.walk(file): for filename in filenames: expfiles.append(os.path.join(dirpath, filename)) else: expfiles.append(file) for path in expfiles: if not os.path.exists(path): sys.stderr.write('%s: No such file or directory\n' % path) return expfiles
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'expand_folder'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '64', '90']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'expfiles'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '13']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '23', '55']}; {'id': '15', 'type': 'call', 'children': ['16', '21']}; {'id': '16', 'type': 'attribute', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'isdir'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'for_statement', 'children': ['25', '29', '35']}; {'id': '25', 'type': 'pattern_list', 'children': ['26', '27', '28']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'dirpath'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dirnames'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'filenames'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'walk'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'for_statement', 'children': ['37', '38', '39']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'filenames'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'expfiles'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'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': 'os'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'dirpath'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '55', 'type': 'else_clause', 'children': ['56']}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'expfiles'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '64', 'type': 'for_statement', 'children': ['65', '66', '67']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'expfiles'}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'if_statement', 'children': ['69', '78']}; {'id': '69', 'type': 'not_operator', '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': 'os'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '86']}; {'id': '81', 'type': 'attribute', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'binary_operator', 'children': ['88', '89'], 'value': '%'}; {'id': '88', 'type': 'string', 'children': [], 'value': "'%s: No such file or directory\\n'"}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '90', 'type': 'return_statement', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'expfiles'}
Return a clone of file list files where all directories are recursively replaced with their contents.
def _from_dict(cls, _dict): args = {} if 'tokens' in _dict: args['tokens'] = [ TokenResult._from_dict(x) for x in (_dict.get('tokens')) ] if 'sentences' in _dict: args['sentences'] = [ SentenceResult._from_dict(x) for x in (_dict.get('sentences')) ] return cls(**args)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_from_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '37', '63']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '10', 'type': 'dictionary', 'children': []}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'in'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'tokens'"}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '21']}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'tokens'"}; {'id': '21', 'type': 'list_comprehension', 'children': ['22', '28']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'TokenResult'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_from_dict'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '28', 'type': 'for_in_clause', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '30', 'type': '()', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'tokens'"}; {'id': '37', 'type': 'if_statement', 'children': ['38', '41']}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '40'], 'value': 'in'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'sentences'"}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '47']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'sentences'"}; {'id': '47', 'type': 'list_comprehension', 'children': ['48', '54']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'SentenceResult'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': '_from_dict'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '54', 'type': 'for_in_clause', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '56', 'type': '()', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'sentences'"}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'dictionary_splat', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'args'}
Initialize a SyntaxResult object from a json dictionary.
def layer_pre_save(instance, *args, **kwargs): is_valid = True if not instance.service.type == 'Hypermap:WorldMap': if not instance.service.is_valid: is_valid = False LOGGER.debug('Layer with id %s is marked invalid because its service is invalid' % instance.id) if instance.bbox_x0 > -2 and instance.bbox_x1 < 2 and instance.bbox_y0 > -2 and instance.bbox_y1 < 2: is_valid = False LOGGER.debug( 'Layer with id %s is marked invalid because its extent is within (-2, -2, +2, +2)' % instance.id ) instance.is_valid = is_valid
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'layer_pre_save'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '5', 'type': 'list_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '9', 'type': 'block', 'children': ['10', '14', '89']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'is_valid'}; {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'if_statement', 'children': ['15', '23']}; {'id': '15', 'type': 'not_operator', 'children': ['16']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '22'], 'value': '=='}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'Hypermap:WorldMap'"}; {'id': '23', 'type': 'block', 'children': ['24', '47']}; {'id': '24', 'type': 'if_statement', 'children': ['25', '31']}; {'id': '25', 'type': 'not_operator', 'children': ['26']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'is_valid'}; {'id': '31', 'type': 'block', 'children': ['32', '36']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'is_valid'}; {'id': '35', 'type': 'False', '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': 'LOGGER'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '44'], 'value': '%'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'Layer with id %s is marked invalid because its service is invalid'"}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '73']}; {'id': '48', 'type': 'boolean_operator', 'children': ['49', '68'], 'value': 'and'}; {'id': '49', 'type': 'boolean_operator', 'children': ['50', '62'], 'value': 'and'}; {'id': '50', 'type': 'boolean_operator', 'children': ['51', '57'], 'value': 'and'}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '55'], 'value': '>'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'bbox_x0'}; {'id': '55', 'type': 'unary_operator', 'children': ['56'], 'value': '-'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '57', 'type': 'comparison_operator', 'children': ['58', '61'], 'value': '<'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'bbox_x1'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '66'], 'value': '>'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'bbox_y0'}; {'id': '66', 'type': 'unary_operator', 'children': ['67'], 'value': '-'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '72'], 'value': '<'}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'bbox_y1'}; {'id': '72', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '73', 'type': 'block', 'children': ['74', '78']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'is_valid'}; {'id': '77', 'type': 'False', 'children': []}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'LOGGER'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'binary_operator', 'children': ['85', '86'], 'value': '%'}; {'id': '85', 'type': 'string', 'children': [], 'value': "'Layer with id %s is marked invalid because its extent is within (-2, -2, +2, +2)'"}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'is_valid'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'is_valid'}
Used to check layer validity.
def mysql_to_dict(data, key): ret = {} headers = [''] for line in data: if not line: continue if line.startswith('+'): continue comps = line.split('|') for comp in range(len(comps)): comps[comp] = comps[comp].strip() if len(headers) > 1: index = len(headers) - 1 row = {} for field in range(index): if field < 1: continue else: row[headers[field]] = salt.utils.stringutils.to_num(comps[field]) ret[row[key]] = row else: headers = comps return ret
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mysql_to_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '16', '134']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '10', 'type': 'dictionary', 'children': []}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '14', 'type': 'list', 'children': ['15'], 'value': "['']"}; {'id': '15', 'type': 'string', 'children': [], 'value': "''"}; {'id': '16', 'type': 'for_statement', 'children': ['17', '18', '19']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '19', 'type': 'block', 'children': ['20', '25', '34', '43', '65']}; {'id': '20', 'type': 'if_statement', 'children': ['21', '23']}; {'id': '21', 'type': 'not_operator', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'continue_statement', 'children': []}; {'id': '25', 'type': 'if_statement', 'children': ['26', '32']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'+'"}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'continue_statement', 'children': []}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'comps'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'string', 'children': [], 'value': "'|'"}; {'id': '43', 'type': 'for_statement', 'children': ['44', '45', '52']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'comp'}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'comps'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '58']}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'comps'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'comp'}; {'id': '58', 'type': 'call', 'children': ['59', '64']}; {'id': '59', 'type': 'attribute', 'children': ['60', '63']}; {'id': '60', 'type': 'subscript', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'comps'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'comp'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '64', 'type': 'argument_list', 'children': []}; {'id': '65', 'type': 'if_statement', 'children': ['66', '72', '128']}; {'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': 'headers'}; {'id': '71', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '72', 'type': 'block', 'children': ['73', '82', '86', '120']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '76', 'type': 'binary_operator', 'children': ['77', '81'], 'value': '-'}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '81', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '85', 'type': 'dictionary', 'children': []}; {'id': '86', 'type': 'for_statement', 'children': ['87', '88', '92']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'if_statement', 'children': ['94', '97', '99']}; {'id': '94', 'type': 'comparison_operator', 'children': ['95', '96'], 'value': '<'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '96', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'continue_statement', 'children': []}; {'id': '99', 'type': 'else_clause', 'children': ['100']}; {'id': '100', 'type': 'block', 'children': ['101']}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '108']}; {'id': '103', 'type': 'subscript', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '105', 'type': 'subscript', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '108', 'type': 'call', 'children': ['109', '116']}; {'id': '109', 'type': 'attribute', 'children': ['110', '115']}; {'id': '110', 'type': 'attribute', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'stringutils'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'to_num'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}; {'id': '117', 'type': 'subscript', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'comps'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'assignment', 'children': ['122', '127']}; {'id': '122', 'type': 'subscript', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '124', 'type': 'subscript', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '128', 'type': 'else_clause', 'children': ['129']}; {'id': '129', 'type': 'block', 'children': ['130']}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'assignment', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'comps'}; {'id': '134', 'type': 'return_statement', 'children': ['135']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'ret'}
Convert MySQL-style output to a python dictionary
def nested(self, format_callback=None): seen = set() roots = [] for root in self.edges.get(None, ()): roots.extend(self._nested(root, seen, format_callback)) return roots
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'nested'}; {'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': 'format_callback'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '15', '19', '45']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'seen'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'roots'}; {'id': '18', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '19', 'type': 'for_statement', 'children': ['20', '21', '30']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'edges'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'tuple', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'roots'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '36', 'type': 'argument_list', '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': '_nested'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43', '44']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'seen'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'format_callback'}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'roots'}
Return the graph as a nested list.
def human_size(bytes, units=[' bytes','KB','MB','GB','TB', 'PB', 'EB']): return str(bytes) + units[0] if bytes < 1024 else human_size(bytes>>10, units[1:])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'human_size'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '7', 'type': 'list', 'children': ['8', '9', '10', '11', '12', '13', '14'], 'value': "[' bytes','KB','MB','GB','TB', 'PB', 'EB']"}; {'id': '8', 'type': 'string', 'children': [], 'value': "' bytes'"}; {'id': '9', 'type': 'string', 'children': [], 'value': "'KB'"}; {'id': '10', 'type': 'string', 'children': [], 'value': "'MB'"}; {'id': '11', 'type': 'string', 'children': [], 'value': "'GB'"}; {'id': '12', 'type': 'string', 'children': [], 'value': "'TB'"}; {'id': '13', 'type': 'string', 'children': [], 'value': "'PB'"}; {'id': '14', 'type': 'string', 'children': [], 'value': "'EB'"}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'conditional_expression', 'children': ['18', '26', '29'], 'value': 'if'}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '23'], 'value': '+'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': '<'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '1024'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'human_size'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '35']}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '34'], 'value': '>>'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '37', 'type': 'slice', 'children': ['38', '39']}; {'id': '38', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '39', 'type': 'colon', 'children': []}
Returns a human readable string reprentation of bytes
def _listen(self, uuid=None, session=None): if self.url is None: raise Exception("NURESTPushCenter needs to have a valid URL. please use setURL: before starting it.") events_url = "%s/events" % self.url if uuid: events_url = "%s?uuid=%s" % (events_url, uuid) request = NURESTRequest(method='GET', url=events_url) connection = NURESTConnection(request=request, async=True, callback=self._did_receive_event, root_object=self._root_object) if self._timeout: if int(time()) - self._start_time >= self._timeout: pushcenter_logger.debug("[NURESTPushCenter] Timeout (timeout=%ss)." % self._timeout) return else: connection.timeout = self._timeout pushcenter_logger.info('Bambou Sending >>>>>>\n%s %s' % (request.method, request.url)) connection.start()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_listen'}; {'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': 'uuid'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '24', '32', '43', '55', '77', '120', '135']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '18']}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '17'], 'value': 'is'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '17', 'type': 'None', 'children': []}; {'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': 'Exception'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'string', 'children': [], 'value': '"NURESTPushCenter needs to have a valid URL. please use setURL: before starting it."'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'events_url'}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '%'}; {'id': '28', 'type': 'string', 'children': [], 'value': '"%s/events"'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '32', 'type': 'if_statement', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'uuid'}; {'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': 'events_url'}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '40'], 'value': '%'}; {'id': '39', 'type': 'string', 'children': [], 'value': '"%s?uuid=%s"'}; {'id': '40', 'type': 'tuple', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'events_url'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'uuid'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'NURESTRequest'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '52']}; {'id': '49', 'type': 'keyword_argument', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '51', 'type': 'string', 'children': [], 'value': "'GET'"}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'events_url'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'NURESTConnection'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '64', '67', '72']}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'async'}; {'id': '66', 'type': 'True', 'children': []}; {'id': '67', 'type': 'keyword_argument', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'callback'}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': '_did_receive_event'}; {'id': '72', 'type': 'keyword_argument', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'root_object'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': '_root_object'}; {'id': '77', 'type': 'if_statement', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': '_timeout'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'if_statement', 'children': ['83', '97', '110']}; {'id': '83', 'type': 'comparison_operator', 'children': ['84', '94'], 'value': '>='}; {'id': '84', 'type': 'binary_operator', 'children': ['85', '91'], 'value': '-'}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '90', 'type': 'argument_list', 'children': []}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': '_start_time'}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': '_timeout'}; {'id': '97', 'type': 'block', 'children': ['98', '109']}; {'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': 'pushcenter_logger'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'binary_operator', 'children': ['105', '106'], 'value': '%'}; {'id': '105', 'type': 'string', 'children': [], 'value': '"[NURESTPushCenter] Timeout (timeout=%ss)."'}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': '_timeout'}; {'id': '109', 'type': 'return_statement', 'children': []}; {'id': '110', 'type': 'else_clause', 'children': ['111']}; {'id': '111', 'type': 'block', 'children': ['112']}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'assignment', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': '_timeout'}; {'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': 'pushcenter_logger'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '125', 'type': 'argument_list', 'children': ['126']}; {'id': '126', 'type': 'binary_operator', 'children': ['127', '128'], 'value': '%'}; {'id': '127', 'type': 'string', 'children': [], 'value': "'Bambou Sending >>>>>>\\n%s %s'"}; {'id': '128', 'type': 'tuple', 'children': ['129', '132']}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'url'}; {'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': 'connection'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '140', 'type': 'argument_list', 'children': []}
Listen a connection uuid
def tag_builder(parser, token, cls, flow_type): tokens = token.split_contents() tokens_num = len(tokens) if tokens_num == 1 or (tokens_num == 3 and tokens[1] == 'for'): flow_name = None if tokens_num == 3: flow_name = tokens[2] return cls(flow_name) else: raise template.TemplateSyntaxError( '"sitegate_%(type)s_form" tag requires zero or two arguments. ' 'E.g. {%% sitegate_%(type)s_form %%} or ' '{%% sitegate_%(type)s_form for ClassicSignup %%}.' % {'type': flow_type})
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tag_builder'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'flow_type'}; {'id': '8', 'type': 'block', 'children': ['9', '17', '24']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'split_contents'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'tokens_num'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '39', '60']}; {'id': '25', 'type': 'boolean_operator', 'children': ['26', '29'], 'value': 'or'}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': '=='}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'tokens_num'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '29', 'type': '()', 'children': ['30']}; {'id': '30', 'type': 'boolean_operator', 'children': ['31', '34'], 'value': 'and'}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '33'], 'value': '=='}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'tokens_num'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '38'], 'value': '=='}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'for'"}; {'id': '39', 'type': 'block', 'children': ['40', '44', '55']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'flow_name'}; {'id': '43', 'type': 'None', 'children': []}; {'id': '44', 'type': 'if_statement', 'children': ['45', '48']}; {'id': '45', 'type': 'comparison_operator', 'children': ['46', '47'], 'value': '=='}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'tokens_num'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '3'}; {'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': 'flow_name'}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '55', 'type': 'return_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'flow_name'}; {'id': '60', 'type': 'else_clause', 'children': ['61']}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'raise_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'TemplateSyntaxError'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'binary_operator', 'children': ['69', '73'], 'value': '%'}; {'id': '69', 'type': 'concatenated_string', 'children': ['70', '71', '72']}; {'id': '70', 'type': 'string', 'children': [], 'value': '\'"sitegate_%(type)s_form" tag requires zero or two arguments. \''}; {'id': '71', 'type': 'string', 'children': [], 'value': "'E.g. {%% sitegate_%(type)s_form %%} or '"}; {'id': '72', 'type': 'string', 'children': [], 'value': "'{%% sitegate_%(type)s_form for ClassicSignup %%}.'"}; {'id': '73', 'type': 'dictionary', 'children': ['74']}; {'id': '74', 'type': 'pair', 'children': ['75', '76']}; {'id': '75', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'flow_type'}
Helper function handling flow form tags.
def DisplayGetter(accessor, *args, **kwargs): short_description = get_pretty_name(accessor) accessor = 'get_%s_display' % accessor getter = Getter(accessor, *args, **kwargs) getter.short_description = short_description return getter
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'DisplayGetter'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'accessor'}; {'id': '5', 'type': 'list_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '9', 'type': 'block', 'children': ['10', '17', '23', '34', '40']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'short_description'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_pretty_name'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'accessor'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'accessor'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '22'], 'value': '%'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'get_%s_display'"}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'accessor'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'getter'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'Getter'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30', '32']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'accessor'}; {'id': '30', 'type': 'list_splat', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '32', 'type': 'dictionary_splat', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'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': 'getter'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'short_description'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'short_description'}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'getter'}
Returns a Getter that gets the display name for a model field with choices.
def commit(message=COMMON_COMMIT_MESSAGE, capture=True): env.warn_only = True local(u'git commit -am"{}"'.format(message))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'commit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'COMMON_COMMIT_MESSAGE'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'capture'}; {'id': '9', 'type': 'True', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '17']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'warn_only'}; {'id': '16', 'type': 'True', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'local'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': 'u\'git commit -am"{}"\''}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'message'}
git commit with common commit message when omit.
def main(): args = parser.parse_args() try: function = args.func except AttributeError: parser.print_usage() parser.exit(1) function(vars(args))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '13', '37']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'parse_args'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'try_statement', 'children': ['14', '21']}; {'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': 'function'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '21', 'type': 'except_clause', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '23', 'type': 'block', 'children': ['24', '30']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'print_usage'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'function'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'args'}
Parse the args and call whatever function was selected
def _get_base_class_names(frame): co, lasti = frame.f_code, frame.f_lasti code = co.co_code extends = [] for (op, oparg) in op_stream(code, lasti): if op in dis.hasconst: if type(co.co_consts[oparg]) == str: extends = [] elif op in dis.hasname: if dis.opname[op] == 'LOAD_NAME': extends.append(('name', co.co_names[oparg])) if dis.opname[op] == 'LOAD_ATTR': extends.append(('attr', co.co_names[oparg])) if dis.opname[op] == 'LOAD_GLOBAL': extends.append(('name', co.co_names[oparg])) items = [] previous_item = [] for t, s in extends: if t == 'name': if previous_item: items.append(previous_item) previous_item = [s] else: previous_item += [s] if previous_item: items.append(previous_item) return items
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_base_class_names'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '24', '28', '134', '138', '142', '175', '185']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'co'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'lasti'}; {'id': '11', 'type': 'expression_list', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'f_code'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'f_lasti'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'co'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'co_code'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'extends'}; {'id': '27', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '28', 'type': 'for_statement', 'children': ['29', '32', '37']}; {'id': '29', 'type': 'tuple_pattern', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'oparg'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'op_stream'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'lasti'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'if_statement', 'children': ['39', '44', '61']}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '41'], 'value': 'in'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'dis'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'hasconst'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'if_statement', 'children': ['46', '56']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '55'], 'value': '=='}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'subscript', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'co'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'co_consts'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'oparg'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'str'}; {'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': 'extends'}; {'id': '60', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '61', 'type': 'elif_clause', 'children': ['62', '67']}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '64'], 'value': 'in'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'dis'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'hasname'}; {'id': '67', 'type': 'block', 'children': ['68', '90', '112']}; {'id': '68', 'type': 'if_statement', 'children': ['69', '76']}; {'id': '69', 'type': 'comparison_operator', 'children': ['70', '75'], 'value': '=='}; {'id': '70', 'type': 'subscript', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'dis'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'opname'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '75', 'type': 'string', 'children': [], 'value': "'LOAD_NAME'"}; {'id': '76', 'type': 'block', 'children': ['77']}; {'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': 'extends'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'tuple', 'children': ['84', '85']}; {'id': '84', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '85', 'type': 'subscript', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'co'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'co_names'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'oparg'}; {'id': '90', 'type': 'if_statement', 'children': ['91', '98']}; {'id': '91', 'type': 'comparison_operator', 'children': ['92', '97'], 'value': '=='}; {'id': '92', 'type': 'subscript', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'dis'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'opname'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '97', 'type': 'string', 'children': [], 'value': "'LOAD_ATTR'"}; {'id': '98', 'type': 'block', 'children': ['99']}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'call', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'extends'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'tuple', 'children': ['106', '107']}; {'id': '106', 'type': 'string', 'children': [], 'value': "'attr'"}; {'id': '107', 'type': 'subscript', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'co'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'co_names'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'oparg'}; {'id': '112', 'type': 'if_statement', 'children': ['113', '120']}; {'id': '113', 'type': 'comparison_operator', 'children': ['114', '119'], 'value': '=='}; {'id': '114', 'type': 'subscript', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'dis'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'opname'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '119', 'type': 'string', 'children': [], 'value': "'LOAD_GLOBAL'"}; {'id': '120', 'type': 'block', 'children': ['121']}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'call', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'extends'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'tuple', 'children': ['128', '129']}; {'id': '128', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '129', 'type': 'subscript', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'co'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'co_names'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'oparg'}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'assignment', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '137', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}; {'id': '139', 'type': 'assignment', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'previous_item'}; {'id': '141', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '142', 'type': 'for_statement', 'children': ['143', '146', '147']}; {'id': '143', 'type': 'pattern_list', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'extends'}; {'id': '147', 'type': 'block', 'children': ['148']}; {'id': '148', 'type': 'if_statement', 'children': ['149', '152', '168']}; {'id': '149', 'type': 'comparison_operator', 'children': ['150', '151'], 'value': '=='}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '151', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '152', 'type': 'block', 'children': ['153', '163']}; {'id': '153', 'type': 'if_statement', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'previous_item'}; {'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': 'items'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '161', 'type': 'argument_list', 'children': ['162']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'previous_item'}; {'id': '163', 'type': 'expression_statement', 'children': ['164']}; {'id': '164', 'type': 'assignment', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'previous_item'}; {'id': '166', 'type': 'list', 'children': ['167'], 'value': '[s]'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '168', 'type': 'else_clause', 'children': ['169']}; {'id': '169', 'type': 'block', 'children': ['170']}; {'id': '170', 'type': 'expression_statement', 'children': ['171']}; {'id': '171', 'type': 'augmented_assignment', 'children': ['172', '173'], 'value': '+='}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'previous_item'}; {'id': '173', 'type': 'list', 'children': ['174'], 'value': '[s]'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '175', 'type': 'if_statement', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'previous_item'}; {'id': '177', 'type': 'block', 'children': ['178']}; {'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': 'items'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '183', 'type': 'argument_list', 'children': ['184']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'previous_item'}; {'id': '185', 'type': 'return_statement', 'children': ['186']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'items'}
Get baseclass names from the code object
def check_if_needs_inversion(tomodir): required_files = ( 'grid' + os.sep + 'elem.dat', 'grid' + os.sep + 'elec.dat', 'exe' + os.sep + 'crtomo.cfg', ) needs_inversion = True for filename in required_files: if not os.path.isfile(tomodir + os.sep + filename): needs_inversion = False if not os.path.isfile(tomodir + os.sep + 'mod' + os.sep + 'volt.dat'): if not check_if_needs_modeling(tomodir): print('no volt.dat and no modeling possible') needs_inversion = False inv_ctr_file = tomodir + os.sep + 'inv' + os.sep + 'inv.ctr' if os.path.isfile(inv_ctr_file): inv_lines = open(inv_ctr_file, 'r').readlines() print('inv_lines', inv_lines[-1]) if inv_lines[-1].startswith('***finished***'): needs_inversion = False return needs_inversion
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_if_needs_inversion'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'tomodir'}; {'id': '5', 'type': 'block', 'children': ['6', '31', '35', '60', '99', '115', '161']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'required_files'}; {'id': '9', 'type': 'tuple', 'children': ['10', '17', '24']}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '16'], 'value': '+'}; {'id': '11', 'type': 'binary_operator', 'children': ['12', '13'], 'value': '+'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'grid'"}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'elem.dat'"}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '23'], 'value': '+'}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '20'], 'value': '+'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'grid'"}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'elec.dat'"}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '30'], 'value': '+'}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '27'], 'value': '+'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'exe'"}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'crtomo.cfg'"}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'needs_inversion'}; {'id': '34', 'type': 'True', 'children': []}; {'id': '35', 'type': 'for_statement', 'children': ['36', '37', '38']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'required_files'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'if_statement', 'children': ['40', '55']}; {'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': 'os'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '54'], 'value': '+'}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '51'], 'value': '+'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'tomodir'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'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': 'needs_inversion'}; {'id': '59', 'type': 'False', 'children': []}; {'id': '60', 'type': 'if_statement', 'children': ['61', '82']}; {'id': '61', 'type': 'not_operator', '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': 'os'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'binary_operator', 'children': ['70', '81'], 'value': '+'}; {'id': '70', 'type': 'binary_operator', 'children': ['71', '78'], 'value': '+'}; {'id': '71', 'type': 'binary_operator', 'children': ['72', '77'], 'value': '+'}; {'id': '72', 'type': 'binary_operator', 'children': ['73', '74'], 'value': '+'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'tomodir'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'mod'"}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '81', 'type': 'string', 'children': [], 'value': "'volt.dat'"}; {'id': '82', 'type': 'block', 'children': ['83']}; {'id': '83', 'type': 'if_statement', 'children': ['84', '89']}; {'id': '84', 'type': 'not_operator', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'check_if_needs_modeling'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'tomodir'}; {'id': '89', 'type': 'block', 'children': ['90', '95']}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'string', 'children': [], 'value': "'no volt.dat and no modeling possible'"}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'needs_inversion'}; {'id': '98', 'type': 'False', 'children': []}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'inv_ctr_file'}; {'id': '102', 'type': 'binary_operator', 'children': ['103', '114'], 'value': '+'}; {'id': '103', 'type': 'binary_operator', 'children': ['104', '111'], 'value': '+'}; {'id': '104', 'type': 'binary_operator', 'children': ['105', '110'], 'value': '+'}; {'id': '105', 'type': 'binary_operator', 'children': ['106', '107'], 'value': '+'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'tomodir'}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '110', 'type': 'string', 'children': [], 'value': "'inv'"}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '114', 'type': 'string', 'children': [], 'value': "'inv.ctr'"}; {'id': '115', 'type': 'if_statement', 'children': ['116', '124']}; {'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': 'isfile'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'inv_ctr_file'}; {'id': '124', 'type': 'block', 'children': ['125', '137', '146']}; {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'assignment', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'inv_lines'}; {'id': '128', 'type': 'call', 'children': ['129', '136']}; {'id': '129', 'type': 'attribute', 'children': ['130', '135']}; {'id': '130', 'type': 'call', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '132', 'type': 'argument_list', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'inv_ctr_file'}; {'id': '134', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'readlines'}; {'id': '136', 'type': 'argument_list', 'children': []}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '140', 'type': 'argument_list', 'children': ['141', '142']}; {'id': '141', 'type': 'string', 'children': [], 'value': "'inv_lines'"}; {'id': '142', 'type': 'subscript', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'inv_lines'}; {'id': '144', 'type': 'unary_operator', 'children': ['145'], 'value': '-'}; {'id': '145', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '146', 'type': 'if_statement', 'children': ['147', '156']}; {'id': '147', 'type': 'call', 'children': ['148', '154']}; {'id': '148', 'type': 'attribute', 'children': ['149', '153']}; {'id': '149', 'type': 'subscript', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'inv_lines'}; {'id': '151', 'type': 'unary_operator', 'children': ['152'], 'value': '-'}; {'id': '152', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '154', 'type': 'argument_list', 'children': ['155']}; {'id': '155', 'type': 'string', 'children': [], 'value': "'***finished***'"}; {'id': '156', 'type': 'block', 'children': ['157']}; {'id': '157', 'type': 'expression_statement', 'children': ['158']}; {'id': '158', 'type': 'assignment', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'needs_inversion'}; {'id': '160', 'type': 'False', 'children': []}; {'id': '161', 'type': 'return_statement', 'children': ['162']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'needs_inversion'}
check of we need to run CRTomo in a given tomodir
def make_arg(key, annotation=None): arg = ast.arg(key, annotation) arg.lineno, arg.col_offset = 0, 0 return arg
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_arg'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'annotation'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '19', '31']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'annotation'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '28']}; {'id': '21', 'type': 'pattern_list', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'lineno'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'col_offset'}; {'id': '28', 'type': 'expression_list', 'children': ['29', '30']}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'arg'}
Make an ast function argument.
def connect(self, sock): def cbwrap(*args, **kwargs): self.callback(self.response_type, *args, **kwargs) self.sock = sock self.sock.subscribe(self.channel) self.sock.onchannel(self.channel, cbwrap)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connect'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '6', 'type': 'block', 'children': ['7', '28', '34', '45']}; {'id': '7', 'type': 'function_definition', 'children': ['8', '9', '14']}; {'id': '8', 'type': 'function_name', 'children': [], 'value': 'cbwrap'}; {'id': '9', 'type': 'parameters', 'children': ['10', '12']}; {'id': '10', 'type': 'list_splat_pattern', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '12', 'type': 'dictionary_splat_pattern', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': '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': 'callback'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '24', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'response_type'}; {'id': '24', 'type': 'list_splat', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '26', 'type': 'dictionary_splat', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '41']}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'subscribe'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'channel'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'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': 'sock'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'onchannel'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'channel'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'cbwrap'}
Attach a given socket to a channel
def _number_of_rows(self, start=0, count=100, **kwargs): first = str(start) last = str(start + count) string_format = ':'.join([first, last]) return string_format
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_number_of_rows'}; {'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': 'integer', 'children': [], 'value': '0'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '11', 'type': 'dictionary_splat_pattern', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '13', 'type': 'block', 'children': ['14', '21', '30', '41']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'last'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '+'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'string_format'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'list', 'children': ['39', '40'], 'value': '[first, last]'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'last'}; {'id': '41', 'type': 'return_statement', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'string_format'}
Internal method to format the number of rows the EPA API returns.
def read(path): data = None with open(path, 'r') as f: data = f.read() f.close() return data
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '30', '36']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'with_statement', 'children': ['11', '21']}; {'id': '11', 'type': 'with_clause', 'children': ['12']}; {'id': '12', 'type': 'with_item', 'children': ['13']}; {'id': '13', 'type': 'as_pattern', 'children': ['14', '19']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '19', 'type': 'as_pattern_target', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'data'}
Reads a file located at the given path.
def directory_values_generator(self, key): directory = self.directory(key) for key in directory: yield self.get(Key(key))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'directory_values_generator'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'block', 'children': ['7', '16']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '16', 'type': 'for_statement', 'children': ['17', '18', '19']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'yield', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Key'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'key'}
Retrieve directory values for given key.
def show_graphs(self): elements = itertools.chain.from_iterable( ([graph] for graph in self.visible_graphs.values())) self.graph_place_holder.original_widget = urwid.Pile(elements)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show_graphs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '28']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'elements'}; {'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': 'itertools'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'chain'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'from_iterable'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'generator_expression', 'children': ['17', '19']}; {'id': '17', 'type': 'list', 'children': ['18'], 'value': '[graph]'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'graph'}; {'id': '19', 'type': 'for_in_clause', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'graph'}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'visible_graphs'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '35']}; {'id': '30', 'type': 'attribute', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'graph_place_holder'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'original_widget'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'urwid'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'Pile'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'elements'}
Show a pile of the graph selected for dislpay
def update(self): if self._is_ignored or "tags" not in self._tag_group_dict: return for i in range(len(self._tag_group_dict["tags"])): tag_dict = self._tag_group_dict["tags"][i] for tag in self._tags: if tag.name == tag_dict["common.ALLTYPES_NAME"]: self._tag_group_dict["tags"][i] = tag.as_dict() break for i in range(len(self._sub_groups)): sub_group = self._sub_groups[i] sub_group.update() self._tag_group_dict["tag_groups"][i] = sub_group.as_dict()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '72']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '16']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '11'], 'value': 'or'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_is_ignored'}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': 'not in'}; {'id': '12', 'type': 'string', 'children': [], 'value': '"tags"'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_tag_group_dict'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'return_statement', 'children': []}; {'id': '18', 'type': 'for_statement', 'children': ['19', '20', '31']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'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': '_tag_group_dict'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"tags"'}; {'id': '31', 'type': 'block', 'children': ['32', '42']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'tag_dict'}; {'id': '35', 'type': 'subscript', 'children': ['36', '41']}; {'id': '36', 'type': 'subscript', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_tag_group_dict'}; {'id': '40', 'type': 'string', 'children': [], 'value': '"tags"'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '42', 'type': 'for_statement', 'children': ['43', '44', '47']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_tags'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'if_statement', 'children': ['49', '56']}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '53'], 'value': '=='}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'tag_dict'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"common.ALLTYPES_NAME"'}; {'id': '56', 'type': 'block', 'children': ['57', '71']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '66']}; {'id': '59', 'type': 'subscript', 'children': ['60', '65']}; {'id': '60', 'type': 'subscript', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': '_tag_group_dict'}; {'id': '64', 'type': 'string', 'children': [], 'value': '"tags"'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'as_dict'}; {'id': '70', 'type': 'argument_list', 'children': []}; {'id': '71', 'type': 'break_statement', 'children': []}; {'id': '72', 'type': 'for_statement', 'children': ['73', '74', '83']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': '_sub_groups'}; {'id': '83', 'type': 'block', 'children': ['84', '92', '98']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'sub_group'}; {'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': '_sub_groups'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'sub_group'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '97', 'type': 'argument_list', 'children': []}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '107']}; {'id': '100', 'type': 'subscript', 'children': ['101', '106']}; {'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': '_tag_group_dict'}; {'id': '105', 'type': 'string', 'children': [], 'value': '"tag_groups"'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '107', 'type': 'call', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'sub_group'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'as_dict'}; {'id': '111', 'type': 'argument_list', 'children': []}
Updates the dictionary of the tag group
def _startProcess(self): connectedDeferred = defer.Deferred() processProtocol = RelayProcessProtocol(connectedDeferred) self.inductor.execute(processProtocol, *self.inductorArgs) return connectedDeferred
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_startProcess'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '21', '34']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'connectedDeferred'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'defer'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Deferred'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'processProtocol'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'RelayProcessProtocol'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'connectedDeferred'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'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': 'inductor'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'processProtocol'}; {'id': '30', 'type': 'list_splat', 'children': ['31']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'inductorArgs'}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'connectedDeferred'}
Use the inductor to start the process we want to relay data from.
def find_user_by_username(self, username): return self.db_adapter.ifind_first_object(self.UserClass, username=username)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_user_by_username'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'db_adapter'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ifind_first_object'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'UserClass'}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'username'}
Find a User object by username.
def create_build_context(self, variant, build_type, build_path): request = variant.get_requires(build_requires=True, private_build_requires=True) req_strs = map(str, request) quoted_req_strs = map(quote, req_strs) self._print("Resolving build environment: %s", ' '.join(quoted_req_strs)) if build_type == BuildType.local: packages_path = self.package.config.packages_path else: packages_path = self.package.config.nonlocal_packages_path if self.package.config.is_overridden("package_filter"): from rez.package_filter import PackageFilterList data = self.package.config.package_filter package_filter = PackageFilterList.from_pod(data) else: package_filter = None context = ResolvedContext(request, package_paths=packages_path, package_filter=package_filter, building=True) if self.verbose: context.print_info() rxt_filepath = os.path.join(build_path, "build.rxt") context.save(rxt_filepath) if context.status != ResolverStatus.solved: raise BuildContextResolveError(context) return context, rxt_filepath
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_build_context'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'variant'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'build_type'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'build_path'}; {'id': '8', 'type': 'block', 'children': ['9', '23', '31', '39', '52', '81', '124', '140', '151', '163', '170', '184']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'variant'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get_requires'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '20']}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'build_requires'}; {'id': '19', 'type': 'True', 'children': []}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'private_build_requires'}; {'id': '22', 'type': 'True', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'req_strs'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'quoted_req_strs'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'quote'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'req_strs'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_print'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'string', 'children': [], 'value': '"Resolving build environment: %s"'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'quoted_req_strs'}; {'id': '52', 'type': 'if_statement', 'children': ['53', '58', '69']}; {'id': '53', 'type': 'comparison_operator', 'children': ['54', '55'], 'value': '=='}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'build_type'}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'BuildType'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'local'}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'packages_path'}; {'id': '62', 'type': 'attribute', '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': 'package'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'packages_path'}; {'id': '69', 'type': 'else_clause', 'children': ['70']}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'packages_path'}; {'id': '74', 'type': 'attribute', 'children': ['75', '80']}; {'id': '75', 'type': 'attribute', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'nonlocal_packages_path'}; {'id': '81', 'type': 'if_statement', 'children': ['82', '92', '118']}; {'id': '82', 'type': 'call', 'children': ['83', '90']}; {'id': '83', 'type': 'attribute', 'children': ['84', '89']}; {'id': '84', 'type': 'attribute', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'is_overridden'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'string', 'children': [], 'value': '"package_filter"'}; {'id': '92', 'type': 'block', 'children': ['93', '99', '109']}; {'id': '93', 'type': 'import_from_statement', 'children': ['94', '97']}; {'id': '94', 'type': 'dotted_name', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'rez'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'package_filter'}; {'id': '97', 'type': 'dotted_name', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'PackageFilterList'}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '102', 'type': 'attribute', 'children': ['103', '108']}; {'id': '103', 'type': 'attribute', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'package_filter'}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'package_filter'}; {'id': '112', 'type': 'call', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'PackageFilterList'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'from_pod'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '118', 'type': 'else_clause', 'children': ['119']}; {'id': '119', 'type': 'block', 'children': ['120']}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'assignment', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'package_filter'}; {'id': '123', 'type': 'None', 'children': []}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'assignment', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '127', 'type': 'call', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'ResolvedContext'}; {'id': '129', 'type': 'argument_list', 'children': ['130', '131', '134', '137']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '131', 'type': 'keyword_argument', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'package_paths'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'packages_path'}; {'id': '134', 'type': 'keyword_argument', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'package_filter'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'package_filter'}; {'id': '137', 'type': 'keyword_argument', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'building'}; {'id': '139', 'type': 'True', 'children': []}; {'id': '140', 'type': 'if_statement', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '144', 'type': 'block', 'children': ['145']}; {'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': 'context'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'print_info'}; {'id': '150', 'type': 'argument_list', 'children': []}; {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'assignment', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'rxt_filepath'}; {'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': 'os'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '160', 'type': 'argument_list', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'build_path'}; {'id': '162', 'type': 'string', 'children': [], 'value': '"build.rxt"'}; {'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': 'context'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '168', 'type': 'argument_list', 'children': ['169']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'rxt_filepath'}; {'id': '170', 'type': 'if_statement', 'children': ['171', '178']}; {'id': '171', 'type': 'comparison_operator', 'children': ['172', '175'], 'value': '!='}; {'id': '172', 'type': 'attribute', 'children': ['173', '174']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '175', 'type': 'attribute', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'ResolverStatus'}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'solved'}; {'id': '178', 'type': 'block', 'children': ['179']}; {'id': '179', 'type': 'raise_statement', 'children': ['180']}; {'id': '180', 'type': 'call', 'children': ['181', '182']}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'BuildContextResolveError'}; {'id': '182', 'type': 'argument_list', 'children': ['183']}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '184', 'type': 'return_statement', 'children': ['185']}; {'id': '185', 'type': 'expression_list', 'children': ['186', '187']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '187', 'type': 'identifier', 'children': [], 'value': 'rxt_filepath'}
Create a context to build the variant within.
def check_scalar(self, scalar_dict): table = {k: np.array([v]) for k, v in scalar_dict.items()} return self.mask(table)[0]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_scalar'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'scalar_dict'}; {'id': '6', 'type': 'block', 'children': ['7', '29']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '10', 'type': 'dictionary_comprehension', 'children': ['11', '20']}; {'id': '11', 'type': 'pair', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'list', 'children': ['19'], 'value': '[v]'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '20', 'type': 'for_in_clause', 'children': ['21', '24']}; {'id': '21', 'type': 'pattern_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'scalar_dict'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'subscript', 'children': ['31', '37']}; {'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': 'mask'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'}
check if `scalar_dict` satisfy query
async def logout(self, request): if "Authorization" not in request.headers: msg = "Auth header is not present, can not destroy token" raise JsonValidaitonError(msg) response = json_response() await forget(request, response) return response
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'logout'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'block', 'children': ['7', '23', '29', '36']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'not in'}; {'id': '9', 'type': 'string', 'children': [], 'value': '"Authorization"'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '13', 'type': 'block', 'children': ['14', '18']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '17', 'type': 'string', 'children': [], 'value': '"Auth header is not present, can not destroy token"'}; {'id': '18', 'type': 'raise_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'JsonValidaitonError'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'json_response'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'await', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'forget'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'response'}
Simple handler for logout
def _depth_im_callback(self, msg): try: self._cur_depth_im = DepthImage(self._bridge.imgmsg_to_cv2(msg) / 1000.0, frame=self._frame) except: self._cur_depth_im = None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_depth_im_callback'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'try_statement', 'children': ['8', '32']}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_cur_depth_im'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'DepthImage'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '27']}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '26'], 'value': '/'}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_bridge'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'imgmsg_to_cv2'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '26', 'type': 'float', 'children': [], 'value': '1000.0'}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_frame'}; {'id': '32', 'type': 'except_clause', 'children': ['33']}; {'id': '33', 'type': 'block', 'children': ['34']}; {'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': '_cur_depth_im'}; {'id': '39', 'type': 'None', 'children': []}
Callback for handling depth images.
def _find_usage_vpcs(self): vpcs = self.conn.describe_vpcs() self.limits['VPCs']._add_current_usage( len(vpcs['Vpcs']), aws_type='AWS::EC2::VPC' )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_find_usage_vpcs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'vpcs'}; {'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': 'conn'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'describe_vpcs'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '25']}; {'id': '18', 'type': 'attribute', 'children': ['19', '24']}; {'id': '19', 'type': 'subscript', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'limits'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'VPCs'"}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_add_current_usage'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '32']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'vpcs'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'Vpcs'"}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'aws_type'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'AWS::EC2::VPC'"}
find usage for VPCs
def _router_numbers(self): return tuple(up for up in self._up2down.keys() if up in self._up2down.values())
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_router_numbers'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '9', 'type': 'generator_expression', 'children': ['10', '11', '20']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'up'}; {'id': '11', 'type': 'for_in_clause', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'up'}; {'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': '_up2down'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'if_clause', 'children': ['21']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '23'], 'value': 'in'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'up'}; {'id': '23', 'type': 'call', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_up2down'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '29', 'type': 'argument_list', 'children': []}
A tuple of the numbers of all "routing" basins.
def replace(self, new_node): cur_node = self.cur_node nodestack = self.nodestack cur = nodestack.pop() prev = nodestack[-1] index = prev[-1] - 1 oldnode, name = prev[-2][index] assert cur[0] is cur_node is oldnode, (cur[0], cur_node, prev[-2], index) parent = prev[0] if isinstance(parent, list): parent[index] = new_node else: setattr(parent, name, new_node)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'replace'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'new_node'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '19', '27', '34', '43', '54', '71', '77']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'cur_node'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'cur_node'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'nodestack'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'nodestack'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'nodestack'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'prev'}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'nodestack'}; {'id': '32', 'type': 'unary_operator', 'children': ['33'], 'value': '-'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '42'], 'value': '-'}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'prev'}; {'id': '40', 'type': 'unary_operator', 'children': ['41'], 'value': '-'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '48']}; {'id': '45', 'type': 'pattern_list', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'oldnode'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '48', 'type': 'subscript', 'children': ['49', '53']}; {'id': '49', 'type': 'subscript', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'prev'}; {'id': '51', 'type': 'unary_operator', 'children': ['52'], 'value': '-'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '54', 'type': 'assert_statement', 'children': ['55', '61']}; {'id': '55', 'type': 'comparison_operator', 'children': ['56', '59', '60'], 'value': 'is'}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'cur_node'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'oldnode'}; {'id': '61', 'type': 'tuple', 'children': ['62', '65', '66', '70']}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '64', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'cur_node'}; {'id': '66', 'type': 'subscript', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'prev'}; {'id': '68', 'type': 'unary_operator', 'children': ['69'], 'value': '-'}; {'id': '69', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'prev'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '77', 'type': 'if_statement', 'children': ['78', '83', '90']}; {'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': 'parent'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'list'}; {'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': 'parent'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'new_node'}; {'id': '90', 'type': 'else_clause', 'children': ['91']}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'call', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '95', 'type': 'argument_list', 'children': ['96', '97', '98']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'new_node'}
Replace a node after first checking integrity of node stack.
def _save_sensitivities(self, directory): print('saving sensitivities') digits = int(np.ceil(np.log10(self.configs.configs.shape[0]))) for i in range(0, self.configs.configs.shape[0]): sens_data, meta_data = self.get_sensitivity(i) filename_raw = 'sens{0:0' + '{0}'.format(digits) + '}.dat' filename = directory + os.sep + filename_raw.format(i + 1) grid_xz = self.grid.get_element_centroids() all_data = np.vstack(( grid_xz[:, 0], grid_xz[:, 0], sens_data[0], sens_data[1], )).T with open(filename, 'wb') as fid: fid.write(bytes( '{0} {1}\n'.format(meta_data[0], meta_data[1]), 'utf-8' )) np.savetxt(fid, all_data)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_save_sensitivities'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '6', 'type': 'block', 'children': ['7', '12', '37']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'string', 'children': [], 'value': "'saving sensitivities'"}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'digits'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ceil'}; {'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': 'np'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'log10'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'subscript', 'children': ['29', '36']}; {'id': '29', 'type': 'attribute', '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': 'configs'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'configs'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '37', 'type': 'for_statement', 'children': ['38', '39', '52']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '43', 'type': 'subscript', 'children': ['44', '51']}; {'id': '44', 'type': 'attribute', 'children': ['45', '50']}; {'id': '45', 'type': 'attribute', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'configs'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'configs'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '52', 'type': 'block', 'children': ['53', '64', '77', '94', '104', '131']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '58']}; {'id': '55', 'type': 'pattern_list', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'sens_data'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'meta_data'}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'get_sensitivity'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'filename_raw'}; {'id': '67', 'type': 'binary_operator', 'children': ['68', '76'], 'value': '+'}; {'id': '68', 'type': 'binary_operator', 'children': ['69', '70'], 'value': '+'}; {'id': '69', 'type': 'string', 'children': [], 'value': "'sens{0:0'"}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': "'{0}'"}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'digits'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'}.dat'"}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '80', 'type': 'binary_operator', 'children': ['81', '86'], 'value': '+'}; {'id': '81', 'type': 'binary_operator', 'children': ['82', '83'], 'value': '+'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'filename_raw'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'binary_operator', 'children': ['92', '93'], 'value': '+'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '93', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'grid_xz'}; {'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': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'grid'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'get_element_centroids'}; {'id': '103', 'type': 'argument_list', 'children': []}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'assignment', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'all_data'}; {'id': '107', 'type': 'attribute', 'children': ['108', '130']}; {'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': 'vstack'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'tuple', 'children': ['114', '119', '124', '127']}; {'id': '114', 'type': 'subscript', 'children': ['115', '116', '118']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'grid_xz'}; {'id': '116', 'type': 'slice', 'children': ['117']}; {'id': '117', 'type': 'colon', 'children': []}; {'id': '118', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '119', 'type': 'subscript', 'children': ['120', '121', '123']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'grid_xz'}; {'id': '121', 'type': 'slice', 'children': ['122']}; {'id': '122', 'type': 'colon', 'children': []}; {'id': '123', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '124', 'type': 'subscript', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'sens_data'}; {'id': '126', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '127', 'type': 'subscript', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'sens_data'}; {'id': '129', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '131', 'type': 'with_statement', 'children': ['132', '142']}; {'id': '132', 'type': 'with_clause', 'children': ['133']}; {'id': '133', 'type': 'with_item', 'children': ['134']}; {'id': '134', 'type': 'as_pattern', 'children': ['135', '140']}; {'id': '135', 'type': 'call', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '137', 'type': 'argument_list', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '139', 'type': 'string', 'children': [], 'value': "'wb'"}; {'id': '140', 'type': 'as_pattern_target', 'children': ['141']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'fid'}; {'id': '142', 'type': 'block', 'children': ['143', '164']}; {'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': 'fid'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '148', 'type': 'argument_list', 'children': ['149']}; {'id': '149', 'type': 'call', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '151', 'type': 'argument_list', 'children': ['152', '163']}; {'id': '152', 'type': 'call', 'children': ['153', '156']}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'string', 'children': [], 'value': "'{0} {1}\\n'"}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '156', 'type': 'argument_list', 'children': ['157', '160']}; {'id': '157', 'type': 'subscript', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'meta_data'}; {'id': '159', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '160', 'type': 'subscript', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'meta_data'}; {'id': '162', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '163', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '164', 'type': 'expression_statement', 'children': ['165']}; {'id': '165', 'type': 'call', 'children': ['166', '169']}; {'id': '166', 'type': 'attribute', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'savetxt'}; {'id': '169', 'type': 'argument_list', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'fid'}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'all_data'}
save sensitivities to a directory
def probe(self, ipaddr=None): if ipaddr is None: ipaddr = self._broadcast_addr cmd = {"payloadtype": PayloadType.GET, "target": ipaddr} self._send_command(cmd)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'probe'}; {'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': 'ipaddr'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '20', '32']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'is'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ipaddr'}; {'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': 'ipaddr'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_broadcast_addr'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '23', 'type': 'dictionary', 'children': ['24', '29']}; {'id': '24', 'type': 'pair', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"payloadtype"'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'PayloadType'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'GET'}; {'id': '29', 'type': 'pair', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"target"'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ipaddr'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_send_command'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'cmd'}
Probe given address for bulb.
def serialize_compound(self, tag): separator, fmt = self.comma, '{{{}}}' with self.depth(): if self.should_expand(tag): separator, fmt = self.expand(separator, fmt) return fmt.format(separator.join( f'{self.stringify_compound_key(key)}{self.colon}{self.serialize(value)}' for key, value in tag.items() ))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'serialize_compound'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '6', 'type': 'block', 'children': ['7', '17']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '12']}; {'id': '9', 'type': 'pattern_list', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'separator'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '12', 'type': 'expression_list', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'comma'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'{{{}}}'"}; {'id': '17', 'type': 'with_statement', 'children': ['18', '25']}; {'id': '18', 'type': 'with_clause', 'children': ['19']}; {'id': '19', 'type': 'with_item', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'depth'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'block', 'children': ['26', '46']}; {'id': '26', 'type': 'if_statement', 'children': ['27', '33']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'should_expand'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '39']}; {'id': '36', 'type': 'pattern_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'separator'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'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': 'expand'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'separator'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'separator'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '56', 'type': 'generator_expression', 'children': ['57', '58']}; {'id': '57', 'type': 'string', 'children': [], 'value': "f'{self.stringify_compound_key(key)}{self.colon}{self.serialize(value)}'"}; {'id': '58', 'type': 'for_in_clause', 'children': ['59', '62']}; {'id': '59', 'type': 'pattern_list', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '66', 'type': 'argument_list', 'children': []}
Return the literal representation of a compound tag.
def projectname(self): if self._projectname is None: exps = self.config.experiments if self._experiment is not None and self._experiment in exps: return exps[self._experiment]['project'] try: self._projectname = list(self.config.projects.keys())[-1] except IndexError: raise ValueError( "No experiment has yet been created! Please run setup " "before.") return self._projectname
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'projectname'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '74']}; {'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': '_projectname'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '21', '42']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'exps'}; {'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': 'config'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'experiments'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '33']}; {'id': '22', 'type': 'boolean_operator', 'children': ['23', '28'], 'value': 'and'}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '27'], 'value': 'is not'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_experiment'}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '32'], 'value': 'in'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_experiment'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'exps'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'subscript', 'children': ['36', '41']}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'exps'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_experiment'}; {'id': '41', 'type': 'string', 'children': [], 'value': "'project'"}; {'id': '42', 'type': 'try_statement', 'children': ['43', '64']}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_projectname'}; {'id': '49', 'type': 'subscript', 'children': ['50', '62']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '61']}; {'id': '54', 'type': 'attribute', 'children': ['55', '60']}; {'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': 'config'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'projects'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'unary_operator', 'children': ['63'], 'value': '-'}; {'id': '63', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '64', 'type': 'except_clause', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'IndexError'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'raise_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'concatenated_string', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': '"No experiment has yet been created! Please run setup "'}; {'id': '73', 'type': 'string', 'children': [], 'value': '"before."'}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': '_projectname'}
The name of the project that is currently processed
def parse_nested( bels: list, char_locs: CharLocs, parsed: Parsed, errors: Errors ) -> Tuple[Parsed, Errors]: for sp in char_locs[ "nested_parens" ]: ep, level = char_locs["nested_parens"][sp] if ep == -1: ep = len(bels) + 1 parsed[(sp, ep)] = {"type": "Nested", "span": (sp, ep)} return parsed, errors
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20', '28']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_nested'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '12', '16']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'bels'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '8', 'type': 'typed_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'char_locs'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'CharLocs'}; {'id': '12', 'type': 'typed_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'Parsed'}; {'id': '16', 'type': 'typed_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '18', 'type': 'type', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'Errors'}; {'id': '20', 'type': 'type', 'children': ['21']}; {'id': '21', 'type': 'generic_type', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'Tuple'}; {'id': '23', 'type': 'type_parameter', 'children': ['24', '26']}; {'id': '24', 'type': 'type', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'Parsed'}; {'id': '26', 'type': 'type', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'Errors'}; {'id': '28', 'type': 'block', 'children': ['29', '76']}; {'id': '29', 'type': 'for_statement', 'children': ['30', '31', '34']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '31', 'type': 'subscript', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'char_locs'}; {'id': '33', 'type': 'string', 'children': [], 'value': '"nested_parens"'}; {'id': '34', 'type': 'block', 'children': ['35', '45', '60']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '40']}; {'id': '37', 'type': 'pattern_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'ep'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '40', 'type': 'subscript', 'children': ['41', '44']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'char_locs'}; {'id': '43', 'type': 'string', 'children': [], 'value': '"nested_parens"'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '45', 'type': 'if_statement', 'children': ['46', '50']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': '=='}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'ep'}; {'id': '48', 'type': 'unary_operator', 'children': ['49'], 'value': '-'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'ep'}; {'id': '54', 'type': 'binary_operator', 'children': ['55', '59'], 'value': '+'}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'bels'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '67']}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '64', 'type': 'tuple', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'ep'}; {'id': '67', 'type': 'dictionary', 'children': ['68', '71']}; {'id': '68', 'type': 'pair', 'children': ['69', '70']}; {'id': '69', 'type': 'string', 'children': [], 'value': '"type"'}; {'id': '70', 'type': 'string', 'children': [], 'value': '"Nested"'}; {'id': '71', 'type': 'pair', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': '"span"'}; {'id': '73', 'type': 'tuple', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'ep'}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'expression_list', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'errors'}
Parse nested BEL object
def WindowsSdkVersion(self): if self.vc_ver <= 9.0: return ('7.0', '6.1', '6.0a') elif self.vc_ver == 10.0: return ('7.1', '7.0a') elif self.vc_ver == 11.0: return ('8.0', '8.0a') elif self.vc_ver == 12.0: return ('8.1', '8.1a') elif self.vc_ver >= 14.0: return ('10.0', '8.1')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'WindowsSdkVersion'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12', '18', '29', '40', '51']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': '<='}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'vc_ver'}; {'id': '11', 'type': 'float', 'children': [], 'value': '9.0'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'tuple', 'children': ['15', '16', '17']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'7.0'"}; {'id': '16', 'type': 'string', 'children': [], 'value': "'6.1'"}; {'id': '17', 'type': 'string', 'children': [], 'value': "'6.0a'"}; {'id': '18', 'type': 'elif_clause', 'children': ['19', '24']}; {'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': 'vc_ver'}; {'id': '23', 'type': 'float', 'children': [], 'value': '10.0'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'tuple', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'7.1'"}; {'id': '28', 'type': 'string', 'children': [], 'value': "'7.0a'"}; {'id': '29', 'type': 'elif_clause', 'children': ['30', '35']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '34'], 'value': '=='}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'vc_ver'}; {'id': '34', 'type': 'float', 'children': [], 'value': '11.0'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'tuple', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'8.0'"}; {'id': '39', 'type': 'string', 'children': [], 'value': "'8.0a'"}; {'id': '40', 'type': 'elif_clause', 'children': ['41', '46']}; {'id': '41', 'type': 'comparison_operator', 'children': ['42', '45'], 'value': '=='}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'vc_ver'}; {'id': '45', 'type': 'float', 'children': [], 'value': '12.0'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'tuple', 'children': ['49', '50']}; {'id': '49', 'type': 'string', 'children': [], 'value': "'8.1'"}; {'id': '50', 'type': 'string', 'children': [], 'value': "'8.1a'"}; {'id': '51', 'type': 'elif_clause', 'children': ['52', '57']}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '56'], 'value': '>='}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'vc_ver'}; {'id': '56', 'type': 'float', 'children': [], 'value': '14.0'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'tuple', 'children': ['60', '61']}; {'id': '60', 'type': 'string', 'children': [], 'value': "'10.0'"}; {'id': '61', 'type': 'string', 'children': [], 'value': "'8.1'"}
Microsoft Windows SDK versions for specified MSVC++ version.
def generate_header_validator(headers, context, **kwargs): validators = ValidationDict() for header_definition in headers: header_processor = generate_value_processor( context=context, **header_definition ) header_validator = generate_object_validator( field_validators=construct_header_validators(header_definition, context=context), ) validators.add_property_validator( header_definition['name'], chain_reduce_partial( header_processor, header_validator, ), ) return generate_object_validator(field_validators=validators)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_header_validator'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '8', 'type': 'block', 'children': ['9', '15', '59']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'validators'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ValidationDict'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'for_statement', 'children': ['16', '17', '18']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'header_definition'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '18', 'type': 'block', 'children': ['19', '30', '45']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'header_processor'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'generate_value_processor'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '28']}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '28', 'type': 'dictionary_splat', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'header_definition'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'header_validator'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'generate_object_validator'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'field_validators'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'construct_header_validators'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'header_definition'}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'validators'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'add_property_validator'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '54']}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'header_definition'}; {'id': '53', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'chain_reduce_partial'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'header_processor'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'header_validator'}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'generate_object_validator'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'keyword_argument', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'field_validators'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'validators'}
Generates a validation function that will validate a dictionary of headers.
def listen(self, listener): for message in listener.listen(): try: data = json.loads(message['data']) if data['event'] in ('canceled', 'lock_lost', 'put'): self.kill(data['jid']) except: logger.exception('Pubsub error')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'listen'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'listener'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '9', '14']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'listener'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'listen'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'try_statement', 'children': ['16', '47']}; {'id': '16', 'type': 'block', 'children': ['17', '28']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'subscript', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '28', 'type': 'if_statement', 'children': ['29', '37']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '33'], 'value': 'in'}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'event'"}; {'id': '33', 'type': 'tuple', 'children': ['34', '35', '36']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'canceled'"}; {'id': '35', 'type': 'string', 'children': [], 'value': "'lock_lost'"}; {'id': '36', 'type': 'string', 'children': [], 'value': "'put'"}; {'id': '37', 'type': 'block', 'children': ['38']}; {'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': 'kill'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'jid'"}; {'id': '47', 'type': 'except_clause', 'children': ['48']}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'exception'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'Pubsub error'"}
Listen for events that affect our ownership of a job
def simple_locking(lock_id, expiration=None): def inner_decorator(function): def wrapper(*args, **kwargs): try: lock = Lock.acquire_lock(lock_id, expiration) except LockError: pass else: logger.debug('acquired lock: %s' % lock_id) try: return function(*args, **kwargs) except: raise finally: lock.release() return wraps(function)(wrapper) return inner_decorator
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'simple_locking'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'lock_id'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'expiration'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '78']}; {'id': '9', 'type': 'function_definition', 'children': ['10', '11', '13']}; {'id': '10', 'type': 'function_name', 'children': [], 'value': 'inner_decorator'}; {'id': '11', 'type': 'parameters', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'function'}; {'id': '13', 'type': 'block', 'children': ['14', '70']}; {'id': '14', 'type': 'function_definition', 'children': ['15', '16', '21']}; {'id': '15', 'type': 'function_name', 'children': [], 'value': 'wrapper'}; {'id': '16', 'type': 'parameters', 'children': ['17', '19']}; {'id': '17', 'type': 'list_splat_pattern', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '19', 'type': 'dictionary_splat_pattern', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'try_statement', 'children': ['23', '34', '38']}; {'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': 'lock'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'Lock'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'acquire_lock'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'lock_id'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'expiration'}; {'id': '34', 'type': 'except_clause', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'LockError'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'pass_statement', 'children': []}; {'id': '38', 'type': 'else_clause', 'children': ['39']}; {'id': '39', 'type': 'block', 'children': ['40', '49']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '48'], 'value': '%'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'acquired lock: %s'"}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'lock_id'}; {'id': '49', 'type': 'try_statement', 'children': ['50', '59', '62']}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'function'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '57']}; {'id': '55', 'type': 'list_splat', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '57', 'type': 'dictionary_splat', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '59', 'type': 'except_clause', 'children': ['60']}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'raise_statement', 'children': []}; {'id': '62', 'type': 'finally_clause', 'children': ['63']}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'lock'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'release'}; {'id': '69', 'type': 'argument_list', 'children': []}; {'id': '70', 'type': 'return_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '76']}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'wraps'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'function'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'wrapper'}; {'id': '78', 'type': 'return_statement', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'inner_decorator'}
A decorator that wraps a function in a single lock getting algorithm
def explode(prefix: str): def _app(i, e=None): if i is not None: return {k: v for (k, v) in iter_fields(i)}, None return i, e def iter_fields(event_field: Union[dict, list]): if type(event_field) is dict: for key, val in event_field.items(): yield (key, val) elif type(event_field) is list: for i, value in enumerate(event_field): for key, val in value.items(): if not i == 0: yield ("{}_{}".format(key, i), val) else: yield (key, val) return compose(_app, add_column_prefix(prefix))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'explode'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '8', 'type': 'block', 'children': ['9', '41', '129']}; {'id': '9', 'type': 'function_definition', 'children': ['10', '11', '16']}; {'id': '10', 'type': 'function_name', 'children': [], 'value': '_app'}; {'id': '11', 'type': 'parameters', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17', '37']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '21']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': 'is not'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'expression_list', 'children': ['24', '36']}; {'id': '24', 'type': 'dictionary_comprehension', 'children': ['25', '28']}; {'id': '25', 'type': 'pair', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '28', 'type': 'for_in_clause', 'children': ['29', '32']}; {'id': '29', 'type': 'tuple_pattern', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'iter_fields'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '36', 'type': 'None', 'children': []}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'expression_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '41', 'type': 'function_definition', 'children': ['42', '43', '54']}; {'id': '42', 'type': 'function_name', 'children': [], 'value': 'iter_fields'}; {'id': '43', 'type': 'parameters', 'children': ['44']}; {'id': '44', 'type': 'typed_parameter', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'event_field'}; {'id': '46', 'type': 'type', 'children': ['47']}; {'id': '47', 'type': 'generic_type', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'Union'}; {'id': '49', 'type': 'type_parameter', 'children': ['50', '52']}; {'id': '50', 'type': 'type', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '52', 'type': 'type', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'if_statement', 'children': ['56', '62', '78']}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '61'], 'value': 'is'}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'event_field'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'for_statement', 'children': ['64', '67', '72']}; {'id': '64', 'type': 'pattern_list', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'event_field'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '71', 'type': 'argument_list', 'children': []}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'yield', 'children': ['75']}; {'id': '75', 'type': 'tuple', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '78', 'type': 'elif_clause', 'children': ['79', '85']}; {'id': '79', 'type': 'comparison_operator', 'children': ['80', '84'], 'value': 'is'}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'event_field'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'for_statement', 'children': ['87', '90', '94']}; {'id': '87', 'type': 'pattern_list', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '90', 'type': 'call', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'event_field'}; {'id': '94', 'type': 'block', 'children': ['95']}; {'id': '95', 'type': 'for_statement', 'children': ['96', '99', '104']}; {'id': '96', 'type': 'pattern_list', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '103', 'type': 'argument_list', 'children': []}; {'id': '104', 'type': 'block', 'children': ['105']}; {'id': '105', 'type': 'if_statement', 'children': ['106', '110', '122']}; {'id': '106', 'type': 'not_operator', 'children': ['107']}; {'id': '107', 'type': 'comparison_operator', 'children': ['108', '109'], 'value': '=='}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '109', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '110', 'type': 'block', 'children': ['111']}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'yield', 'children': ['113']}; {'id': '113', 'type': 'tuple', 'children': ['114', '121']}; {'id': '114', 'type': 'call', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'string', 'children': [], 'value': '"{}_{}"'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '118', 'type': 'argument_list', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '122', 'type': 'else_clause', 'children': ['123']}; {'id': '123', 'type': 'block', 'children': ['124']}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'yield', 'children': ['126']}; {'id': '126', 'type': 'tuple', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '129', 'type': 'return_statement', 'children': ['130']}; {'id': '130', 'type': 'call', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'compose'}; {'id': '132', 'type': 'argument_list', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': '_app'}; {'id': '134', 'type': 'call', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'add_column_prefix'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'prefix'}
given an array of objects de-normalized into fields
def parse_version(str_): v = re.findall(r"\d+.\d+.\d+", str_) if v: return v[0] else: print("cannot parse string {}".format(str_)) raise KeyError
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_version'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'str_'}; {'id': '5', 'type': 'block', 'children': ['6', '16']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'findall'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': 'r"\\d+.\\d+.\\d+"'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'str_'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '18', '23']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '22', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '23', 'type': 'else_clause', 'children': ['24']}; {'id': '24', 'type': 'block', 'children': ['25', '35']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': '"cannot parse string {}"'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'str_'}; {'id': '35', 'type': 'raise_statement', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'KeyError'}
Parses the program's version from a python variable declaration.
def drop(self, ex): "helper for apply_sql in DropX case" if ex.name not in self: if ex.ifexists: return raise KeyError(ex.name) table_ = self[ex.name] parent = table_.parent_table if table_.child_tables: if not ex.cascade: raise table.IntegrityError('delete_parent_without_cascade',ex.name) self.cascade_delete(ex.name) else: del self[ex.name] if parent: parent.child_tables.remove(table_)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'drop'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '29', '37', '43', '81']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': '"helper for apply_sql in DropX case"'}; {'id': '9', 'type': 'if_statement', 'children': ['10', '15']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '14'], 'value': 'not in'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'block', 'children': ['16', '22']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ifexists'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'return_statement', 'children': []}; {'id': '22', 'type': 'raise_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'table_'}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'table_'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'parent_table'}; {'id': '43', 'type': 'if_statement', 'children': ['44', '47', '73']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'table_'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'child_tables'}; {'id': '47', 'type': 'block', 'children': ['48', '64']}; {'id': '48', 'type': 'if_statement', 'children': ['49', '53']}; {'id': '49', 'type': 'not_operator', 'children': ['50']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'cascade'}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'raise_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'IntegrityError'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'string', 'children': [], 'value': "'delete_parent_without_cascade'"}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'name'}; {'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': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'cascade_delete'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '73', 'type': 'else_clause', 'children': ['74']}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'delete_statement', 'children': ['76']}; {'id': '76', 'type': 'subscript', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '81', 'type': 'if_statement', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'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': 'parent'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'child_tables'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'table_'}
helper for apply_sql in DropX case
def export_modified_data(self): def export_modfield(value, is_modified_seq=True): try: return value.export_modified_data() except AttributeError: if is_modified_seq: return value if self.__modified_data__ is not None: return [export_modfield(value) for value in self.__modified_data__] return list(x for x in [export_modfield(value) for value in self.__original_data__] if x is not None)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'export_modified_data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '30', '48']}; {'id': '6', 'type': 'function_definition', 'children': ['7', '8', '13']}; {'id': '7', 'type': 'function_name', 'children': [], 'value': 'export_modfield'}; {'id': '8', 'type': 'parameters', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'is_modified_seq'}; {'id': '12', 'type': 'True', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'try_statement', 'children': ['15', '22']}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'export_modified_data'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'except_clause', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'if_statement', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'is_modified_seq'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '36']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '35'], 'value': 'is not'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '__modified_data__'}; {'id': '35', 'type': 'None', 'children': []}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'list_comprehension', 'children': ['39', '43']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'export_modfield'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '43', 'type': 'for_in_clause', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '__modified_data__'}; {'id': '48', 'type': 'return_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '51', 'type': 'generator_expression', 'children': ['52', '53', '65']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '53', 'type': 'for_in_clause', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '55', 'type': 'list_comprehension', 'children': ['56', '60']}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'export_modfield'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '60', 'type': 'for_in_clause', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '__original_data__'}; {'id': '65', 'type': 'if_clause', 'children': ['66']}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '68'], 'value': 'is not'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '68', 'type': 'None', 'children': []}
Retrieves the modified data in a jsoned form
def ToCategorizedPath(path_type, components): try: prefix = { PathInfo.PathType.OS: ("fs", "os"), PathInfo.PathType.TSK: ("fs", "tsk"), PathInfo.PathType.REGISTRY: ("registry",), PathInfo.PathType.TEMP: ("temp",), }[path_type] except KeyError: raise ValueError("Unknown path type: `%s`" % path_type) return "/".join(itertools.chain(prefix, components))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ToCategorizedPath'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path_type'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'components'}; {'id': '6', 'type': 'block', 'children': ['7', '59']}; {'id': '7', 'type': 'try_statement', 'children': ['8', '49']}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '12', 'type': 'subscript', 'children': ['13', '48']}; {'id': '13', 'type': 'dictionary', 'children': ['14', '23', '32', '40']}; {'id': '14', 'type': 'pair', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'PathInfo'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'PathType'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'OS'}; {'id': '20', 'type': 'tuple', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': '"fs"'}; {'id': '22', 'type': 'string', 'children': [], 'value': '"os"'}; {'id': '23', 'type': 'pair', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'PathInfo'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'PathType'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'TSK'}; {'id': '29', 'type': 'tuple', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"fs"'}; {'id': '31', 'type': 'string', 'children': [], 'value': '"tsk"'}; {'id': '32', 'type': 'pair', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'PathInfo'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'PathType'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'REGISTRY'}; {'id': '38', 'type': 'tuple', 'children': ['39']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"registry"'}; {'id': '40', 'type': 'pair', 'children': ['41', '46']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'PathInfo'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'PathType'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'TEMP'}; {'id': '46', 'type': 'tuple', 'children': ['47']}; {'id': '47', 'type': 'string', 'children': [], 'value': '"temp"'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'path_type'}; {'id': '49', 'type': 'except_clause', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'raise_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '58'], 'value': '%'}; {'id': '57', 'type': 'string', 'children': [], 'value': '"Unknown path type: `%s`"'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'path_type'}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'string', 'children': [], 'value': '"/"'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'itertools'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'chain'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'components'}
Translates a path type and a list of components to a categorized path.
def merge(cls, trees): first = trees[0] for tree in trees: first.update(tree) return first
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'trees'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '24']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '10', 'type': 'subscript', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'trees'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '16']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'trees'}; {'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': 'first'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'first'}
Merge a collection of AttrTree objects.
def _is_valid_cardinal(self, inpt, metadata): if not isinstance(inpt, int): return False if metadata.get_minimum_cardinal() and inpt < metadata.get_maximum_cardinal(): return False if metadata.get_maximum_cardinal() and inpt > metadata.get_minimum_cardinal(): return False if metadata.get_cardinal_set() and inpt not in metadata.get_cardinal_set(): return False else: return True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_is_valid_cardinal'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '35', '52']}; {'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': 'isinstance'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'False', 'children': []}; {'id': '18', 'type': 'if_statement', 'children': ['19', '32']}; {'id': '19', 'type': 'boolean_operator', 'children': ['20', '25'], 'value': 'and'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get_minimum_cardinal'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': '<'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'get_maximum_cardinal'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'False', 'children': []}; {'id': '35', 'type': 'if_statement', 'children': ['36', '49']}; {'id': '36', 'type': 'boolean_operator', 'children': ['37', '42'], 'value': 'and'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'get_maximum_cardinal'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': '>'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'get_minimum_cardinal'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'False', 'children': []}; {'id': '52', 'type': 'if_statement', 'children': ['53', '66', '69']}; {'id': '53', 'type': 'boolean_operator', 'children': ['54', '59'], 'value': 'and'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'get_cardinal_set'}; {'id': '58', 'type': 'argument_list', 'children': []}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '61'], 'value': 'not in'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'get_cardinal_set'}; {'id': '65', 'type': 'argument_list', 'children': []}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'return_statement', 'children': ['68']}; {'id': '68', 'type': 'False', 'children': []}; {'id': '69', 'type': 'else_clause', 'children': ['70']}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'True', 'children': []}
Checks if input is a valid cardinal value
def _get_func_nodes(): return [definition for definition in project_definitions.values() if isinstance(definition.node, ast.FunctionDef)]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_func_nodes'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5']}; {'id': '5', 'type': 'return_statement', 'children': ['6']}; {'id': '6', 'type': 'list_comprehension', 'children': ['7', '8', '15']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'definition'}; {'id': '8', 'type': 'for_in_clause', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'definition'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'project_definitions'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'if_clause', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'definition'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'FunctionDef'}
Get all function nodes.
def process_fasta(fasta, **kwargs): logging.info("Nanoget: Starting to collect statistics from a fasta file.") inputfasta = handle_compressed_input(fasta, file_type="fasta") return ut.reduce_memory_usage(pd.DataFrame( data=[len(rec) for rec in SeqIO.parse(inputfasta, "fasta")], columns=["lengths"] ).dropna())
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_fasta'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fasta'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '15', '25']}; {'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': 'logging'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"Nanoget: Starting to collect statistics from a fasta file."'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'inputfasta'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'handle_compressed_input'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'fasta'}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'file_type'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"fasta"'}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ut'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'reduce_memory_usage'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '59']}; {'id': '32', 'type': 'attribute', 'children': ['33', '58']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'pd'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'DataFrame'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '54']}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '40', 'type': 'list_comprehension', 'children': ['41', '45']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'rec'}; {'id': '45', 'type': 'for_in_clause', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'rec'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'SeqIO'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'parse'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'inputfasta'}; {'id': '53', 'type': 'string', 'children': [], 'value': '"fasta"'}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '56', 'type': 'list', 'children': ['57'], 'value': '["lengths"]'}; {'id': '57', 'type': 'string', 'children': [], 'value': '"lengths"'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'dropna'}; {'id': '59', 'type': 'argument_list', 'children': []}
Combine metrics extracted from a fasta file.
def _front_delta(self): if self.flags & self.NO_MOVE: return Separator(0, 0) if self.clicked and self.hovered: delta = 2 elif self.hovered and not self.flags & self.NO_HOVER: delta = 0 else: delta = 0 return Separator(delta, delta)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_front_delta'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '21', '58']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '14']}; {'id': '7', 'type': 'binary_operator', 'children': ['8', '11'], 'value': '&'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'flags'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'NO_MOVE'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Separator'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '29', '34', '52']}; {'id': '22', 'type': 'boolean_operator', 'children': ['23', '26'], 'value': 'and'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'clicked'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'hovered'}; {'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': 'delta'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '34', 'type': 'elif_clause', 'children': ['35', '47']}; {'id': '35', 'type': 'boolean_operator', 'children': ['36', '39'], 'value': 'and'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'hovered'}; {'id': '39', 'type': 'not_operator', 'children': ['40']}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '44'], 'value': '&'}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'flags'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'NO_HOVER'}; {'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': 'delta'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '52', 'type': 'else_clause', 'children': ['53']}; {'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': 'delta'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'Separator'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'delta'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'delta'}
Return the offset of the colored part.
def execute(self, proxy, method, args): try: result = getattr(proxy, method)(raw_xml=self.options.xml, *tuple(args)) except xmlrpc.ERRORS as exc: self.LOG.error("While calling %s(%s): %s" % (method, ", ".join(repr(i) for i in args), exc)) self.return_code = error.EX_NOINPUT if "not find" in getattr(exc, "faultString", "") else error.EX_DATAERR else: if not self.options.quiet: if self.options.repr: result = pformat(result) elif hasattr(result, "__iter__"): result = '\n'.join(i if isinstance(i, basestring) else pformat(i) for i in result) print(fmt.to_console(result))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execute'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'try_statement', 'children': ['10', '33', '86']}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '14', 'type': 'call', 'children': ['15', '20']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '28']}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'raw_xml'}; {'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': 'options'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'xml'}; {'id': '28', 'type': 'list_splat', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '33', 'type': 'except_clause', 'children': ['34', '40']}; {'id': '34', 'type': 'as_pattern', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'xmlrpc'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ERRORS'}; {'id': '38', 'type': 'as_pattern_target', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '40', 'type': 'block', 'children': ['41', '66']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '48']}; {'id': '43', 'type': 'attribute', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'LOG'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '51'], 'value': '%'}; {'id': '50', 'type': 'string', 'children': [], 'value': '"While calling %s(%s): %s"'}; {'id': '51', 'type': 'tuple', 'children': ['52', '53', '65']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'string', 'children': [], 'value': '", "'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '57', 'type': 'generator_expression', 'children': ['58', '62']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '62', 'type': 'for_in_clause', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'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': 'return_code'}; {'id': '71', 'type': 'conditional_expression', 'children': ['72', '75', '83'], 'value': 'if'}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'EX_NOINPUT'}; {'id': '75', 'type': 'comparison_operator', 'children': ['76', '77'], 'value': 'in'}; {'id': '76', 'type': 'string', 'children': [], 'value': '"not find"'}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '81', '82']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '81', 'type': 'string', 'children': [], 'value': '"faultString"'}; {'id': '82', 'type': 'string', 'children': [], 'value': '""'}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'EX_DATAERR'}; {'id': '86', 'type': 'else_clause', 'children': ['87']}; {'id': '87', 'type': 'block', 'children': ['88']}; {'id': '88', 'type': 'if_statement', 'children': ['89', '95']}; {'id': '89', 'type': 'not_operator', 'children': ['90']}; {'id': '90', 'type': 'attribute', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'quiet'}; {'id': '95', 'type': 'block', 'children': ['96', '139']}; {'id': '96', 'type': 'if_statement', 'children': ['97', '102', '110']}; {'id': '97', 'type': 'attribute', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '102', 'type': 'block', 'children': ['103']}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'assignment', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '106', 'type': 'call', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'pformat'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '110', 'type': 'elif_clause', 'children': ['111', '116']}; {'id': '111', 'type': 'call', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '113', 'type': 'argument_list', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '115', 'type': 'string', 'children': [], 'value': '"__iter__"'}; {'id': '116', 'type': 'block', 'children': ['117']}; {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'assignment', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '120', 'type': 'call', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '124', 'type': 'generator_expression', 'children': ['125', '136']}; {'id': '125', 'type': 'conditional_expression', 'children': ['126', '127', '132'], 'value': 'if'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '127', 'type': 'call', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '129', 'type': 'argument_list', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'basestring'}; {'id': '132', 'type': 'call', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'pformat'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '136', 'type': 'for_in_clause', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'call', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'print'}; {'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': 'fmt'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'to_console'}; {'id': '147', 'type': 'argument_list', 'children': ['148']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'result'}
Execute given XMLRPC call.
def export_public_key(user_id, env=None, sp=subprocess): args = gpg_command(['--export', user_id]) result = check_output(args=args, env=env, sp=sp) if not result: log.error('could not find public key %r in local GPG keyring', user_id) raise KeyError(user_id) return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'export_public_key'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '11', 'type': 'block', 'children': ['12', '21', '36', '53']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'gpg_command'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'list', 'children': ['19', '20'], 'value': "['--export', user_id]"}; {'id': '19', 'type': 'string', 'children': [], 'value': "'--export'"}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'check_output'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '30', '33']}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '39']}; {'id': '37', 'type': 'not_operator', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '39', 'type': 'block', 'children': ['40', '48']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'could not find public key %r in local GPG keyring'"}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '48', 'type': 'raise_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'result'}
Export GPG public key for specified `user_id`.
def _convert_series(self, metric, ts): series = monitoring_v3.types.TimeSeries() series.metric.type = self.get_metric_type(metric.descriptor) for lk, lv in self.options.default_monitoring_labels.items(): series.metric.labels[lk.key] = lv.value for key, val in zip(metric.descriptor.label_keys, ts.label_values): if val.value is not None: safe_key = sanitize_label(key.key) series.metric.labels[safe_key] = val.value set_monitored_resource(series, self.options.resource) for point in ts.points: sd_point = series.points.add() self._convert_point(metric, ts, point, sd_point) return series
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_series'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ts'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '33', '61', '105', '115', '141']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'series'}; {'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': 'monitoring_v3'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'types'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'TimeSeries'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'series'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'type'}; {'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': 'get_metric_type'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '33', 'type': 'for_statement', 'children': ['34', '37', '46']}; {'id': '34', 'type': 'pattern_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'lk'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'lv'}; {'id': '37', 'type': 'call', 'children': ['38', '45']}; {'id': '38', 'type': 'attribute', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'default_monitoring_labels'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '58']}; {'id': '49', 'type': 'subscript', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'series'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'lk'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'lv'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '61', 'type': 'for_statement', 'children': ['62', '65', '76']}; {'id': '62', 'type': 'pattern_list', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '73']}; {'id': '68', 'type': 'attribute', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'label_keys'}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'ts'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'label_values'}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'if_statement', 'children': ['78', '83']}; {'id': '78', 'type': 'comparison_operator', 'children': ['79', '82'], 'value': 'is not'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '82', 'type': 'None', 'children': []}; {'id': '83', 'type': 'block', 'children': ['84', '93']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'safe_key'}; {'id': '87', 'type': 'call', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'sanitize_label'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '102']}; {'id': '95', 'type': 'subscript', 'children': ['96', '101']}; {'id': '96', 'type': 'attribute', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'series'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'safe_key'}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'call', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'set_monitored_resource'}; {'id': '108', 'type': 'argument_list', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'series'}; {'id': '110', 'type': 'attribute', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '115', 'type': 'for_statement', 'children': ['116', '117', '120']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'point'}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'ts'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'points'}; {'id': '120', 'type': 'block', 'children': ['121', '131']}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'assignment', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'sd_point'}; {'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': 'series'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'points'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '130', 'type': 'argument_list', 'children': []}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'call', 'children': ['133', '136']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': '_convert_point'}; {'id': '136', 'type': 'argument_list', 'children': ['137', '138', '139', '140']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'ts'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'point'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'sd_point'}; {'id': '141', 'type': 'return_statement', 'children': ['142']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'series'}
Convert an OC timeseries to a SD series.
def draw(self): from onshapepy import Part CAD = Part( 'https://cad.onshape.com/documents/b4cfd328713460beeb3125ac/w/3928b5c91bb0a0be7858d99e/e/6f2eeada21e494cebb49515f' ) CAD.params = { 'channel_L': self.channel_L, 'channel_W': self.channel_W, 'channel_H': self.downstream_H, 'channel_pairs': self.channel_n/2, 'baffle_S': self.baffle_S, }
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'draw'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '11', '18']}; {'id': '6', 'type': 'import_from_statement', 'children': ['7', '9']}; {'id': '7', 'type': 'dotted_name', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'onshapepy'}; {'id': '9', 'type': 'dotted_name', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Part'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'CAD'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'Part'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'https://cad.onshape.com/documents/b4cfd328713460beeb3125ac/w/3928b5c91bb0a0be7858d99e/e/6f2eeada21e494cebb49515f'"}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'CAD'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '23', 'type': 'dictionary', 'children': ['24', '29', '34', '39', '46']}; {'id': '24', 'type': 'pair', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'channel_L'"}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'channel_L'}; {'id': '29', 'type': 'pair', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'channel_W'"}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'channel_W'}; {'id': '34', 'type': 'pair', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'channel_H'"}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'downstream_H'}; {'id': '39', 'type': 'pair', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': "'channel_pairs'"}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '45'], 'value': '/'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'channel_n'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '46', 'type': 'pair', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': "'baffle_S'"}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'baffle_S'}
Draw the Onshape flocculator model based off of this object.
def pytorch_id(node): return node.scopeName() + "/outputs/" + "/".join([o.uniqueName() for o in node.outputs()])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pytorch_id'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'binary_operator', 'children': ['8', '15'], 'value': '+'}; {'id': '8', 'type': 'binary_operator', 'children': ['9', '14'], 'value': '+'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'scopeName'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'string', 'children': [], 'value': '"/outputs/"'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"/"'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'list_comprehension', 'children': ['21', '26']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'uniqueName'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'for_in_clause', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'outputs'}; {'id': '32', 'type': 'argument_list', 'children': []}
Returns a unique ID for a node.
def _addconfig(config, *paths): for path in paths: if path is not None and exists(path): config.append(path)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_addconfig'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '5', 'type': 'list_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'for_statement', 'children': ['9', '10', '11']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '21']}; {'id': '13', 'type': 'boolean_operator', 'children': ['14', '17'], 'value': 'and'}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '16'], 'value': 'is not'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'path'}
Add path to CONF_DIRS if exists.
def init(self): self._context_notify_cb = pa_context_notify_cb_t( self.context_notify_cb) self._sink_info_cb = pa_sink_info_cb_t(self.sink_info_cb) self._update_cb = pa_context_subscribe_cb_t(self.update_cb) self._success_cb = pa_context_success_cb_t(self.success_cb) self._server_info_cb = pa_server_info_cb_t(self.server_info_cb) _mainloop = pa_threaded_mainloop_new() _mainloop_api = pa_threaded_mainloop_get_api(_mainloop) context = pa_context_new(_mainloop_api, "i3pystatus_pulseaudio".encode("ascii")) pa_context_set_state_callback(context, self._context_notify_cb, None) pa_context_connect(context, None, 0, None) pa_threaded_mainloop_start(_mainloop) self.colors = self.get_hex_color_range(self.color_muted, self.color_unmuted, 100) self.sinks = []
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '28', '39', '50', '61', '67', '74', '87', '96', '104', '109', '126']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_context_notify_cb'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'pa_context_notify_cb_t'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'context_notify_cb'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_sink_info_cb'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pa_sink_info_cb_t'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'sink_info_cb'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_update_cb'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'pa_context_subscribe_cb_t'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'update_cb'}; {'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': '_success_cb'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'pa_context_success_cb_t'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'success_cb'}; {'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': '_server_info_cb'}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'pa_server_info_cb_t'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'server_info_cb'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': '_mainloop'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'pa_threaded_mainloop_new'}; {'id': '66', 'type': 'argument_list', 'children': []}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': '_mainloop_api'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'pa_threaded_mainloop_get_api'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': '_mainloop'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'pa_context_new'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': '_mainloop_api'}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'string', 'children': [], 'value': '"i3pystatus_pulseaudio"'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'string', 'children': [], 'value': '"ascii"'}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'pa_context_set_state_callback'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92', '95']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': '_context_notify_cb'}; {'id': '95', 'type': 'None', 'children': []}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'call', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'pa_context_connect'}; {'id': '99', 'type': 'argument_list', 'children': ['100', '101', '102', '103']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '101', 'type': 'None', 'children': []}; {'id': '102', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '103', 'type': 'None', 'children': []}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'pa_threaded_mainloop_start'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': '_mainloop'}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'colors'}; {'id': '114', 'type': 'call', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'get_hex_color_range'}; {'id': '118', 'type': 'argument_list', 'children': ['119', '122', '125']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'color_muted'}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'color_unmuted'}; {'id': '125', 'type': 'integer', 'children': [], 'value': '100'}; {'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': 'sinks'}; {'id': '131', 'type': 'list', 'children': [], 'value': '[]'}
Creates context, when context is ready context_notify_cb is called
def diagonalSize(self): szs = [a.diagonalSize() for a in self.actors] return np.max(szs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'diagonalSize'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'szs'}; {'id': '9', 'type': 'list_comprehension', 'children': ['10', '15']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'diagonalSize'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'for_in_clause', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'actors'}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'szs'}
Return the maximum diagonal size of the ``Actors`` of the ``Assembly``.
def _tscube_app(self, xmlfile): xmlfile = self.get_model_path(xmlfile) outfile = os.path.join(self.config['fileio']['workdir'], 'tscube%s.fits' % (self.config['file_suffix'])) kw = dict(cmap=self.files['ccube'], expcube=self.files['ltcube'], bexpmap=self.files['bexpmap'], irfs=self.config['gtlike']['irfs'], evtype=self.config['selection']['evtype'], srcmdl=xmlfile, nxpix=self.npix, nypix=self.npix, binsz=self.config['binning']['binsz'], xref=float(self.roi.skydir.ra.deg), yref=float(self.roi.skydir.dec.deg), proj=self.config['binning']['proj'], stlevel=0, coordsys=self.config['binning']['coordsys'], outfile=outfile) run_gtapp('gttscube', self.logger, kw)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_tscube_app'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'xmlfile'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '41', '160']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'xmlfile'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get_model_path'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'xmlfile'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'outfile'}; {'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', '33']}; {'id': '26', 'type': 'subscript', 'children': ['27', '32']}; {'id': '27', 'type': 'subscript', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'fileio'"}; {'id': '32', 'type': 'string', 'children': [], 'value': "'workdir'"}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '35'], 'value': '%'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'tscube%s.fits'"}; {'id': '35', 'type': '()', 'children': ['36']}; {'id': '36', 'type': 'subscript', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'file_suffix'"}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '54', '61', '68', '77', '86', '89', '94', '99', '108', '122', '136', '145', '148', '157']}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'cmap'}; {'id': '49', 'type': 'subscript', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '53', 'type': 'string', 'children': [], 'value': "'ccube'"}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'expcube'}; {'id': '56', 'type': 'subscript', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '60', 'type': 'string', 'children': [], 'value': "'ltcube'"}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'bexpmap'}; {'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': 'files'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'bexpmap'"}; {'id': '68', 'type': 'keyword_argument', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'irfs'}; {'id': '70', 'type': 'subscript', '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': 'config'}; {'id': '75', 'type': 'string', 'children': [], 'value': "'gtlike'"}; {'id': '76', 'type': 'string', 'children': [], 'value': "'irfs'"}; {'id': '77', 'type': 'keyword_argument', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'evtype'}; {'id': '79', 'type': 'subscript', 'children': ['80', '85']}; {'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': 'config'}; {'id': '84', 'type': 'string', 'children': [], 'value': "'selection'"}; {'id': '85', 'type': 'string', 'children': [], 'value': "'evtype'"}; {'id': '86', 'type': 'keyword_argument', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'srcmdl'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'xmlfile'}; {'id': '89', 'type': 'keyword_argument', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'nxpix'}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'npix'}; {'id': '94', 'type': 'keyword_argument', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'nypix'}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'npix'}; {'id': '99', 'type': 'keyword_argument', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'binsz'}; {'id': '101', 'type': 'subscript', 'children': ['102', '107']}; {'id': '102', 'type': 'subscript', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '106', 'type': 'string', 'children': [], 'value': "'binning'"}; {'id': '107', 'type': 'string', 'children': [], 'value': "'binsz'"}; {'id': '108', 'type': 'keyword_argument', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'xref'}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'attribute', 'children': ['114', '121']}; {'id': '114', 'type': 'attribute', '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': 'roi'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'skydir'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'ra'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'deg'}; {'id': '122', 'type': 'keyword_argument', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'yref'}; {'id': '124', 'type': 'call', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'attribute', 'children': ['128', '135']}; {'id': '128', 'type': 'attribute', 'children': ['129', '134']}; {'id': '129', 'type': 'attribute', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'roi'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'skydir'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'dec'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'deg'}; {'id': '136', 'type': 'keyword_argument', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'proj'}; {'id': '138', 'type': 'subscript', 'children': ['139', '144']}; {'id': '139', 'type': 'subscript', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '143', 'type': 'string', 'children': [], 'value': "'binning'"}; {'id': '144', 'type': 'string', 'children': [], 'value': "'proj'"}; {'id': '145', 'type': 'keyword_argument', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'stlevel'}; {'id': '147', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '148', 'type': 'keyword_argument', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'coordsys'}; {'id': '150', 'type': 'subscript', 'children': ['151', '156']}; {'id': '151', 'type': 'subscript', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '155', 'type': 'string', 'children': [], 'value': "'binning'"}; {'id': '156', 'type': 'string', 'children': [], 'value': "'coordsys'"}; {'id': '157', 'type': 'keyword_argument', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'outfile'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'outfile'}; {'id': '160', 'type': 'expression_statement', 'children': ['161']}; {'id': '161', 'type': 'call', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'run_gtapp'}; {'id': '163', 'type': 'argument_list', 'children': ['164', '165', '168']}; {'id': '164', 'type': 'string', 'children': [], 'value': "'gttscube'"}; {'id': '165', 'type': 'attribute', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'kw'}
Run gttscube as an application.
def main(): parser = argparse.ArgumentParser( description='Relocate a virtual environment.' ) parser.add_argument( '--source', help='The existing virtual environment.', required=True, ) parser.add_argument( '--destination', help='The location for which to configure the virtual environment.', required=True, ) parser.add_argument( '--move', help='Move the virtual environment to the destination.', default=False, action='store_true', ) args = parser.parse_args() relocate(args.source, args.destination, args.move)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '16', '29', '42', '58', '66']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'argparse'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ArgumentParser'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'keyword_argument', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '15', 'type': 'string', 'children': [], 'value': "'Relocate a virtual environment.'"}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'add_argument'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23', '26']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'--source'"}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'The existing virtual environment.'"}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '28', 'type': 'True', 'children': []}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'add_argument'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36', '39']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'--destination'"}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'The location for which to configure the virtual environment.'"}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '41', 'type': 'True', 'children': []}; {'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': 'parser'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'add_argument'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49', '52', '55']}; {'id': '48', 'type': 'string', 'children': [], 'value': "'--move'"}; {'id': '49', 'type': 'keyword_argument', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '51', 'type': 'string', 'children': [], 'value': "'Move the virtual environment to the destination.'"}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '54', 'type': 'False', 'children': []}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '57', 'type': 'string', 'children': [], 'value': "'store_true'"}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'parse_args'}; {'id': '65', 'type': 'argument_list', 'children': []}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'relocate'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '73', '76']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'destination'}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'move'}
Relocate a virtual environment.
def _variable_type_to_read_fn(vartype, records): fn_map = {"String": "read_string", "Array[String]": "read_lines", "Array[Array[String]]": "read_tsv", "Object": "read_object", "Array[Object]": "read_objects", "Array[Array[Object]]": "read_objects", "Int": "read_int", "Float": "read_float"} for rec_name in records.keys(): fn_map["%s" % rec_name] = "read_struct" fn_map["Array[%s]" % rec_name] = "read_struct" fn_map["Array[Array[%s]]" % rec_name] = "read_struct" vartype = vartype.replace("File", "String") vartype = vartype.replace("Array[Int]", "Array[String]") vartype = vartype.replace("Array[Float]", "Array[String]") return fn_map[vartype]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_variable_type_to_read_fn'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'records'}; {'id': '6', 'type': 'block', 'children': ['7', '35', '67', '77', '87', '97']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'fn_map'}; {'id': '10', 'type': 'dictionary', 'children': ['11', '14', '17', '20', '23', '26', '29', '32']}; {'id': '11', 'type': 'pair', 'children': ['12', '13']}; {'id': '12', 'type': 'string', 'children': [], 'value': '"String"'}; {'id': '13', 'type': 'string', 'children': [], 'value': '"read_string"'}; {'id': '14', 'type': 'pair', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"Array[String]"'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"read_lines"'}; {'id': '17', 'type': 'pair', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"Array[Array[String]]"'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"read_tsv"'}; {'id': '20', 'type': 'pair', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': '"Object"'}; {'id': '22', 'type': 'string', 'children': [], 'value': '"read_object"'}; {'id': '23', 'type': 'pair', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': '"Array[Object]"'}; {'id': '25', 'type': 'string', 'children': [], 'value': '"read_objects"'}; {'id': '26', 'type': 'pair', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"Array[Array[Object]]"'}; {'id': '28', 'type': 'string', 'children': [], 'value': '"read_objects"'}; {'id': '29', 'type': 'pair', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"Int"'}; {'id': '31', 'type': 'string', 'children': [], 'value': '"read_int"'}; {'id': '32', 'type': 'pair', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': '"Float"'}; {'id': '34', 'type': 'string', 'children': [], 'value': '"read_float"'}; {'id': '35', 'type': 'for_statement', 'children': ['36', '37', '42']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'rec_name'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'records'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'block', 'children': ['43', '51', '59']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '50']}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'fn_map'}; {'id': '47', 'type': 'binary_operator', 'children': ['48', '49'], 'value': '%'}; {'id': '48', 'type': 'string', 'children': [], 'value': '"%s"'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'rec_name'}; {'id': '50', 'type': 'string', 'children': [], 'value': '"read_struct"'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '58']}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'fn_map'}; {'id': '55', 'type': 'binary_operator', 'children': ['56', '57'], 'value': '%'}; {'id': '56', 'type': 'string', 'children': [], 'value': '"Array[%s]"'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'rec_name'}; {'id': '58', 'type': 'string', 'children': [], 'value': '"read_struct"'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '66']}; {'id': '61', 'type': 'subscript', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'fn_map'}; {'id': '63', 'type': 'binary_operator', 'children': ['64', '65'], 'value': '%'}; {'id': '64', 'type': 'string', 'children': [], 'value': '"Array[Array[%s]]"'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'rec_name'}; {'id': '66', 'type': 'string', 'children': [], 'value': '"read_struct"'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '76']}; {'id': '75', 'type': 'string', 'children': [], 'value': '"File"'}; {'id': '76', 'type': 'string', 'children': [], 'value': '"String"'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '86']}; {'id': '85', 'type': 'string', 'children': [], 'value': '"Array[Int]"'}; {'id': '86', 'type': 'string', 'children': [], 'value': '"Array[String]"'}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '96']}; {'id': '95', 'type': 'string', 'children': [], 'value': '"Array[Float]"'}; {'id': '96', 'type': 'string', 'children': [], 'value': '"Array[String]"'}; {'id': '97', 'type': 'return_statement', 'children': ['98']}; {'id': '98', 'type': 'subscript', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'fn_map'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'vartype'}
Convert variant types into corresponding WDL standard library functions.
def reload_list(self): self.leetcode.load() if self.leetcode.quizzes and len(self.leetcode.quizzes) > 0: self.home_view = self.make_listview(self.leetcode.quizzes) self.view_stack = [] self.goto_view(self.home_view)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reload_list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'leetcode'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'if_statement', 'children': ['15', '31']}; {'id': '15', 'type': 'boolean_operator', 'children': ['16', '21'], 'value': 'and'}; {'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': 'leetcode'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'quizzes'}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '30'], 'value': '>'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'leetcode'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'quizzes'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '31', 'type': 'block', 'children': ['32', '47', '53']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'home_view'}; {'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': 'make_listview'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'leetcode'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'quizzes'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'view_stack'}; {'id': '52', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'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': 'goto_view'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'home_view'}
Press R in home view to retrieve quiz list
def getParameterByName(self, name): result = None for parameter in self.getParameters(): nameParam = parameter.getName() if nameParam == name: result = parameter break return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getParameterByName'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '37']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'for_statement', 'children': ['12', '13', '18']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'parameter'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'getParameters'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19', '27']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'nameParam'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'parameter'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'getName'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'if_statement', 'children': ['28', '31']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '30'], 'value': '=='}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'nameParam'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '31', 'type': 'block', 'children': ['32', '36']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'parameter'}; {'id': '36', 'type': 'break_statement', 'children': []}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'result'}
Searchs a parameter by name and returns it.
def afni_copy(filename): if nl.pkg_available('afni',True): afni_filename = "%s+orig" % nl.prefix(filename) if not os.path.exists(afni_filename + ".HEAD"): nl.calc(filename,'a',prefix=nl.prefix(filename)) return afni_filename
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'afni_copy'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '14']}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'nl'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'pkg_available'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'string', 'children': [], 'value': "'afni'"}; {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '26', '55']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'afni_filename'}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '20'], 'value': '%'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"%s+orig"'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'nl'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '38']}; {'id': '27', 'type': 'not_operator', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '34']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '37'], 'value': '+'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'afni_filename'}; {'id': '37', 'type': 'string', 'children': [], 'value': '".HEAD"'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'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': 'nl'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'calc'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46', '47']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'a'"}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'nl'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '55', 'type': 'return_statement', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'afni_filename'}
creates a ``+orig`` copy of the given dataset and returns the filename as a string
def build(self, words): words = [self._normalize(tokens) for tokens in words] self._dawg = dawg.CompletionDAWG(words) self._loaded_model = True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'words'}; {'id': '6', 'type': 'block', 'children': ['7', '20', '31']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'words'}; {'id': '10', 'type': 'list_comprehension', 'children': ['11', '17']}; {'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': '_normalize'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '17', 'type': 'for_in_clause', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'words'}; {'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': '_dawg'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dawg'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'CompletionDAWG'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'words'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_loaded_model'}; {'id': '36', 'type': 'True', 'children': []}
Construct dictionary DAWG from tokenized words.
def addSubparser(subparsers, subcommand, description): parser = subparsers.add_parser( subcommand, description=description, help=description) return parser
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'addSubparser'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'subparsers'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'subcommand'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '7', 'type': 'block', 'children': ['8', '23']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'subparsers'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'add_parser'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17', '20']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'subcommand'}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'parser'}
Add a subparser with subcommand to the subparsers object
def getApplicationsErrorNameFromEnum(self, error): fn = self.function_table.getApplicationsErrorNameFromEnum result = fn(error) return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getApplicationsErrorNameFromEnum'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '22']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'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': 'function_table'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'getApplicationsErrorNameFromEnum'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'result'}
Returns a string for an applications error
def _handle_continuations(self, response, cache_key): rcontinue = response.get('continue') listen = ['blcontinue', 'cmcontinue', 'plcontinue'] cparams = {} if rcontinue: for flag in listen: if rcontinue.get(flag): cparams[flag] = rcontinue.get(flag) if cparams: self.data['continue'] = cparams del self.cache[cache_key] else: if 'continue' in self.data: del self.data['continue']
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_handle_continuations'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'cache_key'}; {'id': '7', 'type': 'block', 'children': ['8', '17', '24', '28', '54']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'rcontinue'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'continue'"}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'listen'}; {'id': '20', 'type': 'list', 'children': ['21', '22', '23'], 'value': "['blcontinue', 'cmcontinue', 'plcontinue']"}; {'id': '21', 'type': 'string', 'children': [], 'value': "'blcontinue'"}; {'id': '22', 'type': 'string', 'children': [], 'value': "'cmcontinue'"}; {'id': '23', 'type': 'string', 'children': [], 'value': "'plcontinue'"}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'cparams'}; {'id': '27', 'type': 'dictionary', 'children': []}; {'id': '28', 'type': 'if_statement', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'rcontinue'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'for_statement', 'children': ['32', '33', '34']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'flag'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'listen'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'if_statement', 'children': ['36', '42']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'rcontinue'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'flag'}; {'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': 'cparams'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'flag'}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'rcontinue'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'flag'}; {'id': '54', 'type': 'if_statement', 'children': ['55', '56', '71']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'cparams'}; {'id': '56', 'type': 'block', 'children': ['57', '65']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '64']}; {'id': '59', 'type': 'subscript', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '63', 'type': 'string', 'children': [], 'value': "'continue'"}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'cparams'}; {'id': '65', 'type': 'delete_statement', 'children': ['66']}; {'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': 'cache'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'cache_key'}; {'id': '71', 'type': 'else_clause', 'children': ['72']}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'if_statement', 'children': ['74', '79']}; {'id': '74', 'type': 'comparison_operator', 'children': ['75', '76'], 'value': 'in'}; {'id': '75', 'type': 'string', 'children': [], 'value': "'continue'"}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '79', 'type': 'block', 'children': ['80']}; {'id': '80', 'type': 'delete_statement', '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': 'data'}; {'id': '85', 'type': 'string', 'children': [], 'value': "'continue'"}
Select continue params and clear cache or last continue params
def alignment(self): if self._arch is None: return NotImplemented return self.size // self._arch.byte_width
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'alignment'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15']}; {'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': '_arch'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'NotImplemented'}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '20'], 'value': '//'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_arch'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'byte_width'}
The alignment of the type in bytes.
def sections_count(self): if not self._ptr: raise BfdException("BFD not initialized") return _bfd.get_bfd_attribute(self._ptr, BfdAttributes.COUNT_SECTIONS)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sections_count'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '11']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_ptr'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'raise_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'BfdException'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': '"BFD not initialized"'}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_bfd'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'get_bfd_attribute'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_ptr'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'BfdAttributes'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'COUNT_SECTIONS'}
Return the sections_count attribute of the BFD file being processed.
def vector_str(p, decimal_places=2, print_zero=True): style = '{0:.' + str(decimal_places) + 'f}' return '[{0}]'.format(", ".join([' ' if not print_zero and a == 0 else style.format(a) for a in p]))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'vector_str'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'decimal_places'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'print_zero'}; {'id': '10', 'type': 'True', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '23']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '22'], 'value': '+'}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '18'], 'value': '+'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'{0:.'"}; {'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': 'decimal_places'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'f}'"}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'[{0}]'"}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': '", "'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'list_comprehension', 'children': ['35', '49']}; {'id': '35', 'type': 'conditional_expression', 'children': ['36', '37', '43'], 'value': 'if'}; {'id': '36', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '37', 'type': 'boolean_operator', 'children': ['38', '40'], 'value': 'and'}; {'id': '38', 'type': 'not_operator', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'print_zero'}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '42'], 'value': '=='}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '49', 'type': 'for_in_clause', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'p'}
Pretty-print the vector values.
def _merge_report(self, target, new): time = None if 'ts' in new['parsed']: time = new['parsed']['ts'] if (target.get('lastSeenDate', None) and time and target['lastSeenDate'] < time): target['lastSeenDate'] = time query_millis = int(new['parsed']['stats']['millis']) target['stats']['totalTimeMillis'] += query_millis target['stats']['count'] += 1 target['stats']['avgTimeMillis'] = target['stats']['totalTimeMillis'] / target['stats']['count']
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_merge_report'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'new'}; {'id': '7', 'type': 'block', 'children': ['8', '12', '27', '51', '64', '72', '80']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'if_statement', 'children': ['13', '18']}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '15'], 'value': 'in'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'ts'"}; {'id': '15', 'type': 'subscript', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'new'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'parsed'"}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '22', 'type': 'subscript', 'children': ['23', '26']}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'new'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'parsed'"}; {'id': '26', 'type': 'string', 'children': [], 'value': "'ts'"}; {'id': '27', 'type': 'if_statement', 'children': ['28', '44']}; {'id': '28', 'type': '()', 'children': ['29']}; {'id': '29', 'type': 'boolean_operator', 'children': ['30', '39'], 'value': 'and'}; {'id': '30', 'type': 'boolean_operator', 'children': ['31', '38'], 'value': 'and'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'lastSeenDate'"}; {'id': '37', 'type': 'None', 'children': []}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '43'], 'value': '<'}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'lastSeenDate'"}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '50']}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '49', 'type': 'string', 'children': [], 'value': "'lastSeenDate'"}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'query_millis'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'subscript', 'children': ['58', '63']}; {'id': '58', 'type': 'subscript', 'children': ['59', '62']}; {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'new'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'parsed'"}; {'id': '62', 'type': 'string', 'children': [], 'value': "'stats'"}; {'id': '63', 'type': 'string', 'children': [], 'value': "'millis'"}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'augmented_assignment', 'children': ['66', '71'], 'value': '+='}; {'id': '66', 'type': 'subscript', 'children': ['67', '70']}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '69', 'type': 'string', 'children': [], 'value': "'stats'"}; {'id': '70', 'type': 'string', 'children': [], 'value': "'totalTimeMillis'"}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'query_millis'}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'augmented_assignment', 'children': ['74', '79'], 'value': '+='}; {'id': '74', 'type': 'subscript', 'children': ['75', '78']}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'stats'"}; {'id': '78', 'type': 'string', 'children': [], 'value': "'count'"}; {'id': '79', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '87']}; {'id': '82', 'type': 'subscript', 'children': ['83', '86']}; {'id': '83', 'type': 'subscript', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '85', 'type': 'string', 'children': [], 'value': "'stats'"}; {'id': '86', 'type': 'string', 'children': [], 'value': "'avgTimeMillis'"}; {'id': '87', 'type': 'binary_operator', 'children': ['88', '93'], 'value': '/'}; {'id': '88', 'type': 'subscript', 'children': ['89', '92']}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '91', 'type': 'string', 'children': [], 'value': "'stats'"}; {'id': '92', 'type': 'string', 'children': [], 'value': "'totalTimeMillis'"}; {'id': '93', 'type': 'subscript', 'children': ['94', '97']}; {'id': '94', 'type': 'subscript', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '96', 'type': 'string', 'children': [], 'value': "'stats'"}; {'id': '97', 'type': 'string', 'children': [], 'value': "'count'"}
Merges a new report into the target report
def expect(func, args, times=7, sleep_t=0.5): while times > 0: try: return func(*args) except Exception as e: times -= 1 logger.debug("expect failed - attempts left: %d" % times) time.sleep(sleep_t) if times == 0: raise exceptions.BaseExc(e)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'expect'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'times'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '7'}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'sleep_t'}; {'id': '11', 'type': 'float', 'children': [], 'value': '0.5'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'while_statement', 'children': ['14', '17']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '16'], 'value': '>'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'times'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'try_statement', 'children': ['19', '26']}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'list_splat', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '26', 'type': 'except_clause', 'children': ['27', '31']}; {'id': '27', 'type': 'as_pattern', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '29', 'type': 'as_pattern_target', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '31', 'type': 'block', 'children': ['32', '36', '45', '52']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'augmented_assignment', 'children': ['34', '35'], 'value': '-='}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'times'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '1'}; {'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': 'logger'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '44'], 'value': '%'}; {'id': '43', 'type': 'string', 'children': [], 'value': '"expect failed - attempts left: %d"'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'times'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'sleep_t'}; {'id': '52', 'type': 'if_statement', 'children': ['53', '56']}; {'id': '53', 'type': 'comparison_operator', 'children': ['54', '55'], 'value': '=='}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'times'}; {'id': '55', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'raise_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'BaseExc'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'e'}
try many times as in times with sleep time
def _create_alignment_button(self): iconnames = ["AlignTop", "AlignCenter", "AlignBottom"] bmplist = [icons[iconname] for iconname in iconnames] self.alignment_tb = _widgets.BitmapToggleButton(self, bmplist) self.alignment_tb.SetToolTipString(_(u"Alignment")) self.Bind(wx.EVT_BUTTON, self.OnAlignment, self.alignment_tb) self.AddControl(self.alignment_tb)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_alignment_button'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '23', '35', '47', '62']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'iconnames'}; {'id': '9', 'type': 'list', 'children': ['10', '11', '12'], 'value': '["AlignTop", "AlignCenter", "AlignBottom"]'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"AlignTop"'}; {'id': '11', 'type': 'string', 'children': [], 'value': '"AlignCenter"'}; {'id': '12', 'type': 'string', 'children': [], 'value': '"AlignBottom"'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'bmplist'}; {'id': '16', 'type': 'list_comprehension', 'children': ['17', '20']}; {'id': '17', 'type': 'subscript', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'icons'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'iconname'}; {'id': '20', 'type': 'for_in_clause', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'iconname'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'iconnames'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'alignment_tb'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_widgets'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'BitmapToggleButton'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'bmplist'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'alignment_tb'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'SetToolTipString'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': 'u"Alignment"'}; {'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': 'Bind'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '56', '59']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'wx'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'EVT_BUTTON'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'OnAlignment'}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'alignment_tb'}; {'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': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'AddControl'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'alignment_tb'}
Creates vertical alignment button
def query(self, query, variables=None, timeout=None, metadata=None, credentials=None): new_metadata = self._dg.add_login_metadata(metadata) req = self._common_query(query, variables=variables) try: res = self._dc.query(req, timeout=timeout, metadata=new_metadata, credentials=credentials) except Exception as error: if util.is_jwt_expired(error): self._dg.retry_login() new_metadata = self._dg.add_login_metadata(metadata) res = self._dc.query(req, timeout=timeout, metadata=new_metadata, credentials=credentials) else: raise error self.merge_context(res.txn) return res
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'query'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19', '30', '42', '121', '130']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'new_metadata'}; {'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': '_dg'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'add_login_metadata'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'req'}; {'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': '_common_query'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '42', 'type': 'try_statement', 'children': ['43', '64']}; {'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': 'res'}; {'id': '47', 'type': 'call', 'children': ['48', '53']}; {'id': '48', 'type': 'attribute', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': '_dc'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55', '58', '61']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'req'}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'new_metadata'}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '64', 'type': 'except_clause', 'children': ['65', '69']}; {'id': '65', 'type': 'as_pattern', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '67', 'type': 'as_pattern_target', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'if_statement', 'children': ['71', '77', '117']}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'util'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'is_jwt_expired'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '77', 'type': 'block', 'children': ['78', '86', '97']}; {'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': '_dg'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'retry_login'}; {'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': 'new_metadata'}; {'id': '89', 'type': 'call', 'children': ['90', '95']}; {'id': '90', 'type': 'attribute', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': '_dg'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'add_login_metadata'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '100', 'type': 'call', 'children': ['101', '106']}; {'id': '101', 'type': 'attribute', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': '_dc'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '106', 'type': 'argument_list', 'children': ['107', '108', '111', '114']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'req'}; {'id': '108', 'type': 'keyword_argument', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '111', 'type': 'keyword_argument', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'new_metadata'}; {'id': '114', 'type': 'keyword_argument', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '117', 'type': 'else_clause', 'children': ['118']}; {'id': '118', 'type': 'block', 'children': ['119']}; {'id': '119', 'type': 'raise_statement', 'children': ['120']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'error'}; {'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': 'self'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'merge_context'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'txn'}; {'id': '130', 'type': 'return_statement', 'children': ['131']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'res'}
Adds a query operation to the transaction.
def read_line(self, fid): lin = ' while lin[0] == ' lin = fid.readline().strip() if lin == '': return lin return lin
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_line'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fid'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '23', '30']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'lin'}; {'id': '10', 'type': 'string', 'children': [], 'value': "'\n while lin[0] == '"}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'lin'}; {'id': '14', 'type': 'call', 'children': ['15', '22']}; {'id': '15', 'type': 'attribute', 'children': ['16', '21']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'fid'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'readline'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'if_statement', 'children': ['24', '27']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': '=='}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'lin'}; {'id': '26', 'type': 'string', 'children': [], 'value': "''"}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'lin'}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'lin'}
Read a line from a file string and check it isn't either empty or commented before returning.
def _convert_clause(self, clause): clause = wrap(clause) if clause == None: return None elif is_data(clause): return set_default({"value": self.convert(clause.value)}, clause) else: return [set_default({"value": self.convert(c.value)}, c) for c in clause]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_clause'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'clause'}; {'id': '6', 'type': 'block', 'children': ['7', '14']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'clause'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'wrap'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'clause'}; {'id': '14', 'type': 'if_statement', 'children': ['15', '18', '21', '43']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '17'], 'value': '=='}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'clause'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'elif_clause', 'children': ['22', '26']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'is_data'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'clause'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'set_default'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '42']}; {'id': '31', 'type': 'dictionary', 'children': ['32']}; {'id': '32', 'type': 'pair', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': '"value"'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'convert'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'clause'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'clause'}; {'id': '43', 'type': 'else_clause', 'children': ['44']}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'list_comprehension', 'children': ['47', '62']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'set_default'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '61']}; {'id': '50', 'type': 'dictionary', 'children': ['51']}; {'id': '51', 'type': 'pair', 'children': ['52', '53']}; {'id': '52', 'type': 'string', 'children': [], 'value': '"value"'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'convert'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '62', 'type': 'for_in_clause', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'clause'}
JSON QUERY EXPRESSIONS HAVE MANY CLAUSES WITH SIMILAR COLUMN DELCARATIONS
def top(self): if self.vMerge is None or self.vMerge == ST_Merge.RESTART: return self._tr_idx return self._tc_above.top
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'top'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '25']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '20']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '13'], 'value': 'or'}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': 'is'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'vMerge'}; {'id': '12', 'type': 'None', 'children': []}; {'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': 'vMerge'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ST_Merge'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'RESTART'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_tr_idx'}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_tc_above'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'top'}
The top-most row index in the vertical span of this cell.
def _get_serv(ret=None): _options = _get_options(ret) host = _options.get('host') port = _options.get('port') database = _options.get('db') user = _options.get('user') password = _options.get('password') version = _get_version(host, port, user, password) if version and "v0.8" in version: return influxdb.influxdb08.InfluxDBClient(host=host, port=port, username=user, password=password, database=database ) else: return influxdb.InfluxDBClient(host=host, port=port, username=user, password=password, database=database )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_serv'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8', '15', '24', '33', '42', '51', '60', '70']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_options'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_get_options'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_options'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'host'"}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_options'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'port'"}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_options'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'string', 'children': [], 'value': "'db'"}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_options'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'string', 'children': [], 'value': "'user'"}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_options'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'string', 'children': [], 'value': "'password'"}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '_get_version'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67', '68', '69']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '70', 'type': 'if_statement', 'children': ['71', '76', '100']}; {'id': '71', 'type': 'boolean_operator', 'children': ['72', '73'], 'value': 'and'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '73', 'type': 'comparison_operator', 'children': ['74', '75'], 'value': 'in'}; {'id': '74', 'type': 'string', 'children': [], 'value': '"v0.8"'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'return_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': 'influxdb'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'influxdb08'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'InfluxDBClient'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '88', '91', '94', '97']}; {'id': '85', 'type': 'keyword_argument', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '88', 'type': 'keyword_argument', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '91', 'type': 'keyword_argument', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '94', 'type': 'keyword_argument', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '97', 'type': 'keyword_argument', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '100', 'type': 'else_clause', 'children': ['101']}; {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'return_statement', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'influxdb'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'InfluxDBClient'}; {'id': '107', 'type': 'argument_list', 'children': ['108', '111', '114', '117', '120']}; {'id': '108', 'type': 'keyword_argument', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '111', 'type': 'keyword_argument', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '114', 'type': 'keyword_argument', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '117', 'type': 'keyword_argument', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '120', 'type': 'keyword_argument', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'database'}
Return an influxdb client object
def to_latex(self): if self.low == self.high: if self.low * 10 % 10 == 0: return "{0:d}".format(int(self.low)) else: return "{0:0.2f}".format(self.low) else: t = "" if self.low == -np.inf: t += r"(-\infty, " elif self.low * 10 % 10 == 0: t += r"[{0:d}, ".format(int(self.low)) else: t += r"[{0:0.2f}, ".format(self.low) if self.high == np.inf: t += r"\infty)" elif self.high * 10 % 10 == 0: t += r"{0:d}]".format(int(self.high)) else: t += r"{0:0.2f}]".format(self.high) return t
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_latex'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '14', '49']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': '=='}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'low'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'high'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '25', '38']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '24'], 'value': '=='}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '23'], 'value': '%'}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '22'], 'value': '*'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'low'}; {'id': '22', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': '"{0:d}"'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'int'}; {'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': 'low'}; {'id': '38', 'type': 'else_clause', 'children': ['39']}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'string', 'children': [], 'value': '"{0:0.2f}"'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'format'}; {'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': 'low'}; {'id': '49', 'type': 'else_clause', 'children': ['50']}; {'id': '50', 'type': 'block', 'children': ['51', '55', '107', '158']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '54', 'type': 'string', 'children': [], 'value': '""'}; {'id': '55', 'type': 'if_statement', 'children': ['56', '64', '69', '94']}; {'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': 'low'}; {'id': '60', 'type': 'unary_operator', 'children': ['61'], 'value': '-'}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'inf'}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'augmented_assignment', 'children': ['67', '68'], 'value': '+='}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '68', 'type': 'string', 'children': [], 'value': 'r"(-\\infty, "'}; {'id': '69', 'type': 'elif_clause', 'children': ['70', '79']}; {'id': '70', 'type': 'comparison_operator', 'children': ['71', '78'], 'value': '=='}; {'id': '71', 'type': 'binary_operator', 'children': ['72', '77'], 'value': '%'}; {'id': '72', 'type': 'binary_operator', 'children': ['73', '76'], 'value': '*'}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'low'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '77', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '79', 'type': 'block', 'children': ['80']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'augmented_assignment', 'children': ['82', '83'], 'value': '+='}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'string', 'children': [], 'value': 'r"[{0:d}, "'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'low'}; {'id': '94', 'type': 'else_clause', 'children': ['95']}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'augmented_assignment', 'children': ['98', '99'], 'value': '+='}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'string', 'children': [], 'value': 'r"[{0:0.2f}, "'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'low'}; {'id': '107', 'type': 'if_statement', 'children': ['108', '115', '120', '145']}; {'id': '108', 'type': 'comparison_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': 'high'}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'inf'}; {'id': '115', 'type': 'block', 'children': ['116']}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'augmented_assignment', 'children': ['118', '119'], 'value': '+='}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '119', 'type': 'string', 'children': [], 'value': 'r"\\infty)"'}; {'id': '120', 'type': 'elif_clause', 'children': ['121', '130']}; {'id': '121', 'type': 'comparison_operator', 'children': ['122', '129'], 'value': '=='}; {'id': '122', 'type': 'binary_operator', 'children': ['123', '128'], 'value': '%'}; {'id': '123', 'type': 'binary_operator', 'children': ['124', '127'], 'value': '*'}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'high'}; {'id': '127', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '128', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '129', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '130', 'type': 'block', 'children': ['131']}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'augmented_assignment', 'children': ['133', '134'], 'value': '+='}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '134', 'type': 'call', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'string', 'children': [], 'value': 'r"{0:d}]"'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '138', 'type': 'argument_list', 'children': ['139']}; {'id': '139', 'type': 'call', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'high'}; {'id': '145', 'type': 'else_clause', 'children': ['146']}; {'id': '146', 'type': 'block', 'children': ['147']}; {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'augmented_assignment', 'children': ['149', '150'], 'value': '+='}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '150', 'type': 'call', 'children': ['151', '154']}; {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'string', 'children': [], 'value': 'r"{0:0.2f}]"'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '154', 'type': 'argument_list', 'children': ['155']}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'high'}; {'id': '158', 'type': 'return_statement', 'children': ['159']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 't'}
Returns an interval representation
def fromJD(jd, utcoffset): if not isinstance(utcoffset, Time): utcoffset = Time(utcoffset) localJD = jd + utcoffset.value / 24.0 date = Date(round(localJD)) time = Time((localJD + 0.5 - date.jdn) * 24) return Datetime(date, time, utcoffset)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fromJD'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'utcoffset'}; {'id': '6', 'type': 'block', 'children': ['7', '22', '32', '42', '58']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'utcoffset'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'Time'}; {'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': 'utcoffset'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'Time'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'utcoffset'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'localJD'}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '27'], 'value': '+'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '31'], 'value': '/'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'utcoffset'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '31', 'type': 'float', 'children': [], 'value': '24.0'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'Date'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'localJD'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'Time'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '57'], 'value': '*'}; {'id': '49', 'type': '()', 'children': ['50']}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '54'], 'value': '-'}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '53'], 'value': '+'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'localJD'}; {'id': '53', 'type': 'float', 'children': [], 'value': '0.5'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'jdn'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '24'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'Datetime'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63', '64']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'utcoffset'}
Builds a Datetime object given a jd and utc offset.
def cli(env, identifier, ack): manager = AccountManager(env.client) event = manager.get_event(identifier) if ack: manager.ack_event(identifier) env.fout(basic_event_table(event)) env.fout(impacted_table(event)) env.fout(update_table(event))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cli'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ack'}; {'id': '7', 'type': 'block', 'children': ['8', '17', '26', '36', '46', '56']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'manager'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'AccountManager'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'manager'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get_event'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ack'}; {'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': 'manager'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ack_event'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'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': 'env'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'fout'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'basic_event_table'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'event'}; {'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': 'env'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'fout'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'impacted_table'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'fout'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'update_table'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'event'}
Details of a specific event, and ability to acknowledge event.
def build_package(path, requires, virtualenv=None, ignore=None, extra_files=None, zipfile_name=ZIPFILE_NAME, pyexec=None): pkg = Package(path, zipfile_name, pyexec) if extra_files: for fil in extra_files: pkg.extra_file(fil) if virtualenv is not None: pkg.virtualenv(virtualenv) pkg.requirements(requires) pkg.build(ignore) return pkg
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_package'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'requires'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'virtualenv'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'ignore'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'extra_files'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'zipfile_name'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ZIPFILE_NAME'}; {'id': '18', 'type': 'default_parameter', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'pyexec'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22', '31', '45', '57', '64', '71']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'pkg'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'Package'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'zipfile_name'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'pyexec'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'extra_files'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'for_statement', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'fil'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'extra_files'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'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': 'pkg'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'extra_file'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'fil'}; {'id': '45', 'type': 'if_statement', 'children': ['46', '49']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': 'is not'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'virtualenv'}; {'id': '48', 'type': 'None', 'children': []}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'pkg'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'virtualenv'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'virtualenv'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'pkg'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'requirements'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'requires'}; {'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': 'pkg'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'build'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'ignore'}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'pkg'}
Builds the zip file and creates the package with it
def train(self, data, **kwargs): self.data = data for i in xrange(0,data.shape[1]): column_mean = np.mean(data.icol(i)) column_stdev = np.std(data.icol(i)) self.column_means += [column_mean] self.column_stdevs += [column_stdev] self.data = self.predict(data)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'train'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '8', 'type': 'block', 'children': ['9', '15', '69']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '15', 'type': 'for_statement', 'children': ['16', '17', '26']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'xrange'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '21', 'type': 'subscript', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '26', 'type': 'block', 'children': ['27', '41', '55', '62']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'column_mean'}; {'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': 'mean'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'icol'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'column_stdev'}; {'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': 'std'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'icol'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'augmented_assignment', 'children': ['57', '60'], 'value': '+='}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'column_means'}; {'id': '60', 'type': 'list', 'children': ['61'], 'value': '[column_mean]'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'column_mean'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'augmented_assignment', 'children': ['64', '67'], 'value': '+='}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'column_stdevs'}; {'id': '67', 'type': 'list', 'children': ['68'], 'value': '[column_stdev]'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'column_stdev'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'predict'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'data'}
Calculate the standard deviations and means in the training data
def _die(self, msg, lnum): raise Exception("**FATAL {FILE}({LNUM}): {MSG}\n".format( FILE=self.obo_file, LNUM=lnum, MSG=msg))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_die'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'lnum'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'raise_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"**FATAL {FILE}({LNUM}): {MSG}\\n"'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '22', '25']}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'FILE'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'obo_file'}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'LNUM'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'lnum'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'MSG'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'msg'}
Raise an Exception if file read is unexpected.
def multipleOrderComparison(cls, orders): comparers = [ (o.keyfn, 1 if o.isAscending() else -1) for o in orders] def cmpfn(a, b): for keyfn, ascOrDesc in comparers: comparison = cmp(keyfn(a), keyfn(b)) * ascOrDesc if comparison is not 0: return comparison return 0 return cmpfn
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'multipleOrderComparison'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'orders'}; {'id': '6', 'type': 'block', 'children': ['7', '27', '64']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'comparers'}; {'id': '10', 'type': 'list_comprehension', 'children': ['11', '24']}; {'id': '11', 'type': 'tuple', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'keyfn'}; {'id': '15', 'type': 'conditional_expression', 'children': ['16', '17', '22'], 'value': 'if'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'isAscending'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'unary_operator', 'children': ['23'], 'value': '-'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '24', 'type': 'for_in_clause', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'orders'}; {'id': '27', 'type': 'function_definition', 'children': ['28', '29', '32']}; {'id': '28', 'type': 'function_name', 'children': [], 'value': 'cmpfn'}; {'id': '29', 'type': 'parameters', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '32', 'type': 'block', 'children': ['33', '62']}; {'id': '33', 'type': 'for_statement', 'children': ['34', '37', '38']}; {'id': '34', 'type': 'pattern_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'keyfn'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'ascOrDesc'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'comparers'}; {'id': '38', 'type': 'block', 'children': ['39', '55']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'comparison'}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '54'], 'value': '*'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'cmp'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '50']}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'keyfn'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'keyfn'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'ascOrDesc'}; {'id': '55', 'type': 'if_statement', 'children': ['56', '59']}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '58'], 'value': 'is not'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'comparison'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'comparison'}; {'id': '62', 'type': 'return_statement', 'children': ['63']}; {'id': '63', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '64', 'type': 'return_statement', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'cmpfn'}
Returns a function that will compare two items according to `orders`
def quick_search(self, terms): assert type(terms) is str p = [{'quicksearch': terms}] return self.search_bugs(p)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'quick_search'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'terms'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '22']}; {'id': '7', 'type': 'assert_statement', 'children': ['8']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '13'], 'value': 'is'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'terms'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '17', 'type': 'list', 'children': ['18'], 'value': "[{'quicksearch': terms}]"}; {'id': '18', 'type': 'dictionary', 'children': ['19']}; {'id': '19', 'type': 'pair', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'quicksearch'"}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'terms'}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'search_bugs'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'p'}
Wrapper for search_bugs, for simple string searches
def comparable(self): document_dict = self.compare_safe(self._document) self._remove_keys(document_dict, self._uncompared_fields) clean_document_dict = {} for k, v in document_dict.items(): if not v and not isinstance(v, (int, float)): continue clean_document_dict[k] = v for ref_field, ref_cls in self._compared_refs.items(): ref = getattr(self, ref_field) if not ref: continue if isinstance(ref, list): if isinstance(ref[0], Frame): continue setattr( clean_document_dict, ref_field, ref_cls.many(In(Q._id, ref)) ) else: if isinstance(ref, Frame): continue setattr( clean_document_dict, ref_field, ref_cls.byId(ref) ) return clean_document_dict
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'comparable'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '27', '31', '61', '143']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'document_dict'}; {'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': 'compare_safe'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_document'}; {'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': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_remove_keys'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'document_dict'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_uncompared_fields'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'clean_document_dict'}; {'id': '30', 'type': 'dictionary', 'children': []}; {'id': '31', 'type': 'for_statement', 'children': ['32', '35', '40']}; {'id': '32', 'type': 'pattern_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'document_dict'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'block', 'children': ['41', '55']}; {'id': '41', 'type': 'if_statement', 'children': ['42', '53']}; {'id': '42', 'type': 'boolean_operator', 'children': ['43', '45'], 'value': 'and'}; {'id': '43', 'type': 'not_operator', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '45', 'type': 'not_operator', 'children': ['46']}; {'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': 'v'}; {'id': '50', 'type': 'tuple', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'continue_statement', 'children': []}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '60']}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'clean_document_dict'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '61', 'type': 'for_statement', 'children': ['62', '65', '72']}; {'id': '62', 'type': 'pattern_list', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'ref_field'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'ref_cls'}; {'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': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': '_compared_refs'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '71', 'type': 'argument_list', 'children': []}; {'id': '72', 'type': 'block', 'children': ['73', '81', '86']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'ref_field'}; {'id': '81', 'type': 'if_statement', 'children': ['82', '84']}; {'id': '82', 'type': 'not_operator', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'continue_statement', 'children': []}; {'id': '86', 'type': 'if_statement', 'children': ['87', '92', '121']}; {'id': '87', 'type': 'call', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '89', 'type': 'argument_list', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '92', 'type': 'block', 'children': ['93', '103']}; {'id': '93', 'type': 'if_statement', 'children': ['94', '101']}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '96', 'type': 'argument_list', 'children': ['97', '100']}; {'id': '97', 'type': 'subscript', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '99', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'Frame'}; {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'continue_statement', 'children': []}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '106', 'type': 'argument_list', 'children': ['107', '108', '109']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'clean_document_dict'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'ref_field'}; {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'ref_cls'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'many'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'call', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'In'}; {'id': '116', 'type': 'argument_list', 'children': ['117', '120']}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': '_id'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '121', 'type': 'else_clause', 'children': ['122']}; {'id': '122', 'type': 'block', 'children': ['123', '131']}; {'id': '123', 'type': 'if_statement', 'children': ['124', '129']}; {'id': '124', 'type': 'call', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '126', 'type': 'argument_list', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'Frame'}; {'id': '129', 'type': 'block', 'children': ['130']}; {'id': '130', 'type': 'continue_statement', 'children': []}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'call', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '134', 'type': 'argument_list', 'children': ['135', '136', '137']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'clean_document_dict'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'ref_field'}; {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'ref_cls'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'byId'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '143', 'type': 'return_statement', 'children': ['144']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'clean_document_dict'}
Return a dictionary that can be compared
def status_code(self): try: return self._status_code except AttributeError: self._status_code = self._response.getcode() return self._status_code
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'status_code'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '27']}; {'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': '_status_code'}; {'id': '12', 'type': 'except_clause', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_status_code'}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_response'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'getcode'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_status_code'}
Get the http status code for the response
def update_from_sam(self, sam, sam_reader): if sam.is_unmapped \ or sam.mate_is_unmapped \ or (sam.reference_id == sam.next_reference_id): return new_link = link.Link(sam, sam_reader, self.ref_lengths) read_name = sam.query_name if read_name in self.partial_links: new_link.merge(self.partial_links[read_name]) del self.partial_links[read_name] key = tuple(sorted((new_link.refnames[0], new_link.refnames[1]))) if key not in self.links: self.links[key] = [] new_link.sort() self.links[key].append(new_link) else: self.partial_links[read_name] = new_link
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_from_sam'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sam'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'sam_reader'}; {'id': '7', 'type': 'block', 'children': ['8', '29', '42', '48']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '27']}; {'id': '9', 'type': 'boolean_operator', 'children': ['10', '18', '19'], 'value': 'or'}; {'id': '10', 'type': 'boolean_operator', 'children': ['11', '14', '15'], 'value': 'or'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'sam'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'is_unmapped'}; {'id': '14', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'sam'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'mate_is_unmapped'}; {'id': '18', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '19', 'type': '()', 'children': ['20']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '24'], 'value': '=='}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sam'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'reference_id'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'sam'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'next_reference_id'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'return_statement', 'children': []}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'new_link'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'Link'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38', '39']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'sam'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'sam_reader'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'ref_lengths'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'read_name'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'sam'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'query_name'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '54', '124']}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '51'], 'value': 'in'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'read_name'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'partial_links'}; {'id': '54', 'type': 'block', 'children': ['55', '66', '72', '92', '107', '113']}; {'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': 'new_link'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'merge'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'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': 'partial_links'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'read_name'}; {'id': '66', 'type': 'delete_statement', 'children': ['67']}; {'id': '67', 'type': 'subscript', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'partial_links'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'read_name'}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'tuple', 'children': ['82', '87']}; {'id': '82', 'type': 'subscript', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'new_link'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'refnames'}; {'id': '86', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '87', 'type': 'subscript', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'new_link'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'refnames'}; {'id': '91', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '92', 'type': 'if_statement', 'children': ['93', '98']}; {'id': '93', 'type': 'comparison_operator', 'children': ['94', '95'], 'value': 'not in'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'links'}; {'id': '98', 'type': 'block', 'children': ['99']}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '106']}; {'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': 'links'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '106', 'type': 'list', 'children': [], 'value': '[]'}; {'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': 'new_link'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '112', 'type': 'argument_list', 'children': []}; {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'call', 'children': ['115', '122']}; {'id': '115', 'type': 'attribute', 'children': ['116', '121']}; {'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': 'links'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'new_link'}; {'id': '124', 'type': 'else_clause', 'children': ['125']}; {'id': '125', 'type': 'block', 'children': ['126']}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'assignment', 'children': ['128', '133']}; {'id': '128', 'type': 'subscript', 'children': ['129', '132']}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'partial_links'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'read_name'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'new_link'}
Updates graph info from a pysam.AlignedSegment object
def hex2termhex(hexval: str, allow_short: bool = False) -> str: return rgb2termhex(*hex2rgb(hexval, allow_short=allow_short))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hex2termhex'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'hexval'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '8', 'type': 'typed_default_parameter', 'children': ['9', '10', '12']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'allow_short'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '12', 'type': 'False', 'children': []}; {'id': '13', 'type': 'type', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'rgb2termhex'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'list_splat', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'hex2rgb'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'hexval'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'allow_short'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'allow_short'}
Convert a hex value into the nearest terminal color matched hex.
def hash_user_id(self, user_id: str) -> str: h = sha256() h.update(user_id.encode()) return h.hexdigest()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hash_user_id'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '9', 'type': 'type', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '11', 'type': 'block', 'children': ['12', '18', '29']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'sha256'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'hexdigest'}; {'id': '34', 'type': 'argument_list', 'children': []}
As per the law, anonymize user identifier before sending it.
def _entity_list_as_bel(entities: Iterable[BaseEntity]) -> str: return ', '.join( e.as_bel() for e in entities )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_entity_list_as_bel'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'entities'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'generic_type', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Iterable'}; {'id': '9', 'type': 'type_parameter', 'children': ['10']}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'BaseEntity'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': "', '"}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '20', 'type': 'generator_expression', 'children': ['21', '26']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'as_bel'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'for_in_clause', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'entities'}
Stringify a list of BEL entities.
def _two_byte_cmd(self, cmd): if cmd == SB: self.telnet_got_sb = True self.telnet_sb_buffer = '' elif cmd == SE: self.telnet_got_sb = False self._sb_decoder() elif cmd == NOP: pass elif cmd == DATMK: pass elif cmd == IP: pass elif cmd == AO: pass elif cmd == AYT: pass elif cmd == EC: pass elif cmd == EL: pass elif cmd == GA: pass else: print "2BC: Should not be here." self.telnet_got_iac = False self.telnet_got_cmd = None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_two_byte_cmd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '6', 'type': 'block', 'children': ['7', '93', '99']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11', '24', '41', '47', '53', '59', '65', '71', '77', '83', '89']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': '=='}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'SB'}; {'id': '11', 'type': 'block', 'children': ['12', '18']}; {'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': 'telnet_got_sb'}; {'id': '17', 'type': 'True', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'telnet_sb_buffer'}; {'id': '23', 'type': 'string', 'children': [], 'value': "''"}; {'id': '24', 'type': 'elif_clause', 'children': ['25', '28']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': '=='}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'SE'}; {'id': '28', 'type': 'block', 'children': ['29', '35']}; {'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': 'telnet_got_sb'}; {'id': '34', 'type': 'False', 'children': []}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_sb_decoder'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'elif_clause', 'children': ['42', '45']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': '=='}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'NOP'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'pass_statement', 'children': []}; {'id': '47', 'type': 'elif_clause', 'children': ['48', '51']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': '=='}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'DATMK'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'pass_statement', 'children': []}; {'id': '53', 'type': 'elif_clause', 'children': ['54', '57']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '56'], 'value': '=='}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'IP'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'pass_statement', 'children': []}; {'id': '59', 'type': 'elif_clause', 'children': ['60', '63']}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '62'], 'value': '=='}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'AO'}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'pass_statement', 'children': []}; {'id': '65', 'type': 'elif_clause', 'children': ['66', '69']}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '68'], 'value': '=='}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'AYT'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'pass_statement', 'children': []}; {'id': '71', 'type': 'elif_clause', 'children': ['72', '75']}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '74'], 'value': '=='}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'EC'}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'pass_statement', 'children': []}; {'id': '77', 'type': 'elif_clause', 'children': ['78', '81']}; {'id': '78', 'type': 'comparison_operator', 'children': ['79', '80'], 'value': '=='}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'EL'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'pass_statement', 'children': []}; {'id': '83', 'type': 'elif_clause', 'children': ['84', '87']}; {'id': '84', 'type': 'comparison_operator', 'children': ['85', '86'], 'value': '=='}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'GA'}; {'id': '87', 'type': 'block', 'children': ['88']}; {'id': '88', 'type': 'pass_statement', 'children': []}; {'id': '89', 'type': 'else_clause', 'children': ['90']}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'print_statement', 'children': ['92']}; {'id': '92', 'type': 'string', 'children': [], 'value': '"2BC: Should not be here."'}; {'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': 'telnet_got_iac'}; {'id': '98', 'type': 'False', 'children': []}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'telnet_got_cmd'}; {'id': '104', 'type': 'None', 'children': []}
Handle incoming Telnet commands that are two bytes long.
def append_default_stylesheets(self): for style in utils.get_stylesheet_list(self.settings): self.css(style)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'append_default_stylesheets'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '16']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'get_stylesheet_list'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'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': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'css'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'style'}
Appends the default styles defined on the translator settings.