code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def _item_type(item): tag = item['tag'] style = item.get('style', None) if tag == 'p': if style is None or 'paragraph' in style: return 'paragraph' else: return style elif tag == 'span': if style in (None, 'normal-text'): return 'text' elif style == 'url': return 'link' else: return style elif tag == 'h': assert style is not None return style elif tag in ('list', 'list-item', 'line-break'): if style == '_numbered_list': return 'numbered-list' else: return tag elif tag == 's': return 'spaces' raise Exception("The tag '{0}' with style '{1}' hasn't " "been implemented.".format(tag, style))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_item_type'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '22', '104']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '9', 'type': 'subscript', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '11', 'type': 'string', 'children': [], 'value': "'tag'"}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'style'"}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'if_statement', 'children': ['23', '26', '42', '67', '78', '97']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': '=='}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'p'"}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'if_statement', 'children': ['28', '35', '38']}; {'id': '28', 'type': 'boolean_operator', 'children': ['29', '32'], 'value': 'or'}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': 'is'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '31', 'type': 'None', 'children': []}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '34'], 'value': 'in'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'paragraph'"}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'string', 'children': [], 'value': "'paragraph'"}; {'id': '38', 'type': 'else_clause', 'children': ['39']}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '42', 'type': 'elif_clause', 'children': ['43', '46']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '45'], 'value': '=='}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '45', 'type': 'string', 'children': [], 'value': "'span'"}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'if_statement', 'children': ['48', '53', '56', '63']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': 'in'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '50', 'type': 'tuple', 'children': ['51', '52']}; {'id': '51', 'type': 'None', 'children': []}; {'id': '52', 'type': 'string', 'children': [], 'value': "'normal-text'"}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'return_statement', 'children': ['55']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'text'"}; {'id': '56', 'type': 'elif_clause', 'children': ['57', '60']}; {'id': '57', 'type': 'comparison_operator', 'children': ['58', '59'], 'value': '=='}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '59', 'type': 'string', 'children': [], 'value': "'url'"}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'return_statement', 'children': ['62']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'link'"}; {'id': '63', 'type': 'else_clause', 'children': ['64']}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'return_statement', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '67', 'type': 'elif_clause', 'children': ['68', '71']}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '70'], 'value': '=='}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '70', 'type': 'string', 'children': [], 'value': "'h'"}; {'id': '71', 'type': 'block', 'children': ['72', '76']}; {'id': '72', 'type': 'assert_statement', 'children': ['73']}; {'id': '73', 'type': 'comparison_operator', 'children': ['74', '75'], 'value': 'is not'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '75', 'type': 'None', 'children': []}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '78', 'type': 'elif_clause', 'children': ['79', '85']}; {'id': '79', 'type': 'comparison_operator', 'children': ['80', '81'], 'value': 'in'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '81', 'type': 'tuple', 'children': ['82', '83', '84']}; {'id': '82', 'type': 'string', 'children': [], 'value': "'list'"}; {'id': '83', 'type': 'string', 'children': [], 'value': "'list-item'"}; {'id': '84', 'type': 'string', 'children': [], 'value': "'line-break'"}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'if_statement', 'children': ['87', '90', '93']}; {'id': '87', 'type': 'comparison_operator', 'children': ['88', '89'], 'value': '=='}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '89', 'type': 'string', 'children': [], 'value': "'_numbered_list'"}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'return_statement', 'children': ['92']}; {'id': '92', 'type': 'string', 'children': [], 'value': "'numbered-list'"}; {'id': '93', 'type': 'else_clause', 'children': ['94']}; {'id': '94', 'type': 'block', 'children': ['95']}; {'id': '95', 'type': 'return_statement', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '97', 'type': 'elif_clause', 'children': ['98', '101']}; {'id': '98', 'type': 'comparison_operator', 'children': ['99', '100'], 'value': '=='}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '100', 'type': 'string', 'children': [], 'value': "'s'"}; {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'return_statement', 'children': ['103']}; {'id': '103', 'type': 'string', 'children': [], 'value': "'spaces'"}; {'id': '104', 'type': 'raise_statement', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '114']}; {'id': '109', 'type': 'attribute', 'children': ['110', '113']}; {'id': '110', 'type': 'concatenated_string', 'children': ['111', '112']}; {'id': '111', 'type': 'string', 'children': [], 'value': '"The tag \'{0}\' with style \'{1}\' hasn\'t "'}; {'id': '112', 'type': 'string', 'children': [], 'value': '"been implemented."'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '114', 'type': 'argument_list', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'style'}
Indicate to the ODF reader the type of the block or text.
def rlmb_long_stochastic_discrete_simulation_deterministic_starts(): hparams = rlmb_base_stochastic_discrete() hparams.generative_model_params = "next_frame_basic_stochastic_discrete_long" hparams.ppo_epochs_num = 1000 hparams.simulation_random_starts = False return hparams
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rlmb_long_stochastic_discrete_simulation_deterministic_starts'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '17', '23', '29']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'rlmb_base_stochastic_discrete'}; {'id': '10', 'type': 'argument_list', 'children': []}; {'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': 'hparams'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'generative_model_params'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"next_frame_basic_stochastic_discrete_long"'}; {'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': 'hparams'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ppo_epochs_num'}; {'id': '22', 'type': 'integer', 'children': [], 'value': '1000'}; {'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': 'hparams'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'simulation_random_starts'}; {'id': '28', 'type': 'False', 'children': []}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'hparams'}
Long setting with stochastic discrete model & deterministic sim starts.
def count_missense_per_gene(lines): counts = {} for x in lines: x = x.split("\t") gene = x[0] consequence = x[3] if gene not in counts: counts[gene] = 0 if consequence != "missense_variant": continue counts[gene] += 1 return counts
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'count_missense_per_gene'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '58']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'counts'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '13']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '13', 'type': 'block', 'children': ['14', '23', '29', '35', '46', '52']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"\\t"'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'gene'}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'consequence'}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '35', 'type': 'if_statement', 'children': ['36', '39']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': 'not in'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'gene'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'counts'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '45']}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'counts'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'gene'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '50']}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '49'], 'value': '!='}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'consequence'}; {'id': '49', 'type': 'string', 'children': [], 'value': '"missense_variant"'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'continue_statement', 'children': []}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'augmented_assignment', 'children': ['54', '57'], 'value': '+='}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'counts'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'gene'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'counts'}
count the number of missense variants in each gene.
def _isvalid(self, datatype): if datatype in self.meta: return bool(Dap._meta_valid[datatype].match(self.meta[datatype])) else: return datatype in Dap._optional_meta
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_isvalid'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'datatype'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13', '32']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'in'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'datatype'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '26']}; {'id': '19', 'type': 'attribute', 'children': ['20', '25']}; {'id': '20', 'type': 'subscript', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'Dap'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_meta_valid'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'datatype'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'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': 'meta'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'datatype'}; {'id': '32', 'type': 'else_clause', 'children': ['33']}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'in'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'datatype'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'Dap'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_optional_meta'}
Checks if the given datatype is valid in meta
def egg_name(self): filename = "%s-%s-py%s" % ( to_filename(self.project_name), to_filename(self.version), self.py_version or PY_MAJOR ) if self.platform: filename += '-' + self.platform return filename
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'egg_name'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '29', '42']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '9', 'type': 'binary_operator', 'children': ['10', '11'], 'value': '%'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"%s-%s-py%s"'}; {'id': '11', 'type': 'tuple', 'children': ['12', '18', '24']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'to_filename'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'project_name'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'to_filename'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '24', 'type': 'boolean_operator', 'children': ['25', '28'], 'value': 'or'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'py_version'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'PY_MAJOR'}; {'id': '29', 'type': 'if_statement', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'augmented_assignment', 'children': ['36', '37'], 'value': '+='}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '+'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'filename'}
Return what this distribution's standard .egg filename should be
def _visit_functiondef(self, cls, node, parent): self._global_names.append({}) node, doc = self._get_doc(node) newnode = cls(node.name, doc, node.lineno, node.col_offset, parent) if node.decorator_list: decorators = self.visit_decorators(node, newnode) else: decorators = None if PY3 and node.returns: returns = self.visit(node.returns, newnode) else: returns = None type_comment_args = type_comment_returns = None type_comment_annotation = self.check_function_type_comment(node) if type_comment_annotation: type_comment_returns, type_comment_args = type_comment_annotation newnode.postinit( args=self.visit(node.args, newnode), body=[self.visit(child, newnode) for child in node.body], decorators=decorators, returns=returns, type_comment_returns=type_comment_returns, type_comment_args=type_comment_args, ) self._global_names.pop() return newnode
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_visit_functiondef'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '8', 'type': 'block', 'children': ['9', '18', '29', '46', '67', '92', '98', '107', '116', '160', '168']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_global_names'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'dictionary', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'pattern_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_get_doc'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'newnode'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '38', '39', '42', '45']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'lineno'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'col_offset'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '50', '61']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'decorator_list'}; {'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': 'decorators'}; {'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': 'visit_decorators'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'newnode'}; {'id': '61', 'type': 'else_clause', 'children': ['62']}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'decorators'}; {'id': '66', 'type': 'None', 'children': []}; {'id': '67', 'type': 'if_statement', 'children': ['68', '73', '86']}; {'id': '68', 'type': 'boolean_operator', 'children': ['69', '70'], 'value': 'and'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'PY3'}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'returns'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'returns'}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'visit'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'returns'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'newnode'}; {'id': '86', 'type': 'else_clause', 'children': ['87']}; {'id': '87', 'type': 'block', 'children': ['88']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'returns'}; {'id': '91', 'type': 'None', 'children': []}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'type_comment_args'}; {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'type_comment_returns'}; {'id': '97', 'type': 'None', 'children': []}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'type_comment_annotation'}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'check_function_type_comment'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '107', 'type': 'if_statement', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'type_comment_annotation'}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '115']}; {'id': '112', 'type': 'pattern_list', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'type_comment_returns'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'type_comment_args'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'type_comment_annotation'}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'call', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'newnode'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'postinit'}; {'id': '121', 'type': 'argument_list', 'children': ['122', '133', '148', '151', '154', '157']}; {'id': '122', 'type': 'keyword_argument', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '124', 'type': 'call', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'visit'}; {'id': '128', 'type': 'argument_list', 'children': ['129', '132']}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'newnode'}; {'id': '133', 'type': 'keyword_argument', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '135', 'type': 'list_comprehension', 'children': ['136', '143']}; {'id': '136', 'type': 'call', 'children': ['137', '140']}; {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'visit'}; {'id': '140', 'type': 'argument_list', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'newnode'}; {'id': '143', 'type': 'for_in_clause', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '148', 'type': 'keyword_argument', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'decorators'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'decorators'}; {'id': '151', 'type': 'keyword_argument', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'returns'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'returns'}; {'id': '154', 'type': 'keyword_argument', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'type_comment_returns'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'type_comment_returns'}; {'id': '157', 'type': 'keyword_argument', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'type_comment_args'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'type_comment_args'}; {'id': '160', 'type': 'expression_statement', 'children': ['161']}; {'id': '161', 'type': 'call', 'children': ['162', '167']}; {'id': '162', 'type': 'attribute', 'children': ['163', '166']}; {'id': '163', 'type': 'attribute', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': '_global_names'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '167', 'type': 'argument_list', 'children': []}; {'id': '168', 'type': 'return_statement', 'children': ['169']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'newnode'}
visit an FunctionDef node to become astroid
def start_review(self): if self.set_status: self.github_repo.create_status( state="pending", description="Static analysis in progress.", context="inline-plz", sha=self.last_sha, )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start_review'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'set_status'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'github_repo'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'create_status'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '22', '25', '28']}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"pending"'}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"Static analysis in progress."'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"inline-plz"'}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'sha'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'last_sha'}
Mark our review as started.
def unique(transactions): seen = set() return [x for x in transactions if not (x in seen or seen.add(x))]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unique'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'transactions'}; {'id': '5', 'type': 'block', 'children': ['6', '12']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'seen'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'list_comprehension', 'children': ['14', '15', '18']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '15', 'type': 'for_in_clause', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'transactions'}; {'id': '18', 'type': 'if_clause', 'children': ['19']}; {'id': '19', 'type': 'not_operator', 'children': ['20']}; {'id': '20', 'type': '()', 'children': ['21']}; {'id': '21', 'type': 'boolean_operator', 'children': ['22', '25'], 'value': 'or'}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '24'], 'value': 'in'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'seen'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'seen'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'x'}
Remove any duplicate entries.
def GetConsistentValueOrRaise(self, error_format, context=None): if self.has_error: full_context = dict(self._context) if context: full_context.update(context) raise ValueError(error_format.format(**full_context)) return self.value
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetConsistentValueOrRaise'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'error_format'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '45']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'has_error'}; {'id': '14', 'type': 'block', 'children': ['15', '24', '34']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'full_context'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_context'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'full_context'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '34', 'type': 'raise_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'error_format'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'dictionary_splat', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'full_context'}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'value'}
Gets consistent value or raises ValueError with formatted contexts.
def info(message, *args, **kwargs): if 'end' in kwargs: end = kwargs['end'] else: end = '\n' if len(args) == 0: sys.stdout.write(message) else: sys.stdout.write(message % args) sys.stdout.write(end) sys.stdout.flush()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'info'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'message'}; {'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', '27', '57', '66']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '14', '21']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': 'in'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'end'"}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'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': 'end'}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'end'"}; {'id': '21', 'type': 'else_clause', 'children': ['22']}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '27', 'type': 'if_statement', 'children': ['28', '34', '44']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '33'], 'value': '=='}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'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': 'sys'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '44', 'type': 'else_clause', 'children': ['45']}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '53']}; {'id': '48', 'type': 'attribute', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'binary_operator', 'children': ['55', '56'], 'value': '%'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '64']}; {'id': '59', 'type': 'attribute', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '73']}; {'id': '68', 'type': 'attribute', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'flush'}; {'id': '73', 'type': 'argument_list', 'children': []}
write a message to stdout
def output(id, url): try: experiment = ExperimentClient().get(normalize_job_name(id)) except FloydException: experiment = ExperimentClient().get(id) output_dir_url = "%s/%s/files" % (floyd.floyd_web_host, experiment.name) if url: floyd_logger.info(output_dir_url) else: floyd_logger.info("Opening output path in your browser ...") webbrowser.open(output_dir_url)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'output'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '6', 'type': 'block', 'children': ['7', '37', '49']}; {'id': '7', 'type': 'try_statement', 'children': ['8', '23']}; {'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': 'experiment'}; {'id': '12', 'type': 'call', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ExperimentClient'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'normalize_job_name'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '23', 'type': 'except_clause', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'FloydException'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'experiment'}; {'id': '29', 'type': 'call', 'children': ['30', '35']}; {'id': '30', 'type': 'attribute', 'children': ['31', '34']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ExperimentClient'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'output_dir_url'}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '42'], 'value': '%'}; {'id': '41', 'type': 'string', 'children': [], 'value': '"%s/%s/files"'}; {'id': '42', 'type': 'tuple', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'floyd'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'floyd_web_host'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'experiment'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '49', 'type': 'if_statement', 'children': ['50', '51', '59']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'floyd_logger'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'output_dir_url'}; {'id': '59', 'type': 'else_clause', 'children': ['60']}; {'id': '60', 'type': 'block', 'children': ['61', '68']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'floyd_logger'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'string', 'children': [], 'value': '"Opening output path in your browser ..."'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'webbrowser'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'output_dir_url'}
View the files from a job.
def do_cat(self, path): path = path[0] tmp_file_path = self.TMP_PATH + 'tmp' if not os.path.exists(self.TMP_PATH): os.makedirs(self.TMP_PATH) f = self.n.downloadFile(self.current_path + path, tmp_file_path) f = open(tmp_file_path, 'r') self.stdout.write(f.read()) self.stdout.write("\n")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_cat'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '21', '43', '59', '67', '80']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '10', 'type': 'subscript', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'tmp_file_path'}; {'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': 'TMP_PATH'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'tmp'"}; {'id': '21', 'type': 'if_statement', 'children': ['22', '33']}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'TMP_PATH'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'makedirs'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'TMP_PATH'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'f'}; {'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': 'n'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'downloadFile'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '58']}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '57'], 'value': '+'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'current_path'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'tmp_file_path'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'tmp_file_path'}; {'id': '66', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '74']}; {'id': '69', 'type': 'attribute', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '79', 'type': 'argument_list', 'children': []}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'call', 'children': ['82', '87']}; {'id': '82', 'type': 'attribute', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'string', 'children': [], 'value': '"\\n"'}
display the contents of a file
def emit(self, item, defaults=None, stencil=None, to_log=False, item_formatter=None): item_text = self.format_item(item, defaults, stencil) if item_formatter: item_text = item_formatter(item_text) if item is None and os.isatty(sys.stdout.fileno()): item_text = ''.join((config.output_header_ecma48, item_text, "\x1B[0m")) if to_log: if callable(to_log): to_log(item_text) else: self.LOG.info(item_text) elif self.options.nul: sys.stdout.write(item_text + '\0') sys.stdout.flush() else: print(item_text) return item_text.count('\n') + 1
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'emit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'defaults'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'stencil'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'to_log'}; {'id': '14', 'type': 'False', 'children': []}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'item_formatter'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19', '30', '40', '72', '130']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'item_text'}; {'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': 'format_item'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28', '29']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'defaults'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'stencil'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'item_formatter'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'item_text'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'item_formatter'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'item_text'}; {'id': '40', 'type': 'if_statement', 'children': ['41', '57']}; {'id': '41', 'type': 'boolean_operator', 'children': ['42', '45'], 'value': 'and'}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': 'is'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '44', 'type': 'None', 'children': []}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'isatty'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '56']}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'fileno'}; {'id': '56', 'type': 'argument_list', 'children': []}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'item_text'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'string', 'children': [], 'value': "''"}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'tuple', 'children': ['67', '70', '71']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'output_header_ecma48'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'item_text'}; {'id': '71', 'type': 'string', 'children': [], 'value': '"\\x1B[0m"'}; {'id': '72', 'type': 'if_statement', 'children': ['73', '74', '97', '123']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'to_log'}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'if_statement', 'children': ['76', '80', '86']}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'callable'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'to_log'}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'to_log'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'item_text'}; {'id': '86', 'type': 'else_clause', 'children': ['87']}; {'id': '87', 'type': 'block', 'children': ['88']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'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': 'LOG'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'item_text'}; {'id': '97', 'type': 'elif_clause', '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': 'options'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'nul'}; {'id': '103', 'type': 'block', 'children': ['104', '115']}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '111']}; {'id': '106', 'type': 'attribute', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'binary_operator', 'children': ['113', '114'], 'value': '+'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'item_text'}; {'id': '114', 'type': 'string', 'children': [], 'value': "'\\0'"}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '122']}; {'id': '117', 'type': 'attribute', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'flush'}; {'id': '122', 'type': 'argument_list', 'children': []}; {'id': '123', 'type': 'else_clause', 'children': ['124']}; {'id': '124', 'type': 'block', 'children': ['125']}; {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'call', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'item_text'}; {'id': '130', 'type': 'return_statement', 'children': ['131']}; {'id': '131', 'type': 'binary_operator', 'children': ['132', '138'], 'value': '+'}; {'id': '132', 'type': 'call', 'children': ['133', '136']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'item_text'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}; {'id': '137', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '138', 'type': 'integer', 'children': [], 'value': '1'}
Print an item to stdout, or the log on INFO level.
def load_json(file): here = os.path.dirname(os.path.abspath(__file__)) with open(os.path.join(here, file)) as jfile: data = json.load(jfile) return data
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_json'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '5', 'type': 'block', 'children': ['6', '24', '52']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'here'}; {'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': 'os'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '__file__'}; {'id': '24', 'type': 'with_statement', 'children': ['25', '42']}; {'id': '25', 'type': 'with_clause', 'children': ['26']}; {'id': '26', 'type': 'with_item', 'children': ['27']}; {'id': '27', 'type': 'as_pattern', 'children': ['28', '40']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'here'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '40', 'type': 'as_pattern_target', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'jfile'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'jfile'}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'data'}
Load JSON file at app start
def find_agent(self, desc): agent_id = (desc.doc_id if IDocument.providedBy(desc) else desc) self.log("I'm trying to find the agent with id: %s", agent_id) result = first(x for x in self._agents if x._descriptor.doc_id == agent_id) return defer.succeed(result)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_agent'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'desc'}; {'id': '6', 'type': 'block', 'children': ['7', '22', '30', '50']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'agent_id'}; {'id': '10', 'type': '()', 'children': ['11']}; {'id': '11', 'type': 'conditional_expression', 'children': ['12', '15', '21'], 'value': 'if'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'desc'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'doc_id'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'IDocument'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'providedBy'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'desc'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'desc'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"I\'m trying to find the agent with id: %s"'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'agent_id'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '35', 'type': 'generator_expression', 'children': ['36', '37', '42']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '37', 'type': 'for_in_clause', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '_agents'}; {'id': '42', 'type': 'if_clause', 'children': ['43']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '49'], 'value': '=='}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_descriptor'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'doc_id'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'agent_id'}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'defer'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'succeed'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'result'}
Gives medium class of the agent if the agency hosts it.
def best(self): b = (-1e999999, None) for k, c in iteritems(self.counts): b = max(b, (c, k)) return b[1]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'best'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '34']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '9', 'type': 'tuple', 'children': ['10', '12']}; {'id': '10', 'type': 'unary_operator', 'children': ['11'], 'value': '-'}; {'id': '11', 'type': 'float', 'children': [], 'value': '1e999999'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'for_statement', 'children': ['14', '17', '23']}; {'id': '14', 'type': 'pattern_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'counts'}; {'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': 'b'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '31', 'type': 'tuple', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '1'}
Returns the element with the highest probability.
def get(self, idx, default=''): if isinstance(idx, int) and (idx >= len(self) or idx < -1 * len(self)): return default return super().__getitem__(idx)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '8', 'type': 'string', 'children': [], 'value': "''"}; {'id': '9', 'type': 'block', 'children': ['10', '37']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '34']}; {'id': '11', 'type': 'boolean_operator', 'children': ['12', '17'], 'value': 'and'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '17', 'type': '()', 'children': ['18']}; {'id': '18', 'type': 'boolean_operator', 'children': ['19', '25'], 'value': 'or'}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': '>='}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': '<'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '30'], 'value': '*'}; {'id': '28', 'type': 'unary_operator', 'children': ['29'], 'value': '-'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '__getitem__'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'idx'}
Returns the element at idx, or default if idx is beyond the length of the list
def _get_assessment_part_collection(self, assessment_part_id): collection = JSONClientValidated('assessment_authoring', collection='AssessmentPart', runtime=self._runtime) assessment_part_map = collection.find_one({'_id': ObjectId(assessment_part_id.get_identifier())}) if 'itemIds' not in assessment_part_map: raise errors.NotFound('no Items are assigned to this AssessmentPart') return assessment_part_map, collection
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_assessment_part_collection'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'assessment_part_id'}; {'id': '6', 'type': 'block', 'children': ['7', '22', '41', '53']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'collection'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'JSONClientValidated'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14', '17']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'assessment_authoring'"}; {'id': '14', 'type': 'keyword_argument', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'collection'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'AssessmentPart'"}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'runtime'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_runtime'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'assessment_part_map'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'collection'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'find_one'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'dictionary', 'children': ['31']}; {'id': '31', 'type': 'pair', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'_id'"}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ObjectId'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'assessment_part_id'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'get_identifier'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'if_statement', 'children': ['42', '45']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': 'not in'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'itemIds'"}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'assessment_part_map'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'raise_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'NotFound'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'string', 'children': [], 'value': "'no Items are assigned to this AssessmentPart'"}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'expression_list', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'assessment_part_map'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'collection'}
Returns a Mongo Collection and AssessmentPart given a AssessmentPart Id
def update_commands(self, commands_str): commands = dict(parse_qsl(commands_str, keep_blank_values=True)) _if = commands.get("if", self._if) if _if: self._if = Condition(_if) self._set_int(commands, "max_length") self._set_int(commands, "min_length") self.color = self._check_color(commands.get("color")) self.not_zero = "not_zero" in commands or self.not_zero self.show = "show" in commands or self.show self.soft = "soft" in commands or self.soft
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_commands'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'commands_str'}; {'id': '6', 'type': 'block', 'children': ['7', '20', '32', '44', '52', '60', '76', '88', '100']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'parse_qsl'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'commands_str'}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'keep_blank_values'}; {'id': '19', 'type': 'True', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_if'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"if"'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_if'}; {'id': '32', 'type': 'if_statement', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_if'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_if'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'Condition'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_if'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_set_int'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '51', 'type': 'string', 'children': [], 'value': '"max_length"'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_set_int'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '59', 'type': 'string', 'children': [], 'value': '"min_length"'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'color'}; {'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': '_check_color'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'string', 'children': [], 'value': '"color"'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'not_zero'}; {'id': '81', 'type': 'boolean_operator', 'children': ['82', '85'], 'value': 'or'}; {'id': '82', 'type': 'comparison_operator', 'children': ['83', '84'], 'value': 'in'}; {'id': '83', 'type': 'string', 'children': [], 'value': '"not_zero"'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'not_zero'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'show'}; {'id': '93', 'type': 'boolean_operator', 'children': ['94', '97'], 'value': 'or'}; {'id': '94', 'type': 'comparison_operator', 'children': ['95', '96'], 'value': 'in'}; {'id': '95', 'type': 'string', 'children': [], 'value': '"show"'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'show'}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'soft'}; {'id': '105', 'type': 'boolean_operator', 'children': ['106', '109'], 'value': 'or'}; {'id': '106', 'type': 'comparison_operator', 'children': ['107', '108'], 'value': 'in'}; {'id': '107', 'type': 'string', 'children': [], 'value': '"soft"'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'soft'}
update with commands from the block
def relpath_for(self, path): if self.parent_dir in (".", ""): return path if path == self.parent_dir: return "" dirname = os.path.dirname(path) or "." basename = os.path.basename(path) cached = self.relpath_cache.get(dirname, empty) if cached is empty: cached = self.relpath_cache[dirname] = os.path.relpath(dirname, self.parent_dir) return os.path.join(cached, basename)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'relpath_for'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '6', 'type': 'block', 'children': ['7', '18', '27', '40', '51', '63', '88']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '15']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': 'in'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'parent_dir'}; {'id': '12', 'type': 'tuple', 'children': ['13', '14']}; {'id': '13', 'type': 'string', 'children': [], 'value': '"."'}; {'id': '14', 'type': 'string', 'children': [], 'value': '""'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '18', 'type': 'if_statement', 'children': ['19', '24']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': '=='}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'parent_dir'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'string', 'children': [], 'value': '""'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '30', 'type': 'boolean_operator', 'children': ['31', '39'], 'value': 'or'}; {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '39', 'type': 'string', 'children': [], 'value': '"."'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'cached'}; {'id': '54', 'type': 'call', 'children': ['55', '60']}; {'id': '55', 'type': 'attribute', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'relpath_cache'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'empty'}; {'id': '63', 'type': 'if_statement', 'children': ['64', '67']}; {'id': '64', 'type': 'comparison_operator', 'children': ['65', '66'], 'value': 'is'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'cached'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'empty'}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'cached'}; {'id': '71', 'type': 'assignment', 'children': ['72', '77']}; {'id': '72', 'type': 'subscript', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'relpath_cache'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '77', 'type': 'call', 'children': ['78', '83']}; {'id': '78', 'type': 'attribute', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'relpath'}; {'id': '83', 'type': 'argument_list', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'parent_dir'}; {'id': '88', 'type': 'return_statement', 'children': ['89']}; {'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': 'os'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '95', 'type': 'argument_list', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'cached'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'basename'}
Find the relative path from here from the parent_dir
def launch_browser(attempt_launch_browser=True): _DISPLAY_VARIABLES = ['DISPLAY', 'WAYLAND_DISPLAY', 'MIR_SOCKET'] _WEBBROWSER_NAMES_BLACKLIST = [ 'www-browser', 'lynx', 'links', 'elinks', 'w3m'] import webbrowser launch_browser = attempt_launch_browser if launch_browser: if ('linux' in sys.platform and not any(os.getenv(var) for var in _DISPLAY_VARIABLES)): launch_browser = False try: browser = webbrowser.get() if (hasattr(browser, 'name') and browser.name in _WEBBROWSER_NAMES_BLACKLIST): launch_browser = False except webbrowser.Error: launch_browser = False return launch_browser
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'launch_browser'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'attempt_launch_browser'}; {'id': '6', 'type': 'True', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8', '15', '24', '27', '31', '97']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_DISPLAY_VARIABLES'}; {'id': '11', 'type': 'list', 'children': ['12', '13', '14'], 'value': "['DISPLAY', 'WAYLAND_DISPLAY', 'MIR_SOCKET']"}; {'id': '12', 'type': 'string', 'children': [], 'value': "'DISPLAY'"}; {'id': '13', 'type': 'string', 'children': [], 'value': "'WAYLAND_DISPLAY'"}; {'id': '14', 'type': 'string', 'children': [], 'value': "'MIR_SOCKET'"}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_WEBBROWSER_NAMES_BLACKLIST'}; {'id': '18', 'type': 'list', 'children': ['19', '20', '21', '22', '23'], 'value': "[\n 'www-browser', 'lynx', 'links', 'elinks', 'w3m']"}; {'id': '19', 'type': 'string', 'children': [], 'value': "'www-browser'"}; {'id': '20', 'type': 'string', 'children': [], 'value': "'lynx'"}; {'id': '21', 'type': 'string', 'children': [], 'value': "'links'"}; {'id': '22', 'type': 'string', 'children': [], 'value': "'elinks'"}; {'id': '23', 'type': 'string', 'children': [], 'value': "'w3m'"}; {'id': '24', 'type': 'import_statement', 'children': ['25']}; {'id': '25', 'type': 'dotted_name', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'webbrowser'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'launch_browser'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'attempt_launch_browser'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'launch_browser'}; {'id': '33', 'type': 'block', 'children': ['34', '60']}; {'id': '34', 'type': 'if_statement', 'children': ['35', '55']}; {'id': '35', 'type': '()', 'children': ['36']}; {'id': '36', 'type': 'boolean_operator', 'children': ['37', '42'], 'value': 'and'}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': 'in'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'linux'"}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '42', 'type': 'not_operator', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '45', 'type': 'generator_expression', 'children': ['46', '52']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'getenv'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '52', 'type': 'for_in_clause', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_DISPLAY_VARIABLES'}; {'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': 'launch_browser'}; {'id': '59', 'type': 'False', 'children': []}; {'id': '60', 'type': 'try_statement', 'children': ['61', '88']}; {'id': '61', 'type': 'block', 'children': ['62', '70']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'browser'}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'webbrowser'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '69', 'type': 'argument_list', 'children': []}; {'id': '70', 'type': 'if_statement', 'children': ['71', '83']}; {'id': '71', 'type': '()', 'children': ['72']}; {'id': '72', 'type': 'boolean_operator', 'children': ['73', '78'], 'value': 'and'}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'browser'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '78', 'type': 'comparison_operator', 'children': ['79', '82'], 'value': 'in'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'browser'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': '_WEBBROWSER_NAMES_BLACKLIST'}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'launch_browser'}; {'id': '87', 'type': 'False', 'children': []}; {'id': '88', 'type': 'except_clause', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'webbrowser'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'Error'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'launch_browser'}; {'id': '96', 'type': 'False', 'children': []}; {'id': '97', 'type': 'return_statement', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'launch_browser'}
Decide if we should launch a browser
def send_exit_with_code(cls, sock, code): encoded_exit_status = cls.encode_int(code) cls.send_exit(sock, payload=encoded_exit_status)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_exit_with_code'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '7', 'type': 'block', 'children': ['8', '17']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'encoded_exit_status'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'encode_int'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'code'}; {'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': 'cls'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'send_exit'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'encoded_exit_status'}
Send an Exit chunk over the specified socket, containing the specified return code.
def kinetic_law_reaction_parameters(self): for parameter in self._root.iterfind( './{}/{}/{}'.format(self._reader._sbml_tag('kineticLaw'), self._reader._sbml_tag('listOfParameters'), self._reader._sbml_tag('parameter'))): param_id = parameter.get('id') param_name = parameter.get('name') param_value = Decimal(parameter.get('value')) param_units = parameter.get('units') yield param_id, param_name, param_value, param_units
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'kinetic_law_reaction_parameters'}; {'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', '44']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'parameter'}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_root'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'iterfind'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'./{}/{}/{}'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '28', '36']}; {'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': '_reader'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_sbml_tag'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'kineticLaw'"}; {'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': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_reader'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_sbml_tag'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'listOfParameters'"}; {'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': '_reader'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '_sbml_tag'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'parameter'"}; {'id': '44', 'type': 'block', 'children': ['45', '54', '63', '75', '84']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'param_id'}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'parameter'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'param_name'}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'parameter'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'param_value'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'Decimal'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'parameter'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'param_units'}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'parameter'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'string', 'children': [], 'value': "'units'"}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'yield', 'children': ['86']}; {'id': '86', 'type': 'expression_list', 'children': ['87', '88', '89', '90']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'param_id'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'param_name'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'param_value'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'param_units'}
Iterator over the values of kinetic law reaction parameters
def _get_aggregated_info(self): agg_results = {} for key in self.aggregated_info['occurrences']: agg_results[key] = { 'occurrences': self.aggregated_info['occurrences'].get(key), 'coverage': (float(self.aggregated_info['occurrences'] .get(key))/float(self.get_metadata('items_count')))*100 } return agg_results
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_aggregated_info'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '64']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'agg_results'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '17']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '12', 'type': 'subscript', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'aggregated_info'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'occurrences'"}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'agg_results'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '23', 'type': 'dictionary', 'children': ['24', '36']}; {'id': '24', 'type': 'pair', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'occurrences'"}; {'id': '26', 'type': 'call', 'children': ['27', '34']}; {'id': '27', 'type': 'attribute', 'children': ['28', '33']}; {'id': '28', 'type': 'subscript', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'aggregated_info'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'occurrences'"}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '36', 'type': 'pair', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': "'coverage'"}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '63'], 'value': '*'}; {'id': '39', 'type': '()', 'children': ['40']}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '54'], 'value': '/'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '52']}; {'id': '45', 'type': 'attribute', 'children': ['46', '51']}; {'id': '46', 'type': 'subscript', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'aggregated_info'}; {'id': '50', 'type': 'string', 'children': [], 'value': "'occurrences'"}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'get_metadata'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'items_count'"}; {'id': '63', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '64', 'type': 'return_statement', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'agg_results'}
Keeps track of aggregated info in a dictionary called self.aggregated_info
def determine_metadata(self, request, view): metadata = super( DynamicMetadata, self).determine_metadata( request, view) metadata['features'] = getattr(view, 'features', []) if hasattr(view, 'get_serializer'): serializer = view.get_serializer(dynamic=False) if hasattr(serializer, 'get_name'): metadata['resource_name'] = serializer.get_name() if hasattr(serializer, 'get_plural_name'): metadata['resource_name_plural'] = serializer.get_plural_name() metadata['properties'] = self.get_serializer_info(serializer) return metadata
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'determine_metadata'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '7', 'type': 'block', 'children': ['8', '22', '33', '85', '96']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '11', 'type': 'call', 'children': ['12', '19']}; {'id': '12', 'type': 'attribute', 'children': ['13', '18']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'DynamicMetadata'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'determine_metadata'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '27']}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'features'"}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31', '32']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'features'"}; {'id': '32', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '39']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'get_serializer'"}; {'id': '39', 'type': 'block', 'children': ['40', '51', '68']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'get_serializer'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'keyword_argument', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'dynamic'}; {'id': '50', 'type': 'False', 'children': []}; {'id': '51', 'type': 'if_statement', 'children': ['52', '57']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '56', 'type': 'string', 'children': [], 'value': "'get_name'"}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '63']}; {'id': '60', 'type': 'subscript', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '62', 'type': 'string', 'children': [], 'value': "'resource_name'"}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'get_name'}; {'id': '67', 'type': 'argument_list', 'children': []}; {'id': '68', 'type': 'if_statement', 'children': ['69', '74']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '73', 'type': 'string', 'children': [], 'value': "'get_plural_name'"}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '80']}; {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '79', 'type': 'string', 'children': [], 'value': "'resource_name_plural'"}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'get_plural_name'}; {'id': '84', 'type': 'argument_list', 'children': []}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '90']}; {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '89', 'type': 'string', 'children': [], 'value': "'properties'"}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'get_serializer_info'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '96', 'type': 'return_statement', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'metadata'}
Adds `properties` and `features` to the metadata response.
def fix_pickle(self): from coconut import __coconut__ for var in self.vars: if not var.startswith("__") and var in dir(__coconut__): self.vars[var] = getattr(__coconut__, var)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fix_pickle'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '11']}; {'id': '6', 'type': 'import_from_statement', 'children': ['7', '9']}; {'id': '7', 'type': 'dotted_name', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'coconut'}; {'id': '9', 'type': 'dotted_name', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '__coconut__'}; {'id': '11', 'type': 'for_statement', 'children': ['12', '13', '16']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '32']}; {'id': '18', 'type': 'boolean_operator', 'children': ['19', '26'], 'value': 'and'}; {'id': '19', 'type': 'not_operator', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"__"'}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'in'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '__coconut__'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '40']}; {'id': '35', 'type': 'subscript', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '__coconut__'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'var'}
Fix pickling of Coconut header objects.
def _tcpdump_callback(self, line, kill_switch): line = line.lower() if ("listening" in line) or ("reading" in line): self.started = True if ("no suitable device" in line): self.error = True self.kill_switch() if "by kernel" in line: self.stopped = True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_tcpdump_callback'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kill_switch'}; {'id': '7', 'type': 'block', 'children': ['8', '16', '33', '51']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'if_statement', 'children': ['17', '26']}; {'id': '17', 'type': 'boolean_operator', 'children': ['18', '22'], 'value': 'or'}; {'id': '18', 'type': '()', 'children': ['19']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': 'in'}; {'id': '20', 'type': 'string', 'children': [], 'value': '"listening"'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '22', 'type': '()', 'children': ['23']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': 'in'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"reading"'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'started'}; {'id': '32', 'type': 'True', 'children': []}; {'id': '33', 'type': 'if_statement', 'children': ['34', '38']}; {'id': '34', 'type': '()', 'children': ['35']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'in'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"no suitable device"'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '38', 'type': 'block', 'children': ['39', '45']}; {'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': 'error'}; {'id': '44', 'type': 'True', 'children': []}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'kill_switch'}; {'id': '50', 'type': 'argument_list', 'children': []}; {'id': '51', 'type': 'if_statement', 'children': ['52', '55']}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '54'], 'value': 'in'}; {'id': '53', 'type': 'string', 'children': [], 'value': '"by kernel"'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'stopped'}; {'id': '61', 'type': 'True', 'children': []}
Callback function to handle tcpdump
def hdate(self, date): if date is None and isinstance(self.gdate, datetime.date): date = self.hdate if not isinstance(date, HebrewDate): raise TypeError('date: {} is not of type HebrewDate'.format(date)) if not 0 < date.month < 15: raise ValueError( 'month ({}) legal values are 1-14'.format(date.month)) if not 0 < date.day < 31: raise ValueError('day ({}) legal values are 1-31'.format(date.day)) self._last_updated = "hdate" self._hdate = date
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hdate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '6', 'type': 'block', 'children': ['7', '28', '46', '67', '88', '94']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '21']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '12'], 'value': 'and'}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'is'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'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': 'gdate'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'date'}; {'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': 'date'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'hdate'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '35']}; {'id': '29', 'type': 'not_operator', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'HebrewDate'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'raise_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'string', 'children': [], 'value': "'date: {} is not of type HebrewDate'"}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '54']}; {'id': '47', 'type': 'not_operator', 'children': ['48']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50', '53'], 'value': '<'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '15'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'raise_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'string', 'children': [], 'value': "'month ({}) legal values are 1-14'"}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '67', 'type': 'if_statement', 'children': ['68', '75']}; {'id': '68', 'type': 'not_operator', 'children': ['69']}; {'id': '69', 'type': 'comparison_operator', 'children': ['70', '71', '74'], 'value': '<'}; {'id': '70', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '74', 'type': 'integer', 'children': [], 'value': '31'}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'raise_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'string', 'children': [], 'value': "'day ({}) legal values are 1-31'"}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': '_last_updated'}; {'id': '93', 'type': 'string', 'children': [], 'value': '"hdate"'}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': '_hdate'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'date'}
Set the dates of the HDate object based on a given Hebrew date.
def _list_selection_changed(self): items = self.list_layers_in_map_report.selectedItems() self.remove_layer.setEnabled(len(items) >= 1) if len(items) == 1 and self.list_layers_in_map_report.count() >= 2: index = self.list_layers_in_map_report.indexFromItem(items[0]) index = index.row() if index == 0: self.move_up.setEnabled(False) self.move_down.setEnabled(True) elif index == self.list_layers_in_map_report.count() - 1: self.move_up.setEnabled(True) self.move_down.setEnabled(False) else: self.move_up.setEnabled(True) self.move_down.setEnabled(True) else: self.move_up.setEnabled(False) self.move_down.setEnabled(False)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_list_selection_changed'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '30']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'items'}; {'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': 'list_layers_in_map_report'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'selectedItems'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'remove_layer'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'setEnabled'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '29'], 'value': '>='}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '47', '143']}; {'id': '31', 'type': 'boolean_operator', 'children': ['32', '38'], 'value': 'and'}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '37'], 'value': '=='}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '46'], 'value': '>='}; {'id': '39', 'type': 'call', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'list_layers_in_map_report'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '47', 'type': 'block', 'children': ['48', '61', '69']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '51', 'type': 'call', 'children': ['52', '57']}; {'id': '52', 'type': 'attribute', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'list_layers_in_map_report'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'indexFromItem'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '60', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '68', 'type': 'argument_list', 'children': []}; {'id': '69', 'type': 'if_statement', 'children': ['70', '73', '92', '123']}; {'id': '70', 'type': 'comparison_operator', 'children': ['71', '72'], 'value': '=='}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '72', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '73', 'type': 'block', 'children': ['74', '83']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '81']}; {'id': '76', 'type': 'attribute', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'move_up'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'setEnabled'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'False', 'children': []}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '90']}; {'id': '85', 'type': 'attribute', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'move_down'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'setEnabled'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'True', 'children': []}; {'id': '92', 'type': 'elif_clause', 'children': ['93', '104']}; {'id': '93', 'type': 'comparison_operator', 'children': ['94', '95'], 'value': '=='}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '95', 'type': 'binary_operator', 'children': ['96', '103'], 'value': '-'}; {'id': '96', 'type': 'call', 'children': ['97', '102']}; {'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': 'list_layers_in_map_report'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '102', 'type': 'argument_list', 'children': []}; {'id': '103', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '104', 'type': 'block', 'children': ['105', '114']}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'call', 'children': ['107', '112']}; {'id': '107', 'type': 'attribute', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'move_up'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'setEnabled'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'True', 'children': []}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '121']}; {'id': '116', 'type': 'attribute', 'children': ['117', '120']}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'move_down'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'setEnabled'}; {'id': '121', 'type': 'argument_list', 'children': ['122']}; {'id': '122', 'type': 'False', 'children': []}; {'id': '123', 'type': 'else_clause', 'children': ['124']}; {'id': '124', 'type': 'block', 'children': ['125', '134']}; {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'call', 'children': ['127', '132']}; {'id': '127', 'type': 'attribute', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'move_up'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'setEnabled'}; {'id': '132', 'type': 'argument_list', 'children': ['133']}; {'id': '133', 'type': 'True', 'children': []}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'call', 'children': ['136', '141']}; {'id': '136', 'type': 'attribute', 'children': ['137', '140']}; {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'move_down'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'setEnabled'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'True', 'children': []}; {'id': '143', 'type': 'else_clause', 'children': ['144']}; {'id': '144', 'type': 'block', 'children': ['145', '154']}; {'id': '145', 'type': 'expression_statement', 'children': ['146']}; {'id': '146', 'type': 'call', 'children': ['147', '152']}; {'id': '147', 'type': 'attribute', 'children': ['148', '151']}; {'id': '148', 'type': 'attribute', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'move_up'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'setEnabled'}; {'id': '152', 'type': 'argument_list', 'children': ['153']}; {'id': '153', 'type': 'False', 'children': []}; {'id': '154', 'type': 'expression_statement', 'children': ['155']}; {'id': '155', 'type': 'call', 'children': ['156', '161']}; {'id': '156', 'type': 'attribute', 'children': ['157', '160']}; {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'move_down'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'setEnabled'}; {'id': '161', 'type': 'argument_list', 'children': ['162']}; {'id': '162', 'type': 'False', 'children': []}
Selection has changed in the list.
def tweet(ctx, message): if not valid_tweet(message): click.echo("Message is too long for twitter.") click.echo("Message:" + message) ctx.exit(2) if not ctx.obj['DRYRUN']: ctx.obj['TWEEPY_API'].update_status(message) else: click.echo("Tweet not sent due to dry-run mode.")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tweet'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '6', 'type': 'block', 'children': ['7', '37']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'valid_tweet'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '13', 'type': 'block', 'children': ['14', '21', '30']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"Message is too long for twitter."'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '+'}; {'id': '28', 'type': 'string', 'children': [], 'value': '"Message:"'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'message'}; {'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': 'ctx'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '37', 'type': 'if_statement', 'children': ['38', '44', '56']}; {'id': '38', 'type': 'not_operator', 'children': ['39']}; {'id': '39', 'type': 'subscript', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'DRYRUN'"}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '54']}; {'id': '47', 'type': 'attribute', 'children': ['48', '53']}; {'id': '48', 'type': 'subscript', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '52', 'type': 'string', 'children': [], 'value': "'TWEEPY_API'"}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'update_status'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '56', 'type': 'else_clause', 'children': ['57']}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'string', 'children': [], 'value': '"Tweet not sent due to dry-run mode."'}
Sends a tweet directly to your timeline
def name_from_type(type_): if isinstance(type_, (DictType, ListType, TupleType, SetType, IteratorType)): return repr(type_) else: if type_.__name__ != 'NoneType': module = type_.__module__ if module in BUILTIN_MODULES or module == '<unknown>': return type_.__name__ else: name = getattr(type_, '__qualname__', None) or type_.__name__ delim = '.' if '.' not in name else ':' return '%s%s%s' % (module, delim, name) else: return 'None'
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'name_from_type'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'type_'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '17', '23']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'type_'}; {'id': '11', 'type': 'tuple', 'children': ['12', '13', '14', '15', '16']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'DictType'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ListType'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'TupleType'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'SetType'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'IteratorType'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'type_'}; {'id': '23', 'type': 'else_clause', 'children': ['24']}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'if_statement', 'children': ['26', '31', '82']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '30'], 'value': '!='}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'type_'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'NoneType'"}; {'id': '31', 'type': 'block', 'children': ['32', '38']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'type_'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '__module__'}; {'id': '38', 'type': 'if_statement', 'children': ['39', '46', '51']}; {'id': '39', 'type': 'boolean_operator', 'children': ['40', '43'], 'value': 'or'}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '42'], 'value': 'in'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'BUILTIN_MODULES'}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '45'], 'value': '=='}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '45', 'type': 'string', 'children': [], 'value': "'<unknown>'"}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'type_'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '51', 'type': 'else_clause', 'children': ['52']}; {'id': '52', 'type': 'block', 'children': ['53', '66', '75']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '56', 'type': 'boolean_operator', 'children': ['57', '63'], 'value': 'or'}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61', '62']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'type_'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'__qualname__'"}; {'id': '62', 'type': 'None', 'children': []}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'type_'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'delim'}; {'id': '69', 'type': 'conditional_expression', 'children': ['70', '71', '74'], 'value': 'if'}; {'id': '70', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '71', 'type': 'comparison_operator', 'children': ['72', '73'], 'value': 'not in'}; {'id': '72', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '74', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '75', 'type': 'return_statement', 'children': ['76']}; {'id': '76', 'type': 'binary_operator', 'children': ['77', '78'], 'value': '%'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'%s%s%s'"}; {'id': '78', 'type': 'tuple', 'children': ['79', '80', '81']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'delim'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '82', 'type': 'else_clause', 'children': ['83']}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'return_statement', 'children': ['85']}; {'id': '85', 'type': 'string', 'children': [], 'value': "'None'"}
Helper function to get PEP-484 compatible string representation of our internal types.
def aug_sysargv(cmdstr): import shlex argv = shlex.split(cmdstr) sys.argv.extend(argv)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'aug_sysargv'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cmdstr'}; {'id': '5', 'type': 'block', 'children': ['6', '9', '18']}; {'id': '6', 'type': 'import_statement', 'children': ['7']}; {'id': '7', 'type': 'dotted_name', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'shlex'}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'shlex'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'cmdstr'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'argv'}
DEBUG FUNC modify argv to look like you ran a command
def are_all_nodes_discovered(self): undiscovered = self.find_all(lambda e: not e.discovered) return len(list(undiscovered)) == 0
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'are_all_nodes_discovered'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '21']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'undiscovered'}; {'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': 'find_all'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'lambda', 'children': ['15', '17']}; {'id': '15', 'type': 'lambda_parameters', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '17', 'type': 'not_operator', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'discovered'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '30'], 'value': '=='}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'undiscovered'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '0'}
Reports whether there are nodes whose node info is still unknown.
def _build_relations_config(self, yamlconfig): config = {} for element in yamlconfig: if isinstance(element, str): config[element] = {'relation_name': element, 'schemas': []} elif isinstance(element, dict): if 'relation_name' not in element or 'schemas' not in element: self.log.warning("Unknown element format for relation element %s", element) continue if not isinstance(element['schemas'], list): self.log.warning("Expected a list of schemas for %s", element) continue name = element['relation_name'] config[name] = {'relation_name': name, 'schemas': element['schemas']} else: self.log.warning('Unhandled relations config type: {}'.format(element)) return config
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_build_relations_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'yamlconfig'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '118']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '10', 'type': 'dictionary', 'children': []}; {'id': '11', 'type': 'for_statement', 'children': ['12', '13', '14']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'yamlconfig'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '21', '34', '102']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '27']}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '27', 'type': 'dictionary', 'children': ['28', '31']}; {'id': '28', 'type': 'pair', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'relation_name'"}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '31', 'type': 'pair', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'schemas'"}; {'id': '33', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '34', 'type': 'elif_clause', 'children': ['35', '40']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '40', 'type': 'block', 'children': ['41', '61', '82', '88']}; {'id': '41', 'type': 'if_statement', 'children': ['42', '49']}; {'id': '42', 'type': 'boolean_operator', 'children': ['43', '46'], 'value': 'or'}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '45'], 'value': 'not in'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'relation_name'"}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': 'not in'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'schemas'"}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '49', 'type': 'block', 'children': ['50', '60']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '57']}; {'id': '52', 'type': 'attribute', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59']}; {'id': '58', 'type': 'string', 'children': [], 'value': '"Unknown element format for relation element %s"'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '60', 'type': 'continue_statement', 'children': []}; {'id': '61', 'type': 'if_statement', 'children': ['62', '70']}; {'id': '62', 'type': 'not_operator', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '69']}; {'id': '66', 'type': 'subscript', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '68', 'type': 'string', 'children': [], 'value': "'schemas'"}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '70', 'type': 'block', 'children': ['71', '81']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '78']}; {'id': '73', 'type': 'attribute', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}; {'id': '79', 'type': 'string', 'children': [], 'value': '"Expected a list of schemas for %s"'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '81', 'type': 'continue_statement', 'children': []}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '85', 'type': 'subscript', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '87', 'type': 'string', 'children': [], 'value': "'relation_name'"}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '93']}; {'id': '90', 'type': 'subscript', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '93', 'type': 'dictionary', 'children': ['94', '97']}; {'id': '94', 'type': 'pair', 'children': ['95', '96']}; {'id': '95', 'type': 'string', 'children': [], 'value': "'relation_name'"}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '97', 'type': 'pair', 'children': ['98', '99']}; {'id': '98', 'type': 'string', 'children': [], 'value': "'schemas'"}; {'id': '99', 'type': 'subscript', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '101', 'type': 'string', 'children': [], 'value': "'schemas'"}; {'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', '111']}; {'id': '106', 'type': 'attribute', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'call', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'string', 'children': [], 'value': "'Unhandled relations config type: {}'"}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '118', 'type': 'return_statement', 'children': ['119']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'config'}
Builds a dictionary from relations configuration while maintaining compatibility
def section_term_branch_orders(neurites, neurite_type=NeuriteType.all): return map_sections(sectionfunc.branch_order, neurites, neurite_type=neurite_type, iterator_type=Tree.ileaf)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'section_term_branch_orders'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'neurites'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'neurite_type'}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'NeuriteType'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'map_sections'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '18', '19', '22']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'sectionfunc'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'branch_order'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'neurites'}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'neurite_type'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'neurite_type'}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'iterator_type'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'Tree'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ileaf'}
Termination section branch orders in a collection of neurites
def _parse_state_file(state_file_path='terraform.tfstate'): ret = {} with salt.utils.files.fopen(state_file_path, 'r') as fh_: tfstate = salt.utils.json.load(fh_) modules = tfstate.get('modules') if not modules: log.error('Malformed tfstate file. No modules found') return ret for module in modules: resources = module.get('resources', []) for resource_name, resource in salt.ext.six.iteritems(resources): roster_entry = None if resource['type'] == 'salt_host': roster_entry = _handle_salt_host_resource(resource) if not roster_entry: continue minion_id = roster_entry.get(MINION_ID, resource.get('id')) if not minion_id: continue if MINION_ID in roster_entry: del roster_entry[MINION_ID] _add_ssh_key(roster_entry) ret[minion_id] = roster_entry return ret
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_state_file'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'state_file_path'}; {'id': '6', 'type': 'string', 'children': [], 'value': "'terraform.tfstate'"}; {'id': '7', 'type': 'block', 'children': ['8', '12', '43', '52', '65', '157']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '11', 'type': 'dictionary', 'children': []}; {'id': '12', 'type': 'with_statement', 'children': ['13', '29']}; {'id': '13', 'type': 'with_clause', 'children': ['14']}; {'id': '14', 'type': 'with_item', 'children': ['15']}; {'id': '15', 'type': 'as_pattern', 'children': ['16', '27']}; {'id': '16', 'type': 'call', 'children': ['17', '24']}; {'id': '17', 'type': 'attribute', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'fopen'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'state_file_path'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '27', 'type': 'as_pattern_target', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'fh_'}; {'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': 'tfstate'}; {'id': '33', 'type': 'call', 'children': ['34', '41']}; {'id': '34', 'type': 'attribute', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'fh_'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'tfstate'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'string', 'children': [], 'value': "'modules'"}; {'id': '52', 'type': 'if_statement', 'children': ['53', '55']}; {'id': '53', 'type': 'not_operator', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '55', 'type': 'block', 'children': ['56', '63']}; {'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': 'log'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'Malformed tfstate file. No modules found'"}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '65', 'type': 'for_statement', 'children': ['66', '67', '68']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '68', 'type': 'block', 'children': ['69', '79']}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'resources'}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '76', 'type': 'argument_list', 'children': ['77', '78']}; {'id': '77', 'type': 'string', 'children': [], 'value': "'resources'"}; {'id': '78', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '79', 'type': 'for_statement', 'children': ['80', '83', '93']}; {'id': '80', 'type': 'pattern_list', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'resource_name'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '83', 'type': 'call', 'children': ['84', '91']}; {'id': '84', 'type': 'attribute', 'children': ['85', '90']}; {'id': '85', 'type': 'attribute', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'resources'}; {'id': '93', 'type': 'block', 'children': ['94', '98', '112', '117', '132', '137', '146', '151']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'roster_entry'}; {'id': '97', 'type': 'None', 'children': []}; {'id': '98', 'type': 'if_statement', 'children': ['99', '104']}; {'id': '99', 'type': 'comparison_operator', 'children': ['100', '103'], 'value': '=='}; {'id': '100', 'type': 'subscript', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '102', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '103', 'type': 'string', 'children': [], 'value': "'salt_host'"}; {'id': '104', 'type': 'block', 'children': ['105']}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'roster_entry'}; {'id': '108', 'type': 'call', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': '_handle_salt_host_resource'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '112', 'type': 'if_statement', 'children': ['113', '115']}; {'id': '113', 'type': 'not_operator', 'children': ['114']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'roster_entry'}; {'id': '115', 'type': 'block', 'children': ['116']}; {'id': '116', 'type': 'continue_statement', 'children': []}; {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'assignment', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'minion_id'}; {'id': '120', 'type': 'call', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'roster_entry'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '124', 'type': 'argument_list', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'MINION_ID'}; {'id': '126', 'type': 'call', 'children': ['127', '130']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '130', 'type': 'argument_list', 'children': ['131']}; {'id': '131', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '132', 'type': 'if_statement', 'children': ['133', '135']}; {'id': '133', 'type': 'not_operator', 'children': ['134']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'minion_id'}; {'id': '135', 'type': 'block', 'children': ['136']}; {'id': '136', 'type': 'continue_statement', 'children': []}; {'id': '137', 'type': 'if_statement', 'children': ['138', '141']}; {'id': '138', 'type': 'comparison_operator', 'children': ['139', '140'], 'value': 'in'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'MINION_ID'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'roster_entry'}; {'id': '141', 'type': 'block', 'children': ['142']}; {'id': '142', 'type': 'delete_statement', 'children': ['143']}; {'id': '143', 'type': 'subscript', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'roster_entry'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'MINION_ID'}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}; {'id': '147', 'type': 'call', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': '_add_ssh_key'}; {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'roster_entry'}; {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'assignment', 'children': ['153', '156']}; {'id': '153', 'type': 'subscript', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'minion_id'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'roster_entry'}; {'id': '157', 'type': 'return_statement', 'children': ['158']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'ret'}
Parses the terraform state file passing different resource types to the right handler
def _covar_mstep_spherical(*args): cv = _covar_mstep_diag(*args) return np.tile(cv.mean(axis=1)[:, np.newaxis], (1, cv.shape[1]))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_covar_mstep_spherical'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'block', 'children': ['7', '15']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'cv'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_covar_mstep_diag'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'list_splat', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'tile'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '35']}; {'id': '21', 'type': 'subscript', 'children': ['22', '30', '32']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'cv'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'mean'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '30', 'type': 'slice', 'children': ['31']}; {'id': '31', 'type': 'colon', 'children': []}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'newaxis'}; {'id': '35', 'type': 'tuple', 'children': ['36', '37']}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'subscript', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'cv'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '1'}
Performing the covariance M step for spherical cases
def thishost(): global _thishost if _thishost is None: try: _thishost = tuple(socket.gethostbyname_ex(socket.gethostname())[2]) except socket.gaierror: _thishost = tuple(socket.gethostbyname_ex('localhost')[2]) return _thishost
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'thishost'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '7', '51']}; {'id': '5', 'type': 'global_statement', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': '_thishost'}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'is'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_thishost'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'try_statement', 'children': ['13', '32']}; {'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': '_thishost'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'subscript', 'children': ['21', '31']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'gethostbyname_ex'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'gethostname'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '32', 'type': 'except_clause', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'gaierror'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_thishost'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'subscript', 'children': ['44', '50']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'gethostbyname_ex'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'string', 'children': [], 'value': "'localhost'"}; {'id': '50', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '_thishost'}
Return the IP addresses of the current host.
def create(cls, service=Service(), private=False): response = service.send(SRequest('POST', cls.path, data={'private': private})) return cls.from_response(response, service=service)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Service'}; {'id': '9', 'type': 'argument_list', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'private'}; {'id': '12', 'type': 'False', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14', '35']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'SRequest'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26', '29']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'POST'"}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '31', 'type': 'dictionary', 'children': ['32']}; {'id': '32', 'type': 'pair', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'private'"}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'private'}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'from_response'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'service'}
create a bin instance on the server
def all_unique(keys, axis=semantics.axis_default): index = as_index(keys, axis) return index.groups == index.size
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'all_unique'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'semantics'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'axis_default'}; {'id': '10', 'type': 'block', 'children': ['11', '19']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'as_index'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '24'], 'value': '=='}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'size'}
Returns true if all keys are unique
def show_firewall(self, firewall, **_params): return self.get(self.firewall_path % (firewall), params=_params)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show_firewall'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'firewall'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': '_params'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'return_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '21']}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '19'], 'value': '%'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'firewall_path'}; {'id': '19', 'type': '()', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'firewall'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_params'}
Fetches information of a certain firewall.
def _connectionEstablished(self, transport): self.transport = transport self.transport.writeOpen() self.heartbeater.schedule()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_connectionEstablished'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'transport'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '21']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'transport'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'transport'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'transport'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'writeOpen'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'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': 'heartbeater'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'schedule'}; {'id': '28', 'type': 'argument_list', 'children': []}
Store a reference to our transport and write an open frame.
def to_bucket(self, timestamp, steps=0): dt = datetime.utcfromtimestamp( timestamp ) if steps!=0: if self._step == 'daily': dt = dt + timedelta(days=steps) elif self._step == 'weekly': dt = dt + timedelta(weeks=steps) elif self._step == 'monthly': dt = dt + MonthDelta(steps) elif self._step == 'yearly': year = int(dt.strftime( self.FORMATS[self._step] )) year += steps dt = datetime(year=year, month=1, day=1) return int(dt.strftime( self.FORMATS[self._step] ))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_bucket'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'timestamp'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'steps'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '9', 'type': 'block', 'children': ['10', '19', '120']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'utcfromtimestamp'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'timestamp'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '23']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': '!='}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'steps'}; {'id': '22', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'if_statement', 'children': ['25', '30', '42', '60', '76']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '29'], 'value': '=='}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_step'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'daily'"}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '36'], 'value': '+'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'steps'}; {'id': '42', 'type': 'elif_clause', 'children': ['43', '48']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '47'], 'value': '=='}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_step'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'weekly'"}; {'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': 'dt'}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '54'], 'value': '+'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'weeks'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'steps'}; {'id': '60', 'type': 'elif_clause', 'children': ['61', '66']}; {'id': '61', 'type': 'comparison_operator', 'children': ['62', '65'], 'value': '=='}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '_step'}; {'id': '65', 'type': 'string', 'children': [], 'value': "'monthly'"}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '70', 'type': 'binary_operator', 'children': ['71', '72'], 'value': '+'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'MonthDelta'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'steps'}; {'id': '76', 'type': 'elif_clause', 'children': ['77', '82']}; {'id': '77', 'type': 'comparison_operator', 'children': ['78', '81'], 'value': '=='}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': '_step'}; {'id': '81', 'type': 'string', 'children': [], 'value': "'yearly'"}; {'id': '82', 'type': 'block', 'children': ['83', '101', '105']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'strftime'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'subscript', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'FORMATS'}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': '_step'}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'augmented_assignment', 'children': ['103', '104'], 'value': '+='}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'steps'}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '108', 'type': 'call', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '110', 'type': 'argument_list', 'children': ['111', '114', '117']}; {'id': '111', 'type': 'keyword_argument', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '114', 'type': 'keyword_argument', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '116', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '117', 'type': 'keyword_argument', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '119', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '120', 'type': 'return_statement', 'children': ['121']}; {'id': '121', 'type': 'call', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '123', 'type': 'argument_list', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'strftime'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}; {'id': '129', 'type': 'subscript', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'FORMATS'}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': '_step'}
Calculate the bucket from a timestamp.
def whoami(ctx, opts): click.echo("Retrieving your authentication status from the API ... ", nl=False) context_msg = "Failed to retrieve your authentication status!" with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg): with maybe_spinner(opts): is_auth, username, email, name = get_user_brief() click.secho("OK", fg="green") click.echo("You are authenticated as:") if not is_auth: click.secho("Nobody (i.e. anonymous user)", fg="yellow") else: click.secho( "%(name)s (slug: %(username)s, email: %(email)s)" % { "name": click.style(name, fg="cyan"), "username": click.style(username, fg="magenta"), "email": click.style(email, fg="green"), } )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'whoami'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '21', '53', '63', '70']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'string', 'children': [], 'value': '"Retrieving your authentication status from the API ... "'}; {'id': '14', 'type': 'keyword_argument', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'nl'}; {'id': '16', 'type': 'False', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'context_msg'}; {'id': '20', 'type': 'string', 'children': [], 'value': '"Failed to retrieve your authentication status!"'}; {'id': '21', 'type': 'with_statement', 'children': ['22', '34']}; {'id': '22', 'type': 'with_clause', 'children': ['23']}; {'id': '23', 'type': 'with_item', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'handle_api_exceptions'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28', '31']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'context_msg'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'context_msg'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'with_statement', 'children': ['36', '42']}; {'id': '36', 'type': 'with_clause', 'children': ['37']}; {'id': '37', 'type': 'with_item', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'maybe_spinner'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '50']}; {'id': '45', 'type': 'pattern_list', 'children': ['46', '47', '48', '49']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'is_auth'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'get_user_brief'}; {'id': '52', 'type': 'argument_list', 'children': []}; {'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': 'click'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'secho'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'string', 'children': [], 'value': '"OK"'}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '62', 'type': 'string', 'children': [], 'value': '"green"'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'string', 'children': [], 'value': '"You are authenticated as:"'}; {'id': '70', 'type': 'if_statement', 'children': ['71', '73', '84']}; {'id': '71', 'type': 'not_operator', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'is_auth'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'secho'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '81']}; {'id': '80', 'type': 'string', 'children': [], 'value': '"Nobody (i.e. anonymous user)"'}; {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '83', 'type': 'string', 'children': [], 'value': '"yellow"'}; {'id': '84', 'type': 'else_clause', 'children': ['85']}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'secho'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'binary_operator', 'children': ['93', '94'], 'value': '%'}; {'id': '93', 'type': 'string', 'children': [], 'value': '"%(name)s (slug: %(username)s, email: %(email)s)"'}; {'id': '94', 'type': 'dictionary', 'children': ['95', '106', '117']}; {'id': '95', 'type': 'pair', 'children': ['96', '97']}; {'id': '96', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '101', 'type': 'argument_list', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '103', 'type': 'keyword_argument', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '105', 'type': 'string', 'children': [], 'value': '"cyan"'}; {'id': '106', 'type': 'pair', 'children': ['107', '108']}; {'id': '107', 'type': 'string', 'children': [], 'value': '"username"'}; {'id': '108', 'type': 'call', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '112', 'type': 'argument_list', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '114', 'type': 'keyword_argument', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '116', 'type': 'string', 'children': [], 'value': '"magenta"'}; {'id': '117', 'type': 'pair', 'children': ['118', '119']}; {'id': '118', 'type': 'string', 'children': [], 'value': '"email"'}; {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '123', 'type': 'argument_list', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '125', 'type': 'keyword_argument', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '127', 'type': 'string', 'children': [], 'value': '"green"'}
Retrieve your current authentication status.
def append_value(dictionary, key, item): items = dictionary.get(key, []) items.append(item) dictionary[key] = items
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'append_value'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dictionary'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '25']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'dictionary'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '17', 'type': 'list', 'children': [], 'value': '[]'}; {'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': 'items'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '30']}; {'id': '27', 'type': 'subscript', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'dictionary'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'items'}
Append those items to the values for that key
def endpoint_update(**kwargs): client = get_client() endpoint_id = kwargs.pop("endpoint_id") get_res = client.get_endpoint(endpoint_id) if get_res["host_endpoint_id"]: endpoint_type = "shared" elif get_res["is_globus_connect"]: endpoint_type = "personal" elif get_res["s3_url"]: endpoint_type = "s3" else: endpoint_type = "server" validate_endpoint_create_and_update_params( endpoint_type, get_res["subscription_id"], kwargs ) ep_doc = assemble_generic_doc("endpoint", **kwargs) res = client.update_endpoint(endpoint_id, ep_doc) formatted_print(res, text_format=FORMAT_TEXT_RAW, response_key="message")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'endpoint_update'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'dictionary_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '22', '31', '64', '73', '82', '92']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'get_client'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'endpoint_id'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'string', 'children': [], 'value': '"endpoint_id"'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'get_res'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'get_endpoint'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'endpoint_id'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '35', '40', '49', '58']}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'get_res'}; {'id': '34', 'type': 'string', 'children': [], 'value': '"host_endpoint_id"'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'endpoint_type'}; {'id': '39', 'type': 'string', 'children': [], 'value': '"shared"'}; {'id': '40', 'type': 'elif_clause', 'children': ['41', '44']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'get_res'}; {'id': '43', 'type': 'string', 'children': [], 'value': '"is_globus_connect"'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'endpoint_type'}; {'id': '48', 'type': 'string', 'children': [], 'value': '"personal"'}; {'id': '49', 'type': 'elif_clause', 'children': ['50', '53']}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'get_res'}; {'id': '52', 'type': 'string', 'children': [], 'value': '"s3_url"'}; {'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': 'endpoint_type'}; {'id': '57', 'type': 'string', 'children': [], 'value': '"s3"'}; {'id': '58', 'type': 'else_clause', 'children': ['59']}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'endpoint_type'}; {'id': '63', 'type': 'string', 'children': [], 'value': '"server"'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'validate_endpoint_create_and_update_params'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69', '72']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'endpoint_type'}; {'id': '69', 'type': 'subscript', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'get_res'}; {'id': '71', 'type': 'string', 'children': [], 'value': '"subscription_id"'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'ep_doc'}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'assemble_generic_doc'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}; {'id': '79', 'type': 'string', 'children': [], 'value': '"endpoint"'}; {'id': '80', 'type': 'dictionary_splat', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'update_endpoint'}; {'id': '89', 'type': 'argument_list', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'endpoint_id'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'ep_doc'}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'call', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'formatted_print'}; {'id': '95', 'type': 'argument_list', 'children': ['96', '97', '100']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '97', 'type': 'keyword_argument', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'text_format'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'FORMAT_TEXT_RAW'}; {'id': '100', 'type': 'keyword_argument', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'response_key'}; {'id': '102', 'type': 'string', 'children': [], 'value': '"message"'}
Executor for `globus endpoint update`
def visit_ifexp(self, node, parent): newnode = nodes.IfExp(node.lineno, node.col_offset, parent) newnode.postinit( self.visit(node.test, newnode), self.visit(node.body, newnode), self.visit(node.orelse, newnode), ) return newnode
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'visit_ifexp'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '7', 'type': 'block', 'children': ['8', '23', '56']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'newnode'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'IfExp'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '19', '22']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'lineno'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'col_offset'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'newnode'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'postinit'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '38', '47']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'visit'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'test'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'newnode'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'visit'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'newnode'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'visit'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'orelse'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'newnode'}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'newnode'}
visit a IfExp node by returning a fresh instance of it
def to_dataframe(self, **kwargs): return pandas.io.parsers.read_csv(self.path, sep=self.d, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_dataframe'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '17']}; {'id': '10', 'type': 'attribute', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'pandas'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'io'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'parsers'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'read_csv'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '21', '26']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '26', 'type': 'dictionary_splat', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Load up the CSV file as a pandas dataframe
def start(self): self._lc = LoopingCall(self._download) self._lc.start(30, now=True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17']}; {'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': '_lc'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'LoopingCall'}; {'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': '_download'}; {'id': '17', 'type': 'expression_statement', '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': '_lc'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'integer', 'children': [], 'value': '30'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '28', 'type': 'True', 'children': []}
Start the background process.
def RGB(self, val): val = np.atleast_1d(val).astype(np.float32) / 255. self.rgba = val
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'RGB'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '6', 'type': 'block', 'children': ['7', '25']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '24'], 'value': '/'}; {'id': '11', 'type': 'call', 'children': ['12', '20']}; {'id': '12', 'type': 'attribute', 'children': ['13', '19']}; {'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': 'atleast_1d'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'astype'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'float32'}; {'id': '24', 'type': 'float', 'children': [], 'value': '255.'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'rgba'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'val'}
Set the color using an Nx3 array of RGB uint8 values
def _hilink_decrypt(self, encrypted_firmware): cipher = DES.new(self.DES_KEY, DES.MODE_ECB) p1 = encrypted_firmware[0:3] p2 = encrypted_firmware[3:] p2 += b"\x00" * (8 - (len(p2) % 8)) d1 = p1 + cipher.decrypt(p2) d1 += b"\x00" * (8 - (len(d1) % 8)) return cipher.decrypt(d1)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_hilink_decrypt'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'encrypted_firmware'}; {'id': '6', 'type': 'block', 'children': ['7', '21', '30', '38', '53', '64', '79']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'cipher'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'DES'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'new'}; {'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': 'DES_KEY'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'DES'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'MODE_ECB'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'p1'}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'encrypted_firmware'}; {'id': '26', 'type': 'slice', 'children': ['27', '28', '29']}; {'id': '27', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '28', 'type': 'colon', 'children': []}; {'id': '29', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'p2'}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'encrypted_firmware'}; {'id': '35', 'type': 'slice', 'children': ['36', '37']}; {'id': '36', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '37', 'type': 'colon', 'children': []}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'augmented_assignment', 'children': ['40', '41'], 'value': '+='}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'p2'}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '43'], 'value': '*'}; {'id': '42', 'type': 'string', 'children': [], 'value': 'b"\\x00"'}; {'id': '43', 'type': '()', 'children': ['44']}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '46'], 'value': '-'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '46', 'type': '()', 'children': ['47']}; {'id': '47', 'type': 'binary_operator', 'children': ['48', '52'], 'value': '%'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'p2'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'd1'}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '58'], 'value': '+'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'p1'}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'cipher'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'decrypt'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'p2'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'augmented_assignment', 'children': ['66', '67'], 'value': '+='}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'd1'}; {'id': '67', 'type': 'binary_operator', 'children': ['68', '69'], 'value': '*'}; {'id': '68', 'type': 'string', 'children': [], 'value': 'b"\\x00"'}; {'id': '69', 'type': '()', 'children': ['70']}; {'id': '70', 'type': 'binary_operator', 'children': ['71', '72'], 'value': '-'}; {'id': '71', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '72', 'type': '()', 'children': ['73']}; {'id': '73', 'type': 'binary_operator', 'children': ['74', '78'], 'value': '%'}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'd1'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '79', 'type': 'return_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'cipher'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'decrypt'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'd1'}
This does the actual decryption.
def fetchref(self, ref): log.debug('[%s] Fetching ref: %s', self.name, ref) fetch_info = self.repo.remotes.origin.fetch(ref).pop() return fetch_info.ref
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetchref'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '6', 'type': 'block', 'children': ['7', '18', '37']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14', '17']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'[%s] Fetching ref: %s'"}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'fetch_info'}; {'id': '21', 'type': 'call', 'children': ['22', '36']}; {'id': '22', 'type': 'attribute', 'children': ['23', '35']}; {'id': '23', 'type': 'call', 'children': ['24', '33']}; {'id': '24', 'type': 'attribute', 'children': ['25', '32']}; {'id': '25', 'type': 'attribute', 'children': ['26', '31']}; {'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': 'repo'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'remotes'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'origin'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'fetch'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '36', 'type': 'argument_list', 'children': []}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'fetch_info'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ref'}
Fetch a particular git ref.
def ansi(color, text): code = COLOR_CODES[color] return '\033[1;{0}m{1}{2}'.format(code, text, RESET_TERM)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ansi'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '6', 'type': 'block', 'children': ['7', '13']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '10', 'type': 'subscript', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'COLOR_CODES'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'\\033[1;{0}m{1}{2}'"}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20', '21']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'RESET_TERM'}
Wrap text in an ansi escape sequence
def _detect_term_type(): if os.name == 'nt': if os.environ.get('TERM') == 'xterm': return 'mintty' else: return 'nt' if platform.system().upper().startswith('CYGWIN'): return 'cygwin' return 'posix'
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_detect_term_type'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '30', '48']}; {'id': '5', 'type': 'if_statement', 'children': ['6', '11']}; {'id': '6', 'type': 'comparison_operator', 'children': ['7', '10'], 'value': '=='}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '10', 'type': 'string', 'children': [], 'value': "'nt'"}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '23', '26']}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '22'], 'value': '=='}; {'id': '14', 'type': 'call', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'TERM'"}; {'id': '22', 'type': 'string', 'children': [], 'value': "'xterm'"}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'mintty'"}; {'id': '26', 'type': 'else_clause', 'children': ['27']}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'nt'"}; {'id': '30', 'type': 'if_statement', 'children': ['31', '45']}; {'id': '31', 'type': 'call', 'children': ['32', '43']}; {'id': '32', 'type': 'attribute', 'children': ['33', '42']}; {'id': '33', 'type': 'call', 'children': ['34', '41']}; {'id': '34', 'type': 'attribute', 'children': ['35', '40']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'system'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'string', 'children': [], 'value': "'CYGWIN'"}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'string', 'children': [], 'value': "'cygwin'"}; {'id': '48', 'type': 'return_statement', 'children': ['49']}; {'id': '49', 'type': 'string', 'children': [], 'value': "'posix'"}
Detect the type of the terminal.
def _readcsv(self, path_to_csv): return np.genfromtxt(path_to_csv, dtype=None, delimiter=',', names=True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_readcsv'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'path_to_csv'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'genfromtxt'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14', '17', '20']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'path_to_csv'}; {'id': '14', 'type': 'keyword_argument', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'delimiter'}; {'id': '19', 'type': 'string', 'children': [], 'value': "','"}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '22', 'type': 'True', 'children': []}
reads a csv column
def update_alarm(self, entity, alarm, criteria=None, disabled=False, label=None, name=None, metadata=None): return entity.update_alarm(alarm, criteria=criteria, disabled=disabled, label=label, name=name, metadata=metadata)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_alarm'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '19']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'entity'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'alarm'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'criteria'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'disabled'}; {'id': '12', 'type': 'False', 'children': []}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'default_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'default_parameter', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'entity'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'update_alarm'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30', '33', '36', '39', '42']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'alarm'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'criteria'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'criteria'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'disabled'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'disabled'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'metadata'}
Updates an existing alarm on the given entity.
def _setup_tls_files(self, files): for file_type in TLSFileType: if file_type.value in files: file_path = files[file_type.value] setattr(self, file_type.value, TLSFile(file_path, file_type=file_type))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_setup_tls_files'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '9', '10']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'file_type'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'TLSFileType'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '17']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '16'], 'value': 'in'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'file_type'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '17', 'type': 'block', 'children': ['18', '26']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '21', 'type': 'subscript', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'file_type'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31', '34']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'file_type'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'TLSFile'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'file_type'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'file_type'}
Initiates TLSFIle objects with the paths given to this bundle
def seekset_ng(func): @functools.wraps(func) def seekcur(file, *args, seekset=os.SEEK_SET, **kw): file.seek(seekset, os.SEEK_SET) return_ = func(file, *args, seekset=seekset, **kw) return return_ return seekcur
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'seekset_ng'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '5', 'type': 'block', 'children': ['6', '54']}; {'id': '6', 'type': 'decorated_definition', 'children': ['7', '14']}; {'id': '7', 'type': 'decorator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'functools'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'wraps'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '14', 'type': 'function_definition', 'children': ['15', '16', '27']}; {'id': '15', 'type': 'function_name', 'children': [], 'value': 'seekcur'}; {'id': '16', 'type': 'parameters', 'children': ['17', '18', '20', '25']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '18', 'type': 'list_splat_pattern', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'seekset'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'SEEK_SET'}; {'id': '25', 'type': 'dictionary_splat_pattern', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '27', 'type': 'block', 'children': ['28', '38', '52']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'seek'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'seekset'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'SEEK_SET'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'return_'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45', '47', '50']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '45', 'type': 'list_splat', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'seekset'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'seekset'}; {'id': '50', 'type': 'dictionary_splat', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'return_'}; {'id': '54', 'type': 'return_statement', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'seekcur'}
Read file from start then set back to original.
def _parse_topic(client, command, actor, args): channel, _, topic = args.partition(" :") channel = client.server.get_channel(channel) channel.topic = topic or None if actor: actor = User(actor) client.dispatch_event("TOPIC", actor, channel, topic)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_topic'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'actor'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '8', 'type': 'block', 'children': ['9', '21', '32', '40', '50']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '15']}; {'id': '11', 'type': 'pattern_list', 'children': ['12', '13', '14']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'channel'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'topic'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'partition'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'string', 'children': [], 'value': '" :"'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'channel'}; {'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': 'client'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'server'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'get_channel'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'channel'}; {'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': 'channel'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'topic'}; {'id': '37', 'type': 'boolean_operator', 'children': ['38', '39'], 'value': 'or'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'topic'}; {'id': '39', 'type': 'None', 'children': []}; {'id': '40', 'type': 'if_statement', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'actor'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'actor'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'User'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'actor'}; {'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': 'client'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'dispatch_event'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '57', '58', '59']}; {'id': '56', 'type': 'string', 'children': [], 'value': '"TOPIC"'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'actor'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'channel'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'topic'}
Parse a TOPIC and update channel state, then dispatch a TOPIC event.
def _add_nested(self, rec, name, value): (typedef, target_term) = value.split('!')[0].rstrip().split(' ') getattr(rec, name)[typedef].append(target_term)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_nested'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'rec'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '8', 'type': 'block', 'children': ['9', '31']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '14']}; {'id': '11', 'type': 'tuple_pattern', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'typedef'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'target_term'}; {'id': '14', 'type': 'call', 'children': ['15', '29']}; {'id': '15', 'type': 'attribute', 'children': ['16', '28']}; {'id': '16', 'type': 'call', 'children': ['17', '27']}; {'id': '17', 'type': 'attribute', 'children': ['18', '26']}; {'id': '18', 'type': 'subscript', 'children': ['19', '25']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'!'"}; {'id': '25', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'rstrip'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '42']}; {'id': '33', 'type': 'attribute', 'children': ['34', '41']}; {'id': '34', 'type': 'subscript', 'children': ['35', '40']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'rec'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'typedef'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'target_term'}
Adds a term's nested attributes.
def steady_connection(self): return connect( self._creator, self._maxusage, self._setsession, self._failures, self._ping, self._closeable, *self._args, **self._kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'steady_connection'}; {'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': 'connect'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '13', '16', '19', '22', '25', '28', '32']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_creator'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_maxusage'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_setsession'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_failures'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_ping'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_closeable'}; {'id': '28', 'type': 'list_splat', 'children': ['29']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_args'}; {'id': '32', 'type': 'dictionary_splat', 'children': ['33']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_kwargs'}
Get a steady, non-persistent DB-API 2 connection.
def read(self, timeout=1.0): self.ser.timeout = timeout if self.ser is None: return '' return self.ser.readline()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '7', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '8', 'type': 'block', 'children': ['9', '17', '26']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ser'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '23']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '22'], 'value': 'is'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ser'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "''"}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '33']}; {'id': '28', 'type': 'attribute', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ser'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'readline'}; {'id': '33', 'type': 'argument_list', 'children': []}
read from modem port, return null string on timeout.
def __get_all_child_accounts_as_array(self, account: Account) -> List[Account]: result = [] result.append(account) for child in account.children: sub_accounts = self.__get_all_child_accounts_as_array(child) result += sub_accounts return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__get_all_child_accounts_as_array'}; {'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': 'account'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Account'}; {'id': '9', 'type': 'type', 'children': ['10']}; {'id': '10', 'type': 'generic_type', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'List'}; {'id': '12', 'type': 'type_parameter', 'children': ['13']}; {'id': '13', 'type': 'type', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Account'}; {'id': '15', 'type': 'block', 'children': ['16', '20', '27', '46']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '19', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'account'}; {'id': '27', 'type': 'for_statement', 'children': ['28', '29', '32']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'account'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '32', 'type': 'block', 'children': ['33', '42']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'sub_accounts'}; {'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': '__get_all_child_accounts_as_array'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'augmented_assignment', 'children': ['44', '45'], 'value': '+='}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'sub_accounts'}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'result'}
Returns the whole tree of child accounts in a list
def unhumanize_class(my_classes): result = [] interval = my_classes[-1] - my_classes[-2] min_value = 0 for max_value in my_classes: result.append((format_decimal(interval, min_value), format_decimal(interval, max_value))) min_value = max_value return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unhumanize_class'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'my_classes'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '22', '26', '51']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'interval'}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '18'], 'value': '-'}; {'id': '14', 'type': 'subscript', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'my_classes'}; {'id': '16', 'type': 'unary_operator', 'children': ['17'], 'value': '-'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'my_classes'}; {'id': '20', 'type': 'unary_operator', 'children': ['21'], 'value': '-'}; {'id': '21', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'min_value'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '26', 'type': 'for_statement', 'children': ['27', '28', '29']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'max_value'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'my_classes'}; {'id': '29', 'type': 'block', 'children': ['30', '47']}; {'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': 'result'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'tuple', 'children': ['37', '42']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'format_decimal'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'interval'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'min_value'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'format_decimal'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'interval'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'max_value'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'min_value'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'max_value'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'result'}
Return class as interval without formatting.
def install_scripts(distributions): try: if "__PEX_UNVENDORED__" in __import__("os").environ: from setuptools.command import easy_install else: from pex.third_party.setuptools.command import easy_install if "__PEX_UNVENDORED__" in __import__("os").environ: import pkg_resources else: import pex.third_party.pkg_resources as pkg_resources except ImportError: raise RuntimeError("'wheel install_scripts' needs setuptools.") for dist in distributions: pkg_resources_dist = pkg_resources.get_distribution(dist) install = get_install_command(dist) command = easy_install.easy_install(install.distribution) command.args = ['wheel'] command.finalize_options() command.install_egg_scripts(pkg_resources_dist)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'install_scripts'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'distributions'}; {'id': '5', 'type': 'block', 'children': ['6', '64']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '56']}; {'id': '7', 'type': 'block', 'children': ['8', '34']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '17', '24']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'in'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"__PEX_UNVENDORED__"'}; {'id': '11', 'type': 'attribute', 'children': ['12', '16']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '__import__'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"os"'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'import_from_statement', 'children': ['19', '22']}; {'id': '19', 'type': 'dotted_name', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'setuptools'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '22', 'type': 'dotted_name', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'easy_install'}; {'id': '24', 'type': 'else_clause', 'children': ['25']}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'import_from_statement', 'children': ['27', '32']}; {'id': '27', 'type': 'dotted_name', 'children': ['28', '29', '30', '31']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'pex'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'third_party'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'setuptools'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '32', 'type': 'dotted_name', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'easy_install'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '43', '47']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'in'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"__PEX_UNVENDORED__"'}; {'id': '37', 'type': 'attribute', 'children': ['38', '42']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '__import__'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'string', 'children': [], 'value': '"os"'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'import_statement', 'children': ['45']}; {'id': '45', 'type': 'dotted_name', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'pkg_resources'}; {'id': '47', 'type': 'else_clause', 'children': ['48']}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'import_statement', 'children': ['50']}; {'id': '50', 'type': 'aliased_import', 'children': ['51', '55']}; {'id': '51', 'type': 'dotted_name', 'children': ['52', '53', '54']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'pex'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'third_party'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'pkg_resources'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'pkg_resources'}; {'id': '56', 'type': 'except_clause', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'ImportError'}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'raise_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'RuntimeError'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'string', 'children': [], 'value': '"\'wheel install_scripts\' needs setuptools."'}; {'id': '64', 'type': 'for_statement', 'children': ['65', '66', '67']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'dist'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'distributions'}; {'id': '67', 'type': 'block', 'children': ['68', '77', '84', '95', '102', '108']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'pkg_resources_dist'}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'pkg_resources'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'get_distribution'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'dist'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'install'}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'get_install_command'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'dist'}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'easy_install'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'easy_install'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'install'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'distribution'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '100', 'type': 'list', 'children': ['101'], 'value': "['wheel']"}; {'id': '101', 'type': 'string', 'children': [], 'value': "'wheel'"}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'finalize_options'}; {'id': '107', 'type': 'argument_list', 'children': []}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'install_egg_scripts'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'pkg_resources_dist'}
Regenerate the entry_points console_scripts for the named distribution.
def _add_device(self, scs_id, ha_id, name): if scs_id in self._devices: return self._devices[scs_id] = { 'name': name, 'ha_id': ha_id }
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_device'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'scs_id'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ha_id'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '8', 'type': 'block', 'children': ['9', '17']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '15']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'in'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'scs_id'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_devices'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', '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': '_devices'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'scs_id'}; {'id': '24', 'type': 'dictionary', 'children': ['25', '28']}; {'id': '25', 'type': 'pair', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '28', 'type': 'pair', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'ha_id'"}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'ha_id'}
Add device to the list of known ones
def _refresh_mine_cache(wrapped): @functools.wraps(wrapped) def wrapper(*args, **kwargs): returned = wrapped(*args, **__utils__['args.clean_kwargs'](**kwargs)) if _check_update_mine(): __salt__['mine.send']( 'docker.ps', verbose=True, all=True, host=True) return returned return wrapper
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_refresh_mine_cache'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'wrapped'}; {'id': '5', 'type': 'block', 'children': ['6', '61']}; {'id': '6', 'type': 'decorated_definition', 'children': ['7', '14']}; {'id': '7', 'type': 'decorator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'functools'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'wraps'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'wrapped'}; {'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', '38', '59']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'returned'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'wrapped'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '30']}; {'id': '28', 'type': 'list_splat', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '30', 'type': 'dictionary_splat', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '__utils__'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'args.clean_kwargs'"}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'dictionary_splat', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '38', 'type': 'if_statement', 'children': ['39', '42']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_check_update_mine'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '__salt__'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'mine.send'"}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50', '53', '56']}; {'id': '49', 'type': 'string', 'children': [], 'value': "'docker.ps'"}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '52', 'type': 'True', 'children': []}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '55', 'type': 'True', 'children': []}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '58', 'type': 'True', 'children': []}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'returned'}; {'id': '61', 'type': 'return_statement', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'wrapper'}
Decorator to trigger a refresh of salt mine data.
def _verify(self, path_prefix=None): for field, spec in self.doc_spec.iteritems(): path = self._append_path(path_prefix, field) if isinstance(spec, dict): self._verify_field_spec(spec, path) else: raise SchemaFormatException("Invalid field definition for {}", path)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_verify'}; {'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': 'path_prefix'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'for_statement', 'children': ['10', '13', '20']}; {'id': '10', 'type': 'pattern_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'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': 'doc_spec'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21', '31']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'path'}; {'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': '_append_path'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'path_prefix'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '37', '46']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'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': '_verify_field_spec'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '46', 'type': 'else_clause', 'children': ['47']}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'raise_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'SchemaFormatException'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'string', 'children': [], 'value': '"Invalid field definition for {}"'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'path'}
Verifies that this schema's doc spec is valid and makes sense.
def all_files(self): return set([entry.decode() for entry, _ in self.git.open_index().items()])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'all_files'}; {'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': 'set'}; {'id': '9', 'type': 'argument_list', 'children': ['10']}; {'id': '10', 'type': 'list_comprehension', 'children': ['11', '16']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'for_in_clause', 'children': ['17', '20']}; {'id': '17', 'type': 'pattern_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '20', 'type': 'call', 'children': ['21', '30']}; {'id': '21', 'type': 'attribute', 'children': ['22', '29']}; {'id': '22', 'type': 'call', 'children': ['23', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'git'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'open_index'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '30', 'type': 'argument_list', 'children': []}
Return a set of all the files under git control
def _save_notebook(self, os_path, nb): with self.atomic_writing(os_path, encoding='utf-8') as f: if ftdetect(os_path) == 'notebook': nbformat.write(nb, f, version=nbformat.NO_CONVERT) elif ftdetect(os_path) == 'markdown': nbjson = nbformat.writes(nb, version=nbformat.NO_CONVERT) markdown = convert(nbjson, informat='notebook', outformat='markdown', strip_outputs=self.strip_outputs) f.write(markdown)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_save_notebook'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'os_path'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'nb'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'with_statement', 'children': ['9', '23']}; {'id': '9', 'type': 'with_clause', 'children': ['10']}; {'id': '10', 'type': 'with_item', 'children': ['11']}; {'id': '11', 'type': 'as_pattern', 'children': ['12', '21']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'atomic_writing'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'os_path'}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '21', 'type': 'as_pattern_target', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'if_statement', 'children': ['25', '31', '45']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '30'], 'value': '=='}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ftdetect'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'os_path'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'notebook'"}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'nbformat'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39', '40']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'nb'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'nbformat'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'NO_CONVERT'}; {'id': '45', 'type': 'elif_clause', 'children': ['46', '52']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '51'], 'value': '=='}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ftdetect'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'os_path'}; {'id': '51', 'type': 'string', 'children': [], 'value': "'markdown'"}; {'id': '52', 'type': 'block', 'children': ['53', '67', '85']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'nbjson'}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'nbformat'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'writes'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'nb'}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'nbformat'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'NO_CONVERT'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'markdown'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'convert'}; {'id': '72', 'type': 'argument_list', 'children': ['73', '74', '77', '80']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'nbjson'}; {'id': '74', 'type': 'keyword_argument', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'informat'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'notebook'"}; {'id': '77', 'type': 'keyword_argument', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'outformat'}; {'id': '79', 'type': 'string', 'children': [], 'value': "'markdown'"}; {'id': '80', 'type': 'keyword_argument', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'strip_outputs'}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'strip_outputs'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'markdown'}
Save a notebook to an os_path.
def _feature_file(self, parallel = None, index = None): if index is None: index = 0 if parallel is None or "SGE_TASK_ID" not in os.environ else int(os.environ["SGE_TASK_ID"]) return os.path.join(self.feature_directory, "Features_%02d.hdf5" % index)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_feature_file'}; {'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': 'parallel'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '39']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '16']}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '15'], 'value': 'is'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '20', 'type': 'conditional_expression', 'children': ['21', '22', '31'], 'value': 'if'}; {'id': '21', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '22', 'type': 'boolean_operator', 'children': ['23', '26'], 'value': 'or'}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': 'is'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'parallel'}; {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'not in'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"SGE_TASK_ID"'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'subscript', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"SGE_TASK_ID"'}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '46']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'feature_directory'}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '52'], 'value': '%'}; {'id': '51', 'type': 'string', 'children': [], 'value': '"Features_%02d.hdf5"'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'index'}
Returns the name of an intermediate file for storing features.
def _virtualenv_sys(venv_path): "obtain version and path info from a virtualenv." executable = os.path.join(venv_path, env_bin_dir, 'python') p = subprocess.Popen([executable, '-c', 'import sys;' 'print (sys.version[:3]);' 'print ("\\n".join(sys.path));'], env={}, stdout=subprocess.PIPE) stdout, err = p.communicate() assert not p.returncode and stdout lines = stdout.decode('utf-8').splitlines() return lines[0], list(filter(bool, lines[1:]))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_virtualenv_sys'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'venv_path'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '21', '44', '54', '61', '74']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': '"obtain version and path info from a virtualenv."'}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'executable'}; {'id': '11', 'type': 'call', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19', '20']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'venv_path'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'env_bin_dir'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'python'"}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'Popen'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '36', '39']}; {'id': '29', 'type': 'list', 'children': ['30', '31', '32'], 'value': '[executable,\n \'-c\', \'import sys;\'\n \'print (sys.version[:3]);\'\n \'print ("\\\\n".join(sys.path));\']'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'executable'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'-c'"}; {'id': '32', 'type': 'concatenated_string', 'children': ['33', '34', '35']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'import sys;'"}; {'id': '34', 'type': 'string', 'children': [], 'value': "'print (sys.version[:3]);'"}; {'id': '35', 'type': 'string', 'children': [], 'value': '\'print ("\\\\n".join(sys.path));\''}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '38', 'type': 'dictionary', 'children': []}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'PIPE'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '49']}; {'id': '46', 'type': 'pattern_list', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'communicate'}; {'id': '53', 'type': 'argument_list', 'children': []}; {'id': '54', 'type': 'assert_statement', 'children': ['55']}; {'id': '55', 'type': 'boolean_operator', 'children': ['56', '60'], 'value': 'and'}; {'id': '56', 'type': 'not_operator', 'children': ['57']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'returncode'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '64', 'type': 'call', 'children': ['65', '73']}; {'id': '65', 'type': 'attribute', 'children': ['66', '72']}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'splitlines'}; {'id': '73', 'type': 'argument_list', 'children': []}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'expression_list', 'children': ['76', '79']}; {'id': '76', 'type': 'subscript', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '86', 'type': 'subscript', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '88', 'type': 'slice', 'children': ['89', '90']}; {'id': '89', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '90', 'type': 'colon', 'children': []}
obtain version and path info from a virtualenv.
def read(filename): return codecs.open(os.path.join(__DIR__, filename), 'r').read()
{'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': 'filename'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '25']}; {'id': '8', 'type': 'attribute', 'children': ['9', '24']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'codecs'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '23']}; {'id': '14', 'type': 'call', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '__DIR__'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '25', 'type': 'argument_list', 'children': []}
Read and return `filename` in root dir of project and return string
def _CheckConnectionEncoding(cursor): cur_character_set = _ReadVariable("character_set_connection", cursor) if cur_character_set != CHARACTER_SET: raise EncodingEnforcementError( "Require MySQL character_set_connection of {}, got {}.".format( CHARACTER_SET, cur_character_set))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_CheckConnectionEncoding'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '5', 'type': 'block', 'children': ['6', '14']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'cur_character_set'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_ReadVariable'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'string', 'children': [], 'value': '"character_set_connection"'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '14', 'type': 'if_statement', 'children': ['15', '18']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '17'], 'value': '!='}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cur_character_set'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'CHARACTER_SET'}; {'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': 'EncodingEnforcementError'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"Require MySQL character_set_connection of {}, got {}."'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'CHARACTER_SET'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'cur_character_set'}
Enforces a sane UTF-8 encoding for the database connection.
def copy(self): return Character(self.name, self.race,self.ch_class, self.stats, self.skills, self.story, self.inventory)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'copy'}; {'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': 'Character'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '13', '16', '19', '22', '25', '28']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'race'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ch_class'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'skills'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'story'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'inventory'}
make an identical copy of the character
def parse_qaml(self): logging.info('Parsing GenomeQAML outputs') nesteddictionary = dict() dictionary = pandas.read_csv(self.qaml_report).to_dict() for header in dictionary: for sample, value in dictionary[header].items(): try: nesteddictionary[sample].update({header: value}) except KeyError: nesteddictionary[sample] = dict() nesteddictionary[sample].update({header: value}) for sample in self.metadata: setattr(sample, self.analysistype, GenObject()) sample[self.analysistype].prediction = str() for line in nesteddictionary: name = nesteddictionary[line]['Sample'] if name == sample.name: sample[self.analysistype].prediction = nesteddictionary[line]['Predicted_Class']
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_qaml'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '19', '34', '87']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'string', 'children': [], 'value': "'Parsing GenomeQAML outputs'"}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'nesteddictionary'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'dictionary'}; {'id': '22', 'type': 'call', 'children': ['23', '33']}; {'id': '23', 'type': 'attribute', 'children': ['24', '32']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'pandas'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'read_csv'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'qaml_report'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'to_dict'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'for_statement', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'dictionary'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'for_statement', 'children': ['39', '42', '49']}; {'id': '39', 'type': 'pattern_list', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '42', 'type': 'call', 'children': ['43', '48']}; {'id': '43', 'type': 'attribute', 'children': ['44', '47']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'dictionary'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'try_statement', 'children': ['51', '64']}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '59']}; {'id': '54', 'type': 'attribute', 'children': ['55', '58']}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'nesteddictionary'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'dictionary', 'children': ['61']}; {'id': '61', 'type': 'pair', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '64', 'type': 'except_clause', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '66', 'type': 'block', 'children': ['67', '75']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '72']}; {'id': '69', 'type': 'subscript', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'nesteddictionary'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '74', 'type': 'argument_list', 'children': []}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '82']}; {'id': '77', 'type': 'attribute', 'children': ['78', '81']}; {'id': '78', 'type': 'subscript', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'nesteddictionary'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'dictionary', 'children': ['84']}; {'id': '84', 'type': 'pair', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '87', 'type': 'for_statement', 'children': ['88', '89', '92']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '92', 'type': 'block', 'children': ['93', '104', '116']}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '96', 'type': 'argument_list', 'children': ['97', '98', '101']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'analysistype'}; {'id': '101', 'type': 'call', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'GenObject'}; {'id': '103', 'type': 'argument_list', 'children': []}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'assignment', 'children': ['106', '113']}; {'id': '106', 'type': 'attribute', 'children': ['107', '112']}; {'id': '107', 'type': 'subscript', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'analysistype'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'prediction'}; {'id': '113', 'type': 'call', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '115', 'type': 'argument_list', 'children': []}; {'id': '116', 'type': 'for_statement', 'children': ['117', '118', '119']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'nesteddictionary'}; {'id': '119', 'type': 'block', 'children': ['120', '128']}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'assignment', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '123', 'type': 'subscript', 'children': ['124', '127']}; {'id': '124', 'type': 'subscript', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'nesteddictionary'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '127', 'type': 'string', 'children': [], 'value': "'Sample'"}; {'id': '128', 'type': 'if_statement', 'children': ['129', '134']}; {'id': '129', 'type': 'comparison_operator', 'children': ['130', '131'], 'value': '=='}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '134', 'type': 'block', 'children': ['135']}; {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'assignment', 'children': ['137', '144']}; {'id': '137', 'type': 'attribute', 'children': ['138', '143']}; {'id': '138', 'type': 'subscript', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'analysistype'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'prediction'}; {'id': '144', 'type': 'subscript', 'children': ['145', '148']}; {'id': '145', 'type': 'subscript', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'nesteddictionary'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '148', 'type': 'string', 'children': [], 'value': "'Predicted_Class'"}
Parse the GenomeQAML report, and populate metadata objects
def atlasdb_set_zonefile_tried_storage( zonefile_hash, tried_storage, con=None, path=None ): with AtlasDBOpen(con=con, path=path) as dbcon: if tried_storage: tried_storage = 1 else: tried_storage = 0 sql = "UPDATE zonefiles SET tried_storage = ? WHERE zonefile_hash = ?;" args = (tried_storage, zonefile_hash) cur = dbcon.cursor() res = atlasdb_query_execute( cur, sql, args ) dbcon.commit() return True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'atlasdb_set_zonefile_tried_storage'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'zonefile_hash'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tried_storage'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '75']}; {'id': '13', 'type': 'with_statement', 'children': ['14', '28']}; {'id': '14', 'type': 'with_clause', 'children': ['15']}; {'id': '15', 'type': 'with_item', 'children': ['16']}; {'id': '16', 'type': 'as_pattern', 'children': ['17', '26']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'AtlasDBOpen'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '23']}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '26', 'type': 'as_pattern_target', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dbcon'}; {'id': '28', 'type': 'block', 'children': ['29', '42', '46', '52', '60', '69']}; {'id': '29', 'type': 'if_statement', 'children': ['30', '31', '36']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'tried_storage'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'tried_storage'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '36', 'type': 'else_clause', 'children': ['37']}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'tried_storage'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'sql'}; {'id': '45', 'type': 'string', 'children': [], 'value': '"UPDATE zonefiles SET tried_storage = ? WHERE zonefile_hash = ?;"'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '49', 'type': 'tuple', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'tried_storage'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'zonefile_hash'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'dbcon'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'atlasdb_query_execute'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67', '68']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'sql'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'dbcon'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'commit'}; {'id': '74', 'type': 'argument_list', 'children': []}; {'id': '75', 'type': 'return_statement', 'children': ['76']}; {'id': '76', 'type': 'True', 'children': []}
Make a note that we tried to get the zonefile from storage
def stdin_readable(): if not WINDOWS: try: return bool(select([sys.stdin], [], [], 0)[0]) except Exception: logger.log_exc() try: return not sys.stdin.isatty() except Exception: logger.log_exc() return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stdin_readable'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '36', '56']}; {'id': '5', 'type': 'if_statement', 'children': ['6', '8']}; {'id': '6', 'type': 'not_operator', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'WINDOWS'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'try_statement', 'children': ['10', '27']}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'subscript', 'children': ['16', '26']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '23', '24', '25']}; {'id': '19', 'type': 'list', 'children': ['20'], 'value': '[sys.stdin]'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'stdin'}; {'id': '23', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '24', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '27', 'type': 'except_clause', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'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': 'logger'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'log_exc'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'try_statement', 'children': ['37', '47']}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'not_operator', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '46']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'stdin'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'isatty'}; {'id': '46', 'type': 'argument_list', 'children': []}; {'id': '47', 'type': 'except_clause', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'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': 'logger'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'log_exc'}; {'id': '55', 'type': 'argument_list', 'children': []}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'False', 'children': []}
Determine whether stdin has any data to read.
def data(self): data=np.empty((self.nRows,self.nCols),dtype=np.float) data[:]=np.nan for colNum,colData in enumerate(self.colData): validIs=np.where([np.isreal(v) for v in colData])[0] validData=np.ones(len(colData))*np.nan validData[validIs]=np.array(colData)[validIs] data[:len(colData),colNum]=validData return data
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '26', '35', '107']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'empty'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '21']}; {'id': '14', 'type': 'tuple', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'nRows'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'nCols'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '32']}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '30', 'type': 'slice', 'children': ['31']}; {'id': '31', 'type': 'colon', 'children': []}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'nan'}; {'id': '35', 'type': 'for_statement', 'children': ['36', '39', '45']}; {'id': '36', 'type': 'pattern_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'colNum'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'colData'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'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': 'colData'}; {'id': '45', 'type': 'block', 'children': ['46', '66', '82', '95']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'validIs'}; {'id': '49', 'type': 'subscript', 'children': ['50', '65']}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'where'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'list_comprehension', 'children': ['56', '62']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'isreal'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '62', 'type': 'for_in_clause', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'colData'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'validData'}; {'id': '69', 'type': 'binary_operator', 'children': ['70', '79'], 'value': '*'}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'ones'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'colData'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'nan'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '87']}; {'id': '84', 'type': 'subscript', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'validData'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'validIs'}; {'id': '87', 'type': 'subscript', 'children': ['88', '94']}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'colData'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'validIs'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '106']}; {'id': '97', 'type': 'subscript', 'children': ['98', '99', '105']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '99', 'type': 'slice', 'children': ['100', '101']}; {'id': '100', 'type': 'colon', 'children': []}; {'id': '101', 'type': 'call', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'colData'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'colNum'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'validData'}; {'id': '107', 'type': 'return_statement', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'data'}
return all of colData as a 2D numpy array.
def hardware_version(self): hardware_string = self.hardware_string if not isinstance(hardware_string, bytes): hardware_string = self.hardware_string.encode('utf-8') if len(hardware_string) > 10: self._logger.warn("Truncating hardware string that was longer than 10 bytes: %s", self.hardware_string) if len(hardware_string) < 10: hardware_string += b'\0'*(10 - len(hardware_string)) return [hardware_string]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hardware_version'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '31', '51', '71']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'hardware_string'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'hardware_string'}; {'id': '12', 'type': 'if_statement', 'children': ['13', '19']}; {'id': '13', 'type': 'not_operator', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'hardware_string'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'hardware_string'}; {'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': 'hardware_string'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '31', 'type': 'if_statement', 'children': ['32', '38']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '37'], 'value': '>'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'hardware_string'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '46']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': '"Truncating hardware string that was longer than 10 bytes: %s"'}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'hardware_string'}; {'id': '51', 'type': 'if_statement', 'children': ['52', '58']}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '57'], 'value': '<'}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'hardware_string'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'augmented_assignment', 'children': ['61', '62'], 'value': '+='}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'hardware_string'}; {'id': '62', 'type': 'binary_operator', 'children': ['63', '64'], 'value': '*'}; {'id': '63', 'type': 'string', 'children': [], 'value': "b'\\0'"}; {'id': '64', 'type': '()', 'children': ['65']}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '67'], 'value': '-'}; {'id': '66', 'type': 'integer', 'children': [], 'value': '10'}; {'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': 'hardware_string'}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'list', 'children': ['73'], 'value': '[hardware_string]'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'hardware_string'}
Get a hardware identification string.
def write_astrom_data(self, astrom_data): self.write_headers(astrom_data.observations, astrom_data.sys_header) self._write_source_data(astrom_data.sources)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_astrom_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'astrom_data'}; {'id': '6', 'type': 'block', 'children': ['7', '19']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'write_headers'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'astrom_data'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'observations'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'astrom_data'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'sys_header'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_write_source_data'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'astrom_data'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'sources'}
Writes a full AstromData structure at once.
def _init_attr_config(attr_cfg): attr_cfg.name = '' attr_cfg.writable = AttrWriteType.READ attr_cfg.data_format = AttrDataFormat.SCALAR attr_cfg.data_type = 0 attr_cfg.max_dim_x = 0 attr_cfg.max_dim_y = 0 attr_cfg.description = '' attr_cfg.label = '' attr_cfg.unit = '' attr_cfg.standard_unit = '' attr_cfg.display_unit = '' attr_cfg.format = '' attr_cfg.min_value = '' attr_cfg.max_value = '' attr_cfg.writable_attr_name = '' attr_cfg.extensions = []
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_init_attr_config'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'attr_cfg'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '20', '28', '34', '40', '46', '52', '58', '64', '70', '76', '82', '88', '94', '100']}; {'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': 'attr_cfg'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '11', 'type': 'string', 'children': [], 'value': "''"}; {'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': 'attr_cfg'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'writable'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'AttrWriteType'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'READ'}; {'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': 'attr_cfg'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'data_format'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'AttrDataFormat'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'SCALAR'}; {'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': 'attr_cfg'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'attr_cfg'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'max_dim_x'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'attr_cfg'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'max_dim_y'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'attr_cfg'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '51', 'type': 'string', 'children': [], 'value': "''"}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'attr_cfg'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '57', 'type': 'string', 'children': [], 'value': "''"}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'attr_cfg'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '63', 'type': 'string', 'children': [], 'value': "''"}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'attr_cfg'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'standard_unit'}; {'id': '69', 'type': 'string', 'children': [], 'value': "''"}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'attr_cfg'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'display_unit'}; {'id': '75', 'type': 'string', 'children': [], 'value': "''"}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'attr_cfg'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '81', 'type': 'string', 'children': [], 'value': "''"}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'attr_cfg'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'min_value'}; {'id': '87', 'type': 'string', 'children': [], 'value': "''"}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'attr_cfg'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'max_value'}; {'id': '93', 'type': 'string', 'children': [], 'value': "''"}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'attr_cfg'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'writable_attr_name'}; {'id': '99', 'type': 'string', 'children': [], 'value': "''"}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'attr_cfg'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'extensions'}; {'id': '105', 'type': 'list', 'children': [], 'value': '[]'}
Helper function to initialize attribute config objects
def update_role(u_name, newprivilege): entry = TabMember.update( role=newprivilege ).where(TabMember.user_name == u_name) try: entry.execute() return True except: return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_role'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'u_name'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'newprivilege'}; {'id': '6', 'type': 'block', 'children': ['7', '27']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '10', 'type': 'call', 'children': ['11', '21']}; {'id': '11', 'type': 'attribute', 'children': ['12', '20']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'TabMember'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'role'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'newprivilege'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'where'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '26'], 'value': '=='}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'TabMember'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'user_name'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'u_name'}; {'id': '27', 'type': 'try_statement', 'children': ['28', '37']}; {'id': '28', 'type': 'block', 'children': ['29', '35']}; {'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': 'entry'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'True', 'children': []}; {'id': '37', 'type': 'except_clause', 'children': ['38']}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'False', 'children': []}
Update the role of the usr.
def _find_classes_param(self): for attr in ["classes_"]: try: return getattr(self.estimator, attr) except AttributeError: continue raise YellowbrickTypeError( "could not find classes_ param on {}".format( self.estimator.__class__.__name__ ) )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_find_classes_param'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '25']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '10']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '8', 'type': 'list', 'children': ['9'], 'value': '["classes_"]'}; {'id': '9', 'type': 'string', 'children': [], 'value': '"classes_"'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'try_statement', 'children': ['12', '21']}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'estimator'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '21', 'type': 'except_clause', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'continue_statement', 'children': []}; {'id': '25', 'type': 'raise_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'YellowbrickTypeError'}; {'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': '"could not find classes_ param on {}"'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'attribute', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'estimator'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '__name__'}
Searches the wrapped model for the classes_ parameter.
def check_manual_seed(seed): seed = seed or random.randint(1, 10000) random.seed(seed) torch.manual_seed(seed) print('Using manual seed: {seed}'.format(seed=seed))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_manual_seed'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'seed'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '25', '32']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'seed'}; {'id': '9', 'type': 'boolean_operator', 'children': ['10', '11'], 'value': 'or'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'seed'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'randint'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '10000'}; {'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': 'random'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'seed'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'seed'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'torch'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'manual_seed'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'seed'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'Using manual seed: {seed}'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'seed'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'seed'}
If manual seed is not specified, choose a random one and communicate it to the user.
def read(self, source_path): with pelican_open(source_path) as text: parts = text.split('----', 1) if len(parts) == 2: headerlines = parts[0].splitlines() headerpairs = map(lambda l: l.split(':', 1), headerlines) headerdict = {pair[0]: pair[1].strip() for pair in headerpairs if len(pair) == 2} metadata = self._parse_metadata(headerdict) content = textile(parts[1]) else: metadata = {} content = textile(text) return content, metadata
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'source_path'}; {'id': '6', 'type': 'block', 'children': ['7', '119']}; {'id': '7', 'type': 'with_statement', 'children': ['8', '17']}; {'id': '8', 'type': 'with_clause', 'children': ['9']}; {'id': '9', 'type': 'with_item', 'children': ['10']}; {'id': '10', 'type': 'as_pattern', 'children': ['11', '15']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'pelican_open'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'source_path'}; {'id': '15', 'type': 'as_pattern_target', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '17', 'type': 'block', 'children': ['18', '28']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'parts'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'----'"}; {'id': '27', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '35', '106']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '34'], 'value': '=='}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'parts'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '35', 'type': 'block', 'children': ['36', '46', '63', '88', '97']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'headerlines'}; {'id': '39', 'type': 'call', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'parts'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'splitlines'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'headerpairs'}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '62']}; {'id': '52', 'type': 'lambda', 'children': ['53', '55']}; {'id': '53', 'type': 'lambda_parameters', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '61', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'headerlines'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'headerdict'}; {'id': '66', 'type': 'dictionary_comprehension', 'children': ['67', '78', '81']}; {'id': '67', 'type': 'pair', 'children': ['68', '71']}; {'id': '68', 'type': 'subscript', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'pair'}; {'id': '70', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '71', 'type': 'call', 'children': ['72', '77']}; {'id': '72', 'type': 'attribute', 'children': ['73', '76']}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'pair'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'for_in_clause', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'pair'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'headerpairs'}; {'id': '81', 'type': 'if_clause', 'children': ['82']}; {'id': '82', 'type': 'comparison_operator', 'children': ['83', '87'], 'value': '=='}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'pair'}; {'id': '87', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '91', 'type': 'call', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': '_parse_metadata'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'headerdict'}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'textile'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'subscript', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'parts'}; {'id': '105', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '106', 'type': 'else_clause', 'children': ['107']}; {'id': '107', 'type': 'block', 'children': ['108', '112']}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'assignment', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '111', 'type': 'dictionary', 'children': []}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'assignment', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '115', 'type': 'call', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'textile'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '119', 'type': 'return_statement', 'children': ['120']}; {'id': '120', 'type': 'expression_list', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'metadata'}
Parse content and metadata of textile files.
def seek_to_packet(self, index): pointer_position = self.packet_positions[index] self.blob_file.seek(pointer_position, 0)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'seek_to_packet'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '6', 'type': 'block', 'children': ['7', '15']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'pointer_position'}; {'id': '10', 'type': 'subscript', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'packet_positions'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'blob_file'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'seek'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pointer_position'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '0'}
Move file pointer to the packet with given index.
def calc_path_and_create_folders(folder, import_path): file_path = abspath(path_join(folder, import_path[:import_path.rfind(".")].replace(".", folder_seperator) + ".py")) mkdir_p(dirname(file_path)) return file_path
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calc_path_and_create_folders'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'folder'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'import_path'}; {'id': '6', 'type': 'block', 'children': ['7', '35', '43']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'path_join'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'folder'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '34'], 'value': '+'}; {'id': '18', 'type': 'call', 'children': ['19', '31']}; {'id': '19', 'type': 'attribute', 'children': ['20', '30']}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'import_path'}; {'id': '22', 'type': 'slice', 'children': ['23', '24']}; {'id': '23', 'type': 'colon', 'children': []}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'import_path'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'rfind'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'string', 'children': [], 'value': '"."'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': '"."'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'folder_seperator'}; {'id': '34', 'type': 'string', 'children': [], 'value': '".py"'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'mkdir_p'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'file_path'}
calculate the path and create the needed folders
def load(cls, filename, name=None): if not os.path.exists(filename): return {} name = name or filename if name not in cls._conffiles: with open(filename) as fdesc: content = yaml.load(fdesc, YAMLLoader) if content is None: content = {} cls._conffiles[name] = content return cls._conffiles[name]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '23', '29', '74']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '20']}; {'id': '11', 'type': 'not_operator', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'dictionary', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '26', 'type': 'boolean_operator', 'children': ['27', '28'], 'value': 'or'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '29', 'type': 'if_statement', 'children': ['30', '35']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': 'not in'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_conffiles'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'with_statement', 'children': ['37', '46']}; {'id': '37', 'type': 'with_clause', 'children': ['38']}; {'id': '38', 'type': 'with_item', 'children': ['39']}; {'id': '39', 'type': 'as_pattern', 'children': ['40', '44']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '44', 'type': 'as_pattern_target', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'fdesc'}; {'id': '46', 'type': 'block', 'children': ['47', '57', '66']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'fdesc'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'YAMLLoader'}; {'id': '57', 'type': 'if_statement', 'children': ['58', '61']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '60'], 'value': 'is'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '60', 'type': 'None', 'children': []}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '65', 'type': 'dictionary', 'children': []}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '73']}; {'id': '68', 'type': 'subscript', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': '_conffiles'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'subscript', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': '_conffiles'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'name'}
Load yaml configuration from filename.
def spawn_gdb(pid, address=DFLT_ADDRESS, gdb='gdb', verbose=False, ctx=None, proc_iut=None): parent, child = socket.socketpair() proc = Popen([gdb, '--interpreter=mi', '-nx'], bufsize=0, stdin=child, stdout=child, stderr=STDOUT) child.close() connections = {} gdb = GdbSocket(ctx, address, proc, proc_iut, parent, verbose, connections) gdb.mi_command('-target-attach %d' % pid) gdb.cli_command('python import pdb_clone.bootstrappdb_gdb') asyncore.loop(map=connections) proc.wait() return gdb.error
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'spawn_gdb'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'DFLT_ADDRESS'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'gdb'}; {'id': '10', 'type': 'string', 'children': [], 'value': "'gdb'"}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '13', 'type': 'False', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'proc_iut'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21', '31', '53', '59', '63', '76', '85', '92', '101', '107']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '26']}; {'id': '23', 'type': 'pattern_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'socketpair'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'proc'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'Popen'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '41', '44', '47', '50']}; {'id': '37', 'type': 'list', 'children': ['38', '39', '40'], 'value': "[gdb, '--interpreter=mi', '-nx']"}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'gdb'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'--interpreter=mi'"}; {'id': '40', 'type': 'string', 'children': [], 'value': "'-nx'"}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'bufsize'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '44', 'type': 'keyword_argument', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'stdin'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'STDOUT'}; {'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': 'child'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '58', 'type': 'argument_list', 'children': []}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'connections'}; {'id': '62', 'type': 'dictionary', 'children': []}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'gdb'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'GdbSocket'}; {'id': '68', 'type': 'argument_list', 'children': ['69', '70', '71', '72', '73', '74', '75']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'proc'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'proc_iut'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'connections'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'gdb'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'mi_command'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'binary_operator', 'children': ['83', '84'], 'value': '%'}; {'id': '83', 'type': 'string', 'children': [], 'value': "'-target-attach %d'"}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'gdb'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'cli_command'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'string', 'children': [], 'value': "'python import pdb_clone.bootstrappdb_gdb'"}; {'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': 'asyncore'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'keyword_argument', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'connections'}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'proc'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'wait'}; {'id': '106', 'type': 'argument_list', 'children': []}; {'id': '107', 'type': 'return_statement', 'children': ['108']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'gdb'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'error'}
Spawn gdb and attach to a process.
def from_yaml(cls, file_path=None): try: import yaml except ImportError: yaml = None if not yaml: import sys sys.exit('PyYAML is not installed, but is required in order to parse YAML files.' '\nTo install, run:\n$ pip install PyYAML\nor visit' ' http://pyyaml.org/wiki/PyYAML for instructions.') with io.open(file_path, encoding=text_type('utf-8')) as stream: users_yaml = yaml.safe_load(stream) if isinstance(users_yaml, dict): return cls.construct_user_list(raw_users=users_yaml.get('users')) else: raise ValueError('No YAML object could be decoded')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_yaml'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '21', '38']}; {'id': '9', 'type': 'try_statement', 'children': ['10', '14']}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'import_statement', 'children': ['12']}; {'id': '12', 'type': 'dotted_name', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '14', 'type': 'except_clause', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ImportError'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'if_statement', 'children': ['22', '24']}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '24', 'type': 'block', 'children': ['25', '28']}; {'id': '25', 'type': 'import_statement', 'children': ['26']}; {'id': '26', 'type': 'dotted_name', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'concatenated_string', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'PyYAML is not installed, but is required in order to parse YAML files.'"}; {'id': '36', 'type': 'string', 'children': [], 'value': "'\\nTo install, run:\\n$ pip install PyYAML\\nor visit'"}; {'id': '37', 'type': 'string', 'children': [], 'value': "' http://pyyaml.org/wiki/PyYAML for instructions.'"}; {'id': '38', 'type': 'with_statement', 'children': ['39', '56']}; {'id': '39', 'type': 'with_clause', 'children': ['40']}; {'id': '40', 'type': 'with_item', 'children': ['41']}; {'id': '41', 'type': 'as_pattern', 'children': ['42', '54']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'io'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '48', 'type': 'keyword_argument', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'text_type'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '54', 'type': 'as_pattern_target', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'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': 'users_yaml'}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'safe_load'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '66', 'type': 'if_statement', 'children': ['67', '72', '87']}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'users_yaml'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'return_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'construct_user_list'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'keyword_argument', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'raw_users'}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'users_yaml'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'string', 'children': [], 'value': "'users'"}; {'id': '87', 'type': 'else_clause', 'children': ['88']}; {'id': '88', 'type': 'block', 'children': ['89']}; {'id': '89', 'type': 'raise_statement', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'string', 'children': [], 'value': "'No YAML object could be decoded'"}
Create collection from a YAML file.
def log_context(trace_level, stream): original_trace_level = DebugInfoHolder.DEBUG_TRACE_LEVEL original_stream = DebugInfoHolder.DEBUG_STREAM DebugInfoHolder.DEBUG_TRACE_LEVEL = trace_level DebugInfoHolder.DEBUG_STREAM = stream try: yield finally: DebugInfoHolder.DEBUG_TRACE_LEVEL = original_trace_level DebugInfoHolder.DEBUG_STREAM = original_stream
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'log_context'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'trace_level'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '19', '25', '31']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'original_trace_level'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'DebugInfoHolder'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'DEBUG_TRACE_LEVEL'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'original_stream'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'DebugInfoHolder'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'DEBUG_STREAM'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'DebugInfoHolder'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'DEBUG_TRACE_LEVEL'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'trace_level'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'DebugInfoHolder'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'DEBUG_STREAM'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '31', 'type': 'try_statement', 'children': ['32', '35']}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'yield', 'children': []}; {'id': '35', 'type': 'finally_clause', 'children': ['36']}; {'id': '36', 'type': 'block', 'children': ['37', '43']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'DebugInfoHolder'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'DEBUG_TRACE_LEVEL'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'original_trace_level'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'DebugInfoHolder'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'DEBUG_STREAM'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'original_stream'}
To be used to temporarily change the logging settings.
def bitdepthof(pixel): maxd = 0 for c in re.findall(r'[a-z]\d*', pixel): if c[0] != 'x': maxd = max(maxd, int(c[1:])) return maxd
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bitdepthof'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pixel'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '42']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'maxd'}; {'id': '9', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '19']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'findall'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "r'[a-z]\\d*'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'pixel'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'if_statement', 'children': ['21', '26']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '25'], 'value': '!='}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'x'"}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'maxd'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'maxd'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '39', 'type': 'slice', 'children': ['40', '41']}; {'id': '40', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '41', 'type': 'colon', 'children': []}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'maxd'}
Return the bitdepth for a Plan9 pixel format string.
def cleanup(arctic_lib, symbol, version_ids, versions_coll, shas_to_delete=None, pointers_cfgs=None): pointers_cfgs = set(pointers_cfgs) if pointers_cfgs else set() collection = arctic_lib.get_top_level_collection() version_ids = list(version_ids) all_symbol_pointers_cfgs = _get_symbol_pointer_cfgs(symbol, versions_coll) all_symbol_pointers_cfgs.update(pointers_cfgs) if all_symbol_pointers_cfgs == {FwPointersCfg.DISABLED} or not all_symbol_pointers_cfgs: _cleanup_parent_pointers(collection, symbol, version_ids) return if FwPointersCfg.DISABLED not in all_symbol_pointers_cfgs: _cleanup_fw_pointers(collection, symbol, version_ids, versions_coll, shas_to_delete=shas_to_delete, do_clean=True) return _cleanup_mixed(symbol, collection, version_ids, versions_coll)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cleanup'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arctic_lib'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'version_ids'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'versions_coll'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'shas_to_delete'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'pointers_cfgs'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '27', '35', '42', '50', '57', '76', '98']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'pointers_cfgs'}; {'id': '18', 'type': 'conditional_expression', 'children': ['19', '23', '24'], 'value': 'if'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'pointers_cfgs'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pointers_cfgs'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'set'}; {'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': 'collection'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'arctic_lib'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'get_top_level_collection'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'version_ids'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'version_ids'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'all_symbol_pointers_cfgs'}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_get_symbol_pointer_cfgs'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'versions_coll'}; {'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': 'all_symbol_pointers_cfgs'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'pointers_cfgs'}; {'id': '57', 'type': 'if_statement', 'children': ['58', '67']}; {'id': '58', 'type': 'boolean_operator', 'children': ['59', '65'], 'value': 'or'}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '61'], 'value': '=='}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'all_symbol_pointers_cfgs'}; {'id': '61', 'type': 'set', 'children': ['62']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'FwPointersCfg'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'DISABLED'}; {'id': '65', 'type': 'not_operator', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'all_symbol_pointers_cfgs'}; {'id': '67', 'type': 'block', 'children': ['68', '75']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '_cleanup_parent_pointers'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73', '74']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'collection'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'version_ids'}; {'id': '75', 'type': 'return_statement', 'children': []}; {'id': '76', 'type': 'if_statement', 'children': ['77', '82']}; {'id': '77', 'type': 'comparison_operator', 'children': ['78', '81'], 'value': 'not in'}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'FwPointersCfg'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'DISABLED'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'all_symbol_pointers_cfgs'}; {'id': '82', 'type': 'block', 'children': ['83', '97']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': '_cleanup_fw_pointers'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '88', '89', '90', '91', '94']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'collection'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'version_ids'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'versions_coll'}; {'id': '91', 'type': 'keyword_argument', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'shas_to_delete'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'shas_to_delete'}; {'id': '94', 'type': 'keyword_argument', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'do_clean'}; {'id': '96', 'type': 'True', 'children': []}; {'id': '97', 'type': 'return_statement', 'children': []}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'call', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': '_cleanup_mixed'}; {'id': '101', 'type': 'argument_list', 'children': ['102', '103', '104', '105']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'collection'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'version_ids'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'versions_coll'}
Helper method for cleaning up chunks from a version store
def _check_trim(data): trim = data["algorithm"].get("trim_reads") if trim: if trim == "fastp" and data["algorithm"].get("align_split_size") is not False: raise ValueError("In sample %s, `trim_reads: fastp` currently requires `align_split_size: false`" % (dd.get_sample_name(data)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_trim'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'block', 'children': ['6', '17']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'trim'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'subscript', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '13', 'type': 'string', 'children': [], 'value': '"algorithm"'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': '"trim_reads"'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'trim'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'if_statement', 'children': ['21', '35']}; {'id': '21', 'type': 'boolean_operator', 'children': ['22', '25'], 'value': 'and'}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '24'], 'value': '=='}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'trim'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"fastp"'}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '34'], 'value': 'is not'}; {'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': 'data'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"algorithm"'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'string', 'children': [], 'value': '"align_split_size"'}; {'id': '34', 'type': 'False', 'children': []}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'raise_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '42'], 'value': '%'}; {'id': '41', 'type': 'string', 'children': [], 'value': '"In sample %s, `trim_reads: fastp` currently requires `align_split_size: false`"'}; {'id': '42', 'type': '()', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'dd'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'get_sample_name'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'data'}
Check for valid values for trim_reads.
def complete_media(self, text, line, begidx, endidx): choices = {'actor': query_actors, 'director': TabCompleteExample.static_list_directors, 'movie_file': (self.path_complete,) } completer = argparse_completer.AutoCompleter(TabCompleteExample.media_parser, self, arg_choices=choices) tokens, _ = self.tokens_for_completion(line, begidx, endidx) results = completer.complete_command(tokens, text, line, begidx, endidx) return results
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'complete_media'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'begidx'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'endidx'}; {'id': '9', 'type': 'block', 'children': ['10', '28', '43', '56', '69']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'choices'}; {'id': '13', 'type': 'dictionary', 'children': ['14', '17', '22']}; {'id': '14', 'type': 'pair', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'actor'"}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'query_actors'}; {'id': '17', 'type': 'pair', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'director'"}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'TabCompleteExample'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'static_list_directors'}; {'id': '22', 'type': 'pair', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'movie_file'"}; {'id': '24', 'type': 'tuple', 'children': ['25']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'path_complete'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'completer'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'argparse_completer'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'AutoCompleter'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '39', '40']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'TabCompleteExample'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'media_parser'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'arg_choices'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'choices'}; {'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': 'tokens'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_'}; {'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': 'tokens_for_completion'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54', '55']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'begidx'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'endidx'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'completer'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'complete_command'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65', '66', '67', '68']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'begidx'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'endidx'}; {'id': '69', 'type': 'return_statement', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'results'}
Adds tab completion to media
def _output_work(self, work, root): output_filename = os.path.join(self._output_dir, work) tree = etree.ElementTree(root) tree.write(output_filename, encoding='utf-8', pretty_print=True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_output_work'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'work'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '7', 'type': 'block', 'children': ['8', '22', '31']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'output_filename'}; {'id': '11', 'type': 'call', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_output_dir'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'work'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ElementTree'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'root'}; {'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': 'tree'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38', '41']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'output_filename'}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'pretty_print'}; {'id': '43', 'type': 'True', 'children': []}
Saves the TEI XML document `root` at the path `work`.
def schedule_ping_frequency(self): "Send a ping message to slack every 20 seconds" ping = crontab('* * * * * */20', func=self.send_ping, start=False) ping.start()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'schedule_ping_frequency'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '23']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': '"Send a ping message to slack every 20 seconds"'}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'ping'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'crontab'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15', '20']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'* * * * * */20'"}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'send_ping'}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '22', 'type': 'False', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ping'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '28', 'type': 'argument_list', 'children': []}
Send a ping message to slack every 20 seconds
def getDefaultItems(self): plugins = [ InspectorRegItem(DEFAULT_INSPECTOR, 'argos.inspector.qtplugins.table.TableInspector'), InspectorRegItem('Qt/Text', 'argos.inspector.qtplugins.text.TextInspector'), InspectorRegItem('PyQtGraph/1D Line Plot', 'argos.inspector.pgplugins.lineplot1d.PgLinePlot1d'), InspectorRegItem('PyQtGraph/2D Image Plot', 'argos.inspector.pgplugins.imageplot2d.PgImagePlot2d'), ] if DEBUGGING: plugins.append(InspectorRegItem('Debug Inspector', 'argos.inspector.debug.DebugInspector')) return plugins
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getDefaultItems'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '30', '44']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'plugins'}; {'id': '9', 'type': 'list', 'children': ['10', '15', '20', '25'], 'value': "[\n InspectorRegItem(DEFAULT_INSPECTOR,\n 'argos.inspector.qtplugins.table.TableInspector'),\n InspectorRegItem('Qt/Text',\n 'argos.inspector.qtplugins.text.TextInspector'),\n InspectorRegItem('PyQtGraph/1D Line Plot',\n 'argos.inspector.pgplugins.lineplot1d.PgLinePlot1d'),\n InspectorRegItem('PyQtGraph/2D Image Plot',\n 'argos.inspector.pgplugins.imageplot2d.PgImagePlot2d'),\n ]"}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'InspectorRegItem'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'DEFAULT_INSPECTOR'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'argos.inspector.qtplugins.table.TableInspector'"}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'InspectorRegItem'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'Qt/Text'"}; {'id': '19', 'type': 'string', 'children': [], 'value': "'argos.inspector.qtplugins.text.TextInspector'"}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'InspectorRegItem'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'PyQtGraph/1D Line Plot'"}; {'id': '24', 'type': 'string', 'children': [], 'value': "'argos.inspector.pgplugins.lineplot1d.PgLinePlot1d'"}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'InspectorRegItem'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'PyQtGraph/2D Image Plot'"}; {'id': '29', 'type': 'string', 'children': [], 'value': "'argos.inspector.pgplugins.imageplot2d.PgImagePlot2d'"}; {'id': '30', 'type': 'if_statement', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'DEBUGGING'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'plugins'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'InspectorRegItem'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'string', 'children': [], 'value': "'Debug Inspector'"}; {'id': '43', 'type': 'string', 'children': [], 'value': "'argos.inspector.debug.DebugInspector'"}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'plugins'}
Returns a list with the default plugins in the inspector registry.
def after_init_app(self, app: FlaskUnchained): from flask_wtf.csrf import generate_csrf @app.after_request def set_csrf_cookie(response): if response: response.set_cookie('csrf_token', generate_csrf()) return response
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'after_init_app'}; {'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': 'app'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'FlaskUnchained'}; {'id': '9', 'type': 'block', 'children': ['10', '16']}; {'id': '10', 'type': 'import_from_statement', 'children': ['11', '14']}; {'id': '11', 'type': 'dotted_name', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'flask_wtf'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'csrf'}; {'id': '14', 'type': 'dotted_name', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'generate_csrf'}; {'id': '16', 'type': 'decorated_definition', 'children': ['17', '21']}; {'id': '17', 'type': 'decorator', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'app'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'after_request'}; {'id': '21', 'type': 'function_definition', 'children': ['22', '23', '25']}; {'id': '22', 'type': 'function_name', 'children': [], 'value': 'set_csrf_cookie'}; {'id': '23', 'type': 'parameters', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '25', 'type': 'block', 'children': ['26', '39']}; {'id': '26', 'type': 'if_statement', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'response'}; {'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': 'response'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'set_cookie'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'csrf_token'"}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'generate_csrf'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'response'}
Configure an after request hook to set the ``csrf_token`` in the cookie.