code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def _get_object_as_soft(self): soft = ["^%s = %s" % (self.geotype, self.name), self._get_metadata_as_string(), self._get_columns_as_string(), self._get_table_as_string()] return "\n".join(soft)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_object_as_soft'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '34']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'soft'}; {'id': '9', 'type': 'list', 'children': ['10', '19', '24', '29'], 'value': '["^%s = %s" % (self.geotype, self.name),\n self._get_metadata_as_string(),\n self._get_columns_as_string(),\n self._get_table_as_string()]'}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '12'], 'value': '%'}; {'id': '11', 'type': 'string', 'children': [], 'value': '"^%s = %s"'}; {'id': '12', 'type': 'tuple', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'geotype'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_get_metadata_as_string'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_get_columns_as_string'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'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': '_get_table_as_string'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'soft'}
Get the object as SOFT formated string.
def _sort_column(self, column, reverse): if tk.DISABLED in self.state(): return l = [(self.set(child, column), child) for child in self.get_children('')] l.sort(reverse=reverse, key=lambda x: self._column_types[column](x[0])) for index, (val, child) in enumerate(l): self.move(child, "", index) self.heading(column, command=lambda: self._sort_column(column, not reverse))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sort_column'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '7', 'type': 'block', 'children': ['8', '20', '41', '65', '85']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '18']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '13'], 'value': 'in'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'tk'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'DISABLED'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '23', 'type': 'list_comprehension', 'children': ['24', '33']}; {'id': '24', 'type': 'tuple', 'children': ['25', '32']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '33', 'type': 'for_in_clause', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'get_children'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'string', 'children': [], 'value': "''"}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '50']}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '52', 'type': 'lambda', 'children': ['53', '55']}; {'id': '53', 'type': 'lambda_parameters', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '55', 'type': 'call', 'children': ['56', '61']}; {'id': '56', 'type': 'subscript', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': '_column_types'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '64', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '65', 'type': 'for_statement', 'children': ['66', '71', '75']}; {'id': '66', 'type': 'pattern_list', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '68', 'type': 'tuple_pattern', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '75', 'type': 'block', 'children': ['76']}; {'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': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'move'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '83', '84']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '83', 'type': 'string', 'children': [], 'value': '""'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'heading'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '92', 'type': 'keyword_argument', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '94', 'type': 'lambda', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': '_sort_column'}; {'id': '99', 'type': 'argument_list', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '101', 'type': 'not_operator', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'reverse'}
Sort a column by its values
def read_hdf5_timeseries(h5f, path=None, start=None, end=None, **kwargs): kwargs.setdefault('array_type', TimeSeries) series = read_hdf5_array(h5f, path=path, **kwargs) if start is not None or end is not None: return series.crop(start, end) return series
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_hdf5_timeseries'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'h5f'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'dictionary_splat_pattern', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '16', 'type': 'block', 'children': ['17', '25', '37', '54']}; {'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': 'kwargs'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'setdefault'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'array_type'"}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'TimeSeries'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'series'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'read_hdf5_array'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32', '35']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'h5f'}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '35', 'type': 'dictionary_splat', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '37', 'type': 'if_statement', 'children': ['38', '45']}; {'id': '38', 'type': 'boolean_operator', 'children': ['39', '42'], 'value': 'or'}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '41'], 'value': 'is not'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '41', 'type': 'None', 'children': []}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': 'is not'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '44', 'type': 'None', 'children': []}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'series'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'crop'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '54', 'type': 'return_statement', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'series'}
Read a `TimeSeries` from HDF5
def _fetchAllChildren(self): bands = self._bands if len(bands) != self._array.shape[-1]: logger.warn("No bands added, bands != last_dim_lenght ({} !: {})" .format(len(bands), self._array.shape[-1])) return [] childItems = [] for bandNr, band in enumerate(bands): bandItem = PillowBandRti(self._array[..., bandNr], nodeName=band, fileName=self.fileName, iconColor=self.iconColor, attributes=self._attributes) childItems.append(bandItem) return childItems
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_fetchAllChildren'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '52', '56', '102']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'bands'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_bands'}; {'id': '12', 'type': 'if_statement', 'children': ['13', '26']}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '18'], 'value': '!='}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'bands'}; {'id': '18', 'type': 'subscript', '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': '_array'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '24', 'type': 'unary_operator', 'children': ['25'], 'value': '-'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '26', 'type': 'block', 'children': ['27', '50']}; {'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': 'logger'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': '"No bands added, bands != last_dim_lenght ({} !: {})"'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '42']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'bands'}; {'id': '42', 'type': 'subscript', 'children': ['43', '48']}; {'id': '43', 'type': 'attribute', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_array'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '48', 'type': 'unary_operator', 'children': ['49'], 'value': '-'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'childItems'}; {'id': '55', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '56', 'type': 'for_statement', 'children': ['57', '60', '64']}; {'id': '57', 'type': 'pattern_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'bandNr'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'band'}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'bands'}; {'id': '64', 'type': 'block', 'children': ['65', '95']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'bandItem'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'PillowBandRti'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '77', '80', '85', '90']}; {'id': '71', 'type': 'subscript', 'children': ['72', '75', '76']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': '_array'}; {'id': '75', 'type': 'ellipsis', 'children': [], 'value': '...'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'bandNr'}; {'id': '77', 'type': 'keyword_argument', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'nodeName'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'band'}; {'id': '80', 'type': 'keyword_argument', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'fileName'}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'fileName'}; {'id': '85', 'type': 'keyword_argument', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'iconColor'}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'iconColor'}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': '_attributes'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'childItems'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '100', 'type': 'argument_list', 'children': ['101']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'bandItem'}; {'id': '102', 'type': 'return_statement', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'childItems'}
Adds the bands as separate fields so they can be inspected easily.
def check_git_unchanged(filename, yes=False): if check_staged(filename): s = 'There are staged changes in {}, overwrite? [y/n] '.format(filename) if yes or input(s) in ('y', 'yes'): return else: raise RuntimeError('There are staged changes in ' '{}, aborting.'.format(filename)) if check_unstaged(filename): s = 'There are unstaged changes in {}, overwrite? [y/n] '.format(filename) if yes or input(s) in ('y', 'yes'): return else: raise RuntimeError('There are unstaged changes in ' '{}, aborting.'.format(filename))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_git_unchanged'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'yes'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '51']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '14']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'check_staged'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '14', 'type': 'block', 'children': ['15', '24']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'There are staged changes in {}, overwrite? [y/n] '"}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '35', '37']}; {'id': '25', 'type': 'boolean_operator', 'children': ['26', '27'], 'value': 'or'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'yes'}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '32'], 'value': 'in'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'input'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '32', 'type': 'tuple', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'y'"}; {'id': '34', 'type': 'string', 'children': [], 'value': "'yes'"}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'return_statement', 'children': []}; {'id': '37', 'type': 'else_clause', 'children': ['38']}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'raise_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'RuntimeError'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'concatenated_string', 'children': ['46', '47']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'There are staged changes in '"}; {'id': '47', 'type': 'string', 'children': [], 'value': "'{}, aborting.'"}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '51', 'type': 'if_statement', 'children': ['52', '56']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'check_unstaged'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'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': 's'}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'There are unstaged changes in {}, overwrite? [y/n] '"}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '66', 'type': 'if_statement', 'children': ['67', '77', '79']}; {'id': '67', 'type': 'boolean_operator', 'children': ['68', '69'], 'value': 'or'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'yes'}; {'id': '69', 'type': 'comparison_operator', 'children': ['70', '74'], 'value': 'in'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'input'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '74', 'type': 'tuple', 'children': ['75', '76']}; {'id': '75', 'type': 'string', 'children': [], 'value': "'y'"}; {'id': '76', 'type': 'string', 'children': [], 'value': "'yes'"}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'return_statement', 'children': []}; {'id': '79', 'type': 'else_clause', 'children': ['80']}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'raise_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'RuntimeError'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '91']}; {'id': '86', 'type': 'attribute', 'children': ['87', '90']}; {'id': '87', 'type': 'concatenated_string', 'children': ['88', '89']}; {'id': '88', 'type': 'string', 'children': [], 'value': "'There are unstaged changes in '"}; {'id': '89', 'type': 'string', 'children': [], 'value': "'{}, aborting.'"}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'filename'}
Check git to avoid overwriting user changes.
def to_string(self, hdr, other): result = "%s[%s,%s" % ( hdr, self.get_type(self.type), self.get_clazz(self.clazz)) if self.unique: result += "-unique," else: result += "," result += self.name if other is not None: result += ",%s]" % (other) else: result += "]" return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_string'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'hdr'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '7', 'type': 'block', 'children': ['8', '31', '46', '52', '70']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '11', 'type': 'binary_operator', 'children': ['12', '13'], 'value': '%'}; {'id': '12', 'type': 'string', 'children': [], 'value': '"%s[%s,%s"'}; {'id': '13', 'type': 'tuple', 'children': ['14', '15', '23']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'hdr'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get_type'}; {'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': 'type'}; {'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_clazz'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'clazz'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '35', '40']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'unique'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'augmented_assignment', 'children': ['38', '39'], 'value': '+='}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '39', 'type': 'string', 'children': [], 'value': '"-unique,"'}; {'id': '40', 'type': 'else_clause', 'children': ['41']}; {'id': '41', 'type': 'block', 'children': ['42']}; {'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': 'string', 'children': [], 'value': '","'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'augmented_assignment', 'children': ['48', '49'], 'value': '+='}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '52', 'type': 'if_statement', 'children': ['53', '56', '64']}; {'id': '53', 'type': 'comparison_operator', 'children': ['54', '55'], 'value': 'is not'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '55', 'type': 'None', 'children': []}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'augmented_assignment', 'children': ['59', '60'], 'value': '+='}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '62'], 'value': '%'}; {'id': '61', 'type': 'string', 'children': [], 'value': '",%s]"'}; {'id': '62', 'type': '()', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '64', 'type': 'else_clause', 'children': ['65']}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'augmented_assignment', 'children': ['68', '69'], 'value': '+='}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '69', 'type': 'string', 'children': [], 'value': '"]"'}; {'id': '70', 'type': 'return_statement', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'result'}
String representation with additional information
def scroll_down (self): s = self.scroll_row_start - 1 e = self.scroll_row_end - 1 self.w[s+1:e+1] = copy.deepcopy(self.w[s:e])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scroll_down'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '22']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '9', 'type': 'binary_operator', 'children': ['10', '13'], 'value': '-'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'scroll_row_start'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '21'], 'value': '-'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'scroll_row_end'}; {'id': '21', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '36']}; {'id': '24', 'type': 'subscript', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '28', 'type': 'slice', 'children': ['29', '32', '33']}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '31'], 'value': '+'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '32', 'type': 'colon', 'children': []}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '35'], 'value': '+'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'deepcopy'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'subscript', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '45', 'type': 'slice', 'children': ['46', '47', '48']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '47', 'type': 'colon', 'children': []}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'e'}
Scroll display down one line.
def _assert_keys_match(keys1, keys2): if set(keys1) != set(keys2): raise ValueError('{} {}'.format(list(keys1), list(keys2)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_assert_keys_match'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'keys1'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'keys2'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '17']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '13'], 'value': '!='}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'keys1'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'keys2'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'raise_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'{} {}'"}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '31']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'keys1'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'keys2'}
Ensure the two list of keys matches.
def new(self, filename=None): path = (self.exec_path,) if self.exec_path.filetype() in ('py', 'pyw', 'pyz', self.FTYPE): p = find_executable("python") path = (p, 'python') + path else: path += (self.exec_path,) if filename: path += ('-o', filename) os.spawnl(os.P_NOWAIT, *path)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'new'}; {'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': 'filename'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '16', '57', '66']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '12', 'type': 'tuple', 'children': ['13']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'exec_path'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '32', '48']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '25'], 'value': 'in'}; {'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': 'exec_path'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'filetype'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'tuple', 'children': ['26', '27', '28', '29']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'py'"}; {'id': '27', 'type': 'string', 'children': [], 'value': "'pyw'"}; {'id': '28', 'type': 'string', 'children': [], 'value': "'pyz'"}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'FTYPE'}; {'id': '32', 'type': 'block', 'children': ['33', '40']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'find_executable'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"python"'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '47'], 'value': '+'}; {'id': '44', 'type': 'tuple', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'python'"}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '48', 'type': 'else_clause', 'children': ['49']}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'augmented_assignment', 'children': ['52', '53'], 'value': '+='}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '53', 'type': 'tuple', 'children': ['54']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'exec_path'}; {'id': '57', 'type': 'if_statement', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'augmented_assignment', 'children': ['62', '63'], 'value': '+='}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '63', 'type': 'tuple', 'children': ['64', '65']}; {'id': '64', 'type': 'string', 'children': [], 'value': "'-o'"}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'spawnl'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'P_NOWAIT'}; {'id': '75', 'type': 'list_splat', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'path'}
start a session an independent process
def _add_properties(self, **kwargs): for k,v in kwargs.items(): if k=='parallax': self.obs.add_parallax(v) elif k in ['Teff', 'logg', 'feh', 'density']: par = {k:v} self.obs.add_spectroscopy(**par) elif re.search('_', k): m = re.search('^(\w+)_(\w+)$', k) prop = m.group(1) tag = m.group(2) self.obs.add_spectroscopy(**{prop:v, 'label':'0_{}'.format(tag)})
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_properties'}; {'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': 'for_statement', 'children': ['9', '12', '17']}; {'id': '9', 'type': 'pattern_list', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'if_statement', 'children': ['19', '22', '32', '58']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': '=='}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'parallax'"}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'obs'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'add_parallax'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '32', 'type': 'elif_clause', 'children': ['33', '40']}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '35'], 'value': 'in'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '35', 'type': 'list', 'children': ['36', '37', '38', '39'], 'value': "['Teff', 'logg', 'feh', 'density']"}; {'id': '36', 'type': 'string', 'children': [], 'value': "'Teff'"}; {'id': '37', 'type': 'string', 'children': [], 'value': "'logg'"}; {'id': '38', 'type': 'string', 'children': [], 'value': "'feh'"}; {'id': '39', 'type': 'string', 'children': [], 'value': "'density'"}; {'id': '40', 'type': 'block', 'children': ['41', '48']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'par'}; {'id': '44', 'type': 'dictionary', 'children': ['45']}; {'id': '45', 'type': 'pair', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'obs'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'add_spectroscopy'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'dictionary_splat', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'par'}; {'id': '58', 'type': 'elif_clause', 'children': ['59', '66']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65']}; {'id': '64', 'type': 'string', 'children': [], 'value': "'_'"}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '66', 'type': 'block', 'children': ['67', '77', '86', '95']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '76']}; {'id': '75', 'type': 'string', 'children': [], 'value': "'^(\\w+)_(\\w+)$'"}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'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': 'obs'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'add_spectroscopy'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'dictionary_splat', 'children': ['104']}; {'id': '104', 'type': 'dictionary', 'children': ['105', '108']}; {'id': '105', 'type': 'pair', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '108', 'type': 'pair', 'children': ['109', '110']}; {'id': '109', 'type': 'string', 'children': [], 'value': "'label'"}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'string', 'children': [], 'value': "'0_{}'"}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'tag'}
Adds non-photometry properties to ObservationTree
def add_target_and_index(self, name, sig, signode): targetname = '%s-%s' % (self.objtype, name) if targetname not in self.state.document.ids: signode['names'].append(targetname) signode['ids'].append(targetname) signode['first'] = (not self.names) self.state.document.note_explicit_target(signode) objects = self.env.domaindata['everett']['objects'] key = (self.objtype, name) if key in objects: self.state_machine.reporter.warning( 'duplicate description of %s %s, ' % (self.objtype, name) + 'other instance in ' + self.env.doc2path(objects[key]), line=self.lineno ) objects[key] = self.env.docname indextext = _('%s (component)') % name self.indexnode['entries'].append(('single', indextext, targetname, '', None))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_target_and_index'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'sig'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'signode'}; {'id': '8', 'type': 'block', 'children': ['9', '19', '139', '148']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'targetname'}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '14'], 'value': '%'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'%s-%s'"}; {'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': 'objtype'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '29']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': 'not in'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'targetname'}; {'id': '22', 'type': 'attribute', 'children': ['23', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'document'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ids'}; {'id': '29', 'type': 'block', 'children': ['30', '39', '48', '58', '69', '81', '89', '129']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'signode'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'names'"}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'targetname'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '46']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'signode'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'ids'"}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'targetname'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '53']}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'signode'}; {'id': '52', 'type': 'string', 'children': [], 'value': "'first'"}; {'id': '53', 'type': '()', 'children': ['54']}; {'id': '54', 'type': 'not_operator', 'children': ['55']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '67']}; {'id': '60', 'type': 'attribute', 'children': ['61', '66']}; {'id': '61', 'type': 'attribute', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'document'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'note_explicit_target'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'signode'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '72', 'type': 'subscript', 'children': ['73', '80']}; {'id': '73', 'type': 'subscript', 'children': ['74', '79']}; {'id': '74', 'type': 'attribute', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'domaindata'}; {'id': '79', 'type': 'string', 'children': [], 'value': "'everett'"}; {'id': '80', 'type': 'string', 'children': [], 'value': "'objects'"}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '84', 'type': 'tuple', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'objtype'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '89', 'type': 'if_statement', 'children': ['90', '93']}; {'id': '90', 'type': 'comparison_operator', 'children': ['91', '92'], 'value': 'in'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '103']}; {'id': '96', 'type': 'attribute', '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': 'state_machine'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'reporter'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '103', 'type': 'argument_list', 'children': ['104', '124']}; {'id': '104', 'type': 'binary_operator', 'children': ['105', '114'], 'value': '+'}; {'id': '105', 'type': 'binary_operator', 'children': ['106', '113'], 'value': '+'}; {'id': '106', 'type': 'binary_operator', 'children': ['107', '108'], 'value': '%'}; {'id': '107', 'type': 'string', 'children': [], 'value': "'duplicate description of %s %s, '"}; {'id': '108', 'type': 'tuple', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'objtype'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '113', 'type': 'string', 'children': [], 'value': "'other instance in '"}; {'id': '114', 'type': 'call', 'children': ['115', '120']}; {'id': '115', 'type': 'attribute', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'doc2path'}; {'id': '120', 'type': 'argument_list', 'children': ['121']}; {'id': '121', 'type': 'subscript', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '124', 'type': 'keyword_argument', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'lineno'}; {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'assignment', 'children': ['131', '134']}; {'id': '131', 'type': 'subscript', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '134', 'type': 'attribute', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'docname'}; {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'assignment', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'indextext'}; {'id': '142', 'type': 'binary_operator', 'children': ['143', '147'], 'value': '%'}; {'id': '143', 'type': 'call', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': 'string', 'children': [], 'value': "'%s (component)'"}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '148', 'type': 'expression_statement', 'children': ['149']}; {'id': '149', 'type': 'call', 'children': ['150', '157']}; {'id': '150', 'type': 'attribute', 'children': ['151', '156']}; {'id': '151', 'type': 'subscript', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'indexnode'}; {'id': '155', 'type': 'string', 'children': [], 'value': "'entries'"}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '157', 'type': 'argument_list', 'children': ['158']}; {'id': '158', 'type': 'tuple', 'children': ['159', '160', '161', '162', '163']}; {'id': '159', 'type': 'string', 'children': [], 'value': "'single'"}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'indextext'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'targetname'}; {'id': '162', 'type': 'string', 'children': [], 'value': "''"}; {'id': '163', 'type': 'None', 'children': []}
Add a target and index for this thing.
def validate_vars(env): if 'PCH' in env and env['PCH']: if 'PCHSTOP' not in env: raise SCons.Errors.UserError("The PCHSTOP construction must be defined if PCH is defined.") if not SCons.Util.is_String(env['PCHSTOP']): raise SCons.Errors.UserError("The PCHSTOP construction variable must be a string: %r"%env['PCHSTOP'])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_vars'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '14']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '11'], 'value': 'and'}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'in'}; {'id': '9', 'type': 'string', 'children': [], 'value': "'PCH'"}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '11', 'type': 'subscript', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'PCH'"}; {'id': '14', 'type': 'block', 'children': ['15', '29']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '19']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': 'not in'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'PCHSTOP'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'raise_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'Errors'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'UserError'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"The PCHSTOP construction must be defined if PCH is defined."'}; {'id': '29', 'type': 'if_statement', 'children': ['30', '41']}; {'id': '30', 'type': 'not_operator', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'is_String'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'PCHSTOP'"}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'raise_statement', 'children': ['43']}; {'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': 'SCons'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'Errors'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'UserError'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '52'], 'value': '%'}; {'id': '51', 'type': 'string', 'children': [], 'value': '"The PCHSTOP construction variable must be a string: %r"'}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '54', 'type': 'string', 'children': [], 'value': "'PCHSTOP'"}
Validate the PCH and PCHSTOP construction variables.
def _make_qheader(self, job_name, qout_path, qerr_path): subs_dict = self.get_subs_dict() subs_dict['job_name'] = job_name.replace('/', '_') subs_dict['_qout_path'] = qout_path subs_dict['_qerr_path'] = qerr_path qtemplate = QScriptTemplate(self.QTEMPLATE) unclean_template = qtemplate.safe_substitute(subs_dict) clean_template = [] for line in unclean_template.split('\n'): if '$$' not in line: clean_template.append(line) return '\n'.join(clean_template)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_make_qheader'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'job_name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'qout_path'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'qerr_path'}; {'id': '8', 'type': 'block', 'children': ['9', '17', '29', '35', '41', '50', '59', '63', '84']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'subs_dict'}; {'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': 'get_subs_dict'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '22']}; {'id': '19', 'type': 'subscript', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'subs_dict'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'job_name'"}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'job_name'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '28', 'type': 'string', 'children': [], 'value': "'_'"}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '34']}; {'id': '31', 'type': 'subscript', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'subs_dict'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'_qout_path'"}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'qout_path'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '40']}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'subs_dict'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'_qerr_path'"}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'qerr_path'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'qtemplate'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'QScriptTemplate'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'QTEMPLATE'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'unclean_template'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'qtemplate'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'safe_substitute'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'subs_dict'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'clean_template'}; {'id': '62', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '63', 'type': 'for_statement', 'children': ['64', '65', '71']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'unclean_template'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'if_statement', 'children': ['73', '76']}; {'id': '73', 'type': 'comparison_operator', 'children': ['74', '75'], 'value': 'not in'}; {'id': '74', 'type': 'string', 'children': [], 'value': "'$$'"}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'clean_template'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '84', 'type': 'return_statement', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'clean_template'}
Return a string with the options that are passed to the resource manager.
def power_up(self): for m in self.motors: m.compliant = False m.moving_speed = 0 m.torque_limit = 100.0
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'power_up'}; {'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', '11']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'motors'}; {'id': '11', 'type': 'block', 'children': ['12', '18', '24']}; {'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': 'm'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'compliant'}; {'id': '17', 'type': 'False', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'moving_speed'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'torque_limit'}; {'id': '29', 'type': 'float', 'children': [], 'value': '100.0'}
Changes all settings to guarantee the motors will be used at their maximum power.
def _uint2objs(ftype, num, length=None): if num == 0: objs = [ftype.box(0)] else: _num = num objs = list() while _num != 0: objs.append(ftype.box(_num & 1)) _num >>= 1 if length: if length < len(objs): fstr = "overflow: num = {} requires length >= {}, got length = {}" raise ValueError(fstr.format(num, len(objs), length)) else: while len(objs) < length: objs.append(ftype.box(0)) return objs
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_uint2objs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ftype'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'num'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '60', '112']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '14', '25']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': '=='}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'num'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'objs'}; {'id': '18', 'type': 'list', 'children': ['19'], 'value': '[ftype.box(0)]'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ftype'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'box'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '25', 'type': 'else_clause', 'children': ['26']}; {'id': '26', 'type': 'block', 'children': ['27', '31', '37']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_num'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'num'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'objs'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '36', 'type': 'argument_list', 'children': []}; {'id': '37', 'type': 'while_statement', 'children': ['38', '41']}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '40'], 'value': '!='}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_num'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '41', 'type': 'block', 'children': ['42', '56']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'objs'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'ftype'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'box'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '55'], 'value': '&'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_num'}; {'id': '55', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'augmented_assignment', 'children': ['58', '59'], 'value': '>>='}; {'id': '58', 'type': 'identifier', 'children': [], 'value': '_num'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '60', 'type': 'if_statement', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'if_statement', 'children': ['64', '70', '90']}; {'id': '64', 'type': 'comparison_operator', 'children': ['65', '66'], 'value': '<'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'objs'}; {'id': '70', 'type': 'block', 'children': ['71', '75']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'fstr'}; {'id': '74', 'type': 'string', 'children': [], 'value': '"overflow: num = {} requires length >= {}, got length = {}"'}; {'id': '75', 'type': 'raise_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'fstr'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '83', 'type': 'argument_list', 'children': ['84', '85', '89']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'num'}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'objs'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '90', 'type': 'else_clause', 'children': ['91']}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'while_statement', 'children': ['93', '99']}; {'id': '93', 'type': 'comparison_operator', 'children': ['94', '98'], 'value': '<'}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'objs'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'objs'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'call', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'ftype'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'box'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '112', 'type': 'return_statement', 'children': ['113']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'objs'}
Convert an unsigned integer to a list of constant expressions.
def _client_connection(self, conn, addr): log.debug('Established connection with %s:%d', addr[0], addr[1]) conn.settimeout(self.socket_timeout) try: while self.__up: msg = conn.recv(self.buffer_size) if not msg: continue log.debug('[%s] Received %s from %s. Adding in the queue', time.time(), msg, addr) self.buffer.put((msg, '{}:{}'.format(addr[0], addr[1]))) except socket.timeout: if not self.__up: return log.debug('Connection %s:%d timed out', addr[1], addr[0]) raise ListenerException('Connection %s:%d timed out' % addr) finally: log.debug('Closing connection with %s', addr) conn.close()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_client_connection'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '7', 'type': 'block', 'children': ['8', '21', '30']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15', '18']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'Established connection with %s:%d'"}; {'id': '15', 'type': 'subscript', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '1'}; {'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': 'conn'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'settimeout'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'socket_timeout'}; {'id': '30', 'type': 'try_statement', 'children': ['31', '88', '120']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'while_statement', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '__up'}; {'id': '36', 'type': 'block', 'children': ['37', '48', '53', '67']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'recv'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'buffer_size'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '51']}; {'id': '49', 'type': 'not_operator', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'continue_statement', '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': 'log'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60', '65', '66']}; {'id': '59', 'type': 'string', 'children': [], 'value': "'[%s] Received %s from %s. Adding in the queue'"}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '64', 'type': 'argument_list', 'children': []}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'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': 'buffer'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'put'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'tuple', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'string', 'children': [], 'value': "'{}:{}'"}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '85']}; {'id': '82', 'type': 'subscript', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '85', 'type': 'subscript', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '87', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '88', 'type': 'except_clause', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '92', 'type': 'block', 'children': ['93', '100', '113']}; {'id': '93', 'type': 'if_statement', 'children': ['94', '98']}; {'id': '94', 'type': 'not_operator', 'children': ['95']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': '__up'}; {'id': '98', 'type': 'block', 'children': ['99']}; {'id': '99', 'type': 'return_statement', 'children': []}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '105', 'type': 'argument_list', 'children': ['106', '107', '110']}; {'id': '106', 'type': 'string', 'children': [], 'value': "'Connection %s:%d timed out'"}; {'id': '107', 'type': 'subscript', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '109', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '110', 'type': 'subscript', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '112', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '113', 'type': 'raise_statement', 'children': ['114']}; {'id': '114', 'type': 'call', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'ListenerException'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}; {'id': '117', 'type': 'binary_operator', 'children': ['118', '119'], 'value': '%'}; {'id': '118', 'type': 'string', 'children': [], 'value': "'Connection %s:%d timed out'"}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '120', 'type': 'finally_clause', 'children': ['121']}; {'id': '121', 'type': 'block', 'children': ['122', '130']}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'call', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '127', 'type': 'argument_list', 'children': ['128', '129']}; {'id': '128', 'type': 'string', 'children': [], 'value': "'Closing connection with %s'"}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '135', 'type': 'argument_list', 'children': []}
Handle the connecition with one client.
def format_coord(self, x, y): p, b = stereonet_math.geographic2plunge_bearing(x, y) s, d = stereonet_math.geographic2pole(x, y) pb = u'P/B={:0.0f}\u00b0/{:03.0f}\u00b0'.format(p[0], b[0]) sd = u'S/D={:03.0f}\u00b0/{:0.0f}\u00b0'.format(s[0], d[0]) return u'{}, {}'.format(pb, sd)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_coord'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '7', 'type': 'block', 'children': ['8', '20', '32', '46', '60']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '13']}; {'id': '10', 'type': 'pattern_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'stereonet_math'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'geographic2plunge_bearing'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '25']}; {'id': '22', 'type': 'pattern_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'stereonet_math'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'geographic2pole'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'pb'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': "u'P/B={:0.0f}\\u00b0/{:03.0f}\\u00b0'"}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '43']}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'sd'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': "u'S/D={:03.0f}\\u00b0/{:0.0f}\\u00b0'"}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '57']}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'string', 'children': [], 'value': "u'{}, {}'"}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'pb'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'sd'}
Format displayed coordinates during mouseover of axes.
def _get_bus_array_construct(self): bus_no = integer.setResultsName("bus_no") v_base = real.setResultsName("v_base") v_magnitude = Optional(real).setResultsName("v_magnitude") v_angle = Optional(real).setResultsName("v_angle") area = Optional(integer).setResultsName("area") region = Optional(integer).setResultsName("region") bus_data = bus_no + v_base + v_magnitude + v_angle + \ area + region + scolon bus_data.setParseAction(self.push_bus) bus_array = Literal("Bus.con") + "=" + "[" + "..." + \ ZeroOrMore(bus_data + Optional("]" + scolon)) bus_array.setParseAction(self.sort_buses) return bus_array
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_bus_array_construct'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '24', '36', '48', '60', '72', '89', '98', '124', '133']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'bus_no'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'integer'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'setResultsName'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"bus_no"'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'v_base'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'real'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'setResultsName'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'string', 'children': [], 'value': '"v_base"'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'v_magnitude'}; {'id': '27', 'type': 'call', 'children': ['28', '34']}; {'id': '28', 'type': 'attribute', 'children': ['29', '33']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'Optional'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'real'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'setResultsName'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'string', 'children': [], 'value': '"v_magnitude"'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'v_angle'}; {'id': '39', 'type': 'call', 'children': ['40', '46']}; {'id': '40', 'type': 'attribute', 'children': ['41', '45']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'Optional'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'real'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'setResultsName'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'string', 'children': [], 'value': '"v_angle"'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'area'}; {'id': '51', 'type': 'call', 'children': ['52', '58']}; {'id': '52', 'type': 'attribute', 'children': ['53', '57']}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'Optional'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'integer'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'setResultsName'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'string', 'children': [], 'value': '"area"'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '63', 'type': 'call', 'children': ['64', '70']}; {'id': '64', 'type': 'attribute', 'children': ['65', '69']}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'Optional'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'integer'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'setResultsName'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'string', 'children': [], 'value': '"region"'}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'bus_data'}; {'id': '75', 'type': 'binary_operator', 'children': ['76', '88'], 'value': '+'}; {'id': '76', 'type': 'binary_operator', 'children': ['77', '87'], 'value': '+'}; {'id': '77', 'type': 'binary_operator', 'children': ['78', '85', '86'], 'value': '+'}; {'id': '78', 'type': 'binary_operator', 'children': ['79', '84'], 'value': '+'}; {'id': '79', 'type': 'binary_operator', 'children': ['80', '83'], 'value': '+'}; {'id': '80', 'type': 'binary_operator', 'children': ['81', '82'], 'value': '+'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'bus_no'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'v_base'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'v_magnitude'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'v_angle'}; {'id': '85', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'area'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'scolon'}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'bus_data'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'setParseAction'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'push_bus'}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'bus_array'}; {'id': '101', 'type': 'binary_operator', 'children': ['102', '112', '113'], 'value': '+'}; {'id': '102', 'type': 'binary_operator', 'children': ['103', '111'], 'value': '+'}; {'id': '103', 'type': 'binary_operator', 'children': ['104', '110'], 'value': '+'}; {'id': '104', 'type': 'binary_operator', 'children': ['105', '109'], 'value': '+'}; {'id': '105', 'type': 'call', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'Literal'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'string', 'children': [], 'value': '"Bus.con"'}; {'id': '109', 'type': 'string', 'children': [], 'value': '"="'}; {'id': '110', 'type': 'string', 'children': [], 'value': '"["'}; {'id': '111', 'type': 'string', 'children': [], 'value': '"..."'}; {'id': '112', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '113', 'type': 'call', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'ZeroOrMore'}; {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'binary_operator', 'children': ['117', '118'], 'value': '+'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'bus_data'}; {'id': '118', 'type': 'call', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'Optional'}; {'id': '120', 'type': 'argument_list', 'children': ['121']}; {'id': '121', 'type': 'binary_operator', 'children': ['122', '123'], 'value': '+'}; {'id': '122', 'type': 'string', 'children': [], 'value': '"]"'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'scolon'}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'bus_array'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'setParseAction'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'sort_buses'}; {'id': '133', 'type': 'return_statement', 'children': ['134']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'bus_array'}
Returns a construct for an array of bus data.
def _connect_lxd(spec): return { 'method': 'lxd', 'kwargs': { 'container': spec.remote_addr(), 'python_path': spec.python_path(), 'lxc_path': spec.mitogen_lxc_path(), 'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(), 'remote_name': get_remote_name(spec), } }
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_connect_lxd'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'dictionary', 'children': ['8', '11']}; {'id': '8', 'type': 'pair', 'children': ['9', '10']}; {'id': '9', 'type': 'string', 'children': [], 'value': "'method'"}; {'id': '10', 'type': 'string', 'children': [], 'value': "'lxd'"}; {'id': '11', 'type': 'pair', 'children': ['12', '13']}; {'id': '12', 'type': 'string', 'children': [], 'value': "'kwargs'"}; {'id': '13', 'type': 'dictionary', 'children': ['14', '21', '28', '35', '48']}; {'id': '14', 'type': 'pair', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'container'"}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'remote_addr'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'pair', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'python_path'"}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'python_path'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'pair', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'lxc_path'"}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'mitogen_lxc_path'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'pair', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'connect_timeout'"}; {'id': '37', 'type': 'boolean_operator', 'children': ['38', '43'], 'value': 'or'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'ansible_ssh_timeout'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '47', 'type': 'argument_list', 'children': []}; {'id': '48', 'type': 'pair', 'children': ['49', '50']}; {'id': '49', 'type': 'string', 'children': [], 'value': "'remote_name'"}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'get_remote_name'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'spec'}
Return ContextService arguments for an LXD container connection.
async def send_webmention(self, entry, url): if (entry.url, url) in self._processed_mentions: LOGGER.debug( "Skipping already processed mention %s -> %s", entry.url, url) self._processed_mentions.add((entry.url, url)) LOGGER.debug("++WAIT: webmentions.get_target %s", url) target = await webmentions.get_target(self, url) LOGGER.debug("++DONE: webmentions.get_target %s", url) if target: LOGGER.debug("++WAIT: Sending webmention %s -> %s", entry.url, url) await target.send(self, entry) LOGGER.debug("++DONE: Sending webmention %s -> %s", entry.url, url)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_webmention'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '7', 'type': 'block', 'children': ['8', '30', '43', '51', '62', '70']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '18']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '15'], 'value': 'in'}; {'id': '10', 'type': 'tuple', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_processed_mentions'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'LOGGER'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26', '29']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"Skipping already processed mention %s -> %s"'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_processed_mentions'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'tuple', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'LOGGER'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50']}; {'id': '49', 'type': 'string', 'children': [], 'value': '"++WAIT: webmentions.get_target %s"'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '54', 'type': 'await', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'webmentions'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'get_target'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'LOGGER'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69']}; {'id': '68', 'type': 'string', 'children': [], 'value': '"++DONE: webmentions.get_target %s"'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '70', 'type': 'if_statement', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '72', 'type': 'block', 'children': ['73', '84', '93']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'LOGGER'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80', '83']}; {'id': '79', 'type': 'string', 'children': [], 'value': '"++WAIT: Sending webmention %s -> %s"'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'await', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'LOGGER'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100', '103']}; {'id': '99', 'type': 'string', 'children': [], 'value': '"++DONE: Sending webmention %s -> %s"'}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'url'}
send a webmention from an entry to a URL
def parse_option(self, option, block_name, message): if option == 'show': option = 'start_' + option key = option.split('_', 1)[0] self.messages[key] = message
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_option'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'block_name'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '8', 'type': 'block', 'children': ['9', '20', '32']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': '=='}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'show'"}; {'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': 'option'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '19'], 'value': '+'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'start_'"}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '23', 'type': 'subscript', 'children': ['24', '31']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'_'"}; {'id': '30', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '39']}; {'id': '34', 'type': 'subscript', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'messages'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'message'}
Parse show, end_show, and timer_show options.
def run_work(self): if os.path.exists(LOCAL_EVAL_ROOT_DIR): sudo_remove_dirtree(LOCAL_EVAL_ROOT_DIR) self.run_attacks() self.run_defenses()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_work'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '21', '27']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '15']}; {'id': '7', 'type': 'call', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'LOCAL_EVAL_ROOT_DIR'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'sudo_remove_dirtree'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'LOCAL_EVAL_ROOT_DIR'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'run_attacks'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'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': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'run_defenses'}; {'id': '32', 'type': 'argument_list', 'children': []}
Run attacks and defenses
def unindent(self): _logger().debug('unindent') cursor = self.editor.textCursor() _logger().debug('cursor has selection %r', cursor.hasSelection()) if cursor.hasSelection(): cursor.beginEditBlock() self.unindent_selection(cursor) cursor.endEditBlock() self.editor.setTextCursor(cursor) else: tab_len = self.editor.tab_length indentation = cursor.positionInBlock() indentation -= self.min_column if indentation == 0: return max_spaces = indentation % tab_len if max_spaces == 0: max_spaces = tab_len spaces = self.count_deletable_spaces(cursor, max_spaces) _logger().info('deleting %d space before cursor' % spaces) cursor.beginEditBlock() for _ in range(spaces): cursor.deletePreviousChar() cursor.endEditBlock() self.editor.setTextCursor(cursor) _logger().debug(cursor.block().text())
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unindent'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '25', '39']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'unindent'"}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'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': 'editor'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'textCursor'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'cursor has selection %r'"}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'hasSelection'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'if_statement', 'children': ['40', '45', '74']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'hasSelection'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'block', 'children': ['46', '52', '59', '65']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'beginEditBlock'}; {'id': '51', 'type': 'argument_list', 'children': []}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'unindent_selection'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'endEditBlock'}; {'id': '64', 'type': 'argument_list', 'children': []}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '72']}; {'id': '67', 'type': 'attribute', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'editor'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'setTextCursor'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '74', 'type': 'else_clause', 'children': ['75']}; {'id': '75', 'type': 'block', 'children': ['76', '84', '92', '98', '104', '110', '119', '129', '140', '146', '159', '165', '174']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'tab_len'}; {'id': '79', 'type': 'attribute', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'editor'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'tab_length'}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'indentation'}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'positionInBlock'}; {'id': '91', 'type': 'argument_list', 'children': []}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'augmented_assignment', 'children': ['94', '95'], 'value': '-='}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'indentation'}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'min_column'}; {'id': '98', 'type': 'if_statement', 'children': ['99', '102']}; {'id': '99', 'type': 'comparison_operator', 'children': ['100', '101'], 'value': '=='}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'indentation'}; {'id': '101', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '102', 'type': 'block', 'children': ['103']}; {'id': '103', 'type': 'return_statement', 'children': []}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'assignment', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'max_spaces'}; {'id': '107', 'type': 'binary_operator', 'children': ['108', '109'], 'value': '%'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'indentation'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'tab_len'}; {'id': '110', 'type': 'if_statement', 'children': ['111', '114']}; {'id': '111', 'type': 'comparison_operator', 'children': ['112', '113'], 'value': '=='}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'max_spaces'}; {'id': '113', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '114', 'type': 'block', 'children': ['115']}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'assignment', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'max_spaces'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'tab_len'}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'assignment', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'spaces'}; {'id': '122', 'type': 'call', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'count_deletable_spaces'}; {'id': '126', 'type': 'argument_list', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'max_spaces'}; {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'call', 'children': ['131', '136']}; {'id': '131', 'type': 'attribute', 'children': ['132', '135']}; {'id': '132', 'type': 'call', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '134', 'type': 'argument_list', 'children': []}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}; {'id': '137', 'type': 'binary_operator', 'children': ['138', '139'], 'value': '%'}; {'id': '138', 'type': 'string', 'children': [], 'value': "'deleting %d space before cursor'"}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'spaces'}; {'id': '140', 'type': 'expression_statement', 'children': ['141']}; {'id': '141', 'type': 'call', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'beginEditBlock'}; {'id': '145', 'type': 'argument_list', 'children': []}; {'id': '146', 'type': 'for_statement', 'children': ['147', '148', '152']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '148', 'type': 'call', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '150', 'type': 'argument_list', 'children': ['151']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'spaces'}; {'id': '152', 'type': 'block', 'children': ['153']}; {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'call', 'children': ['155', '158']}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'deletePreviousChar'}; {'id': '158', 'type': 'argument_list', 'children': []}; {'id': '159', 'type': 'expression_statement', 'children': ['160']}; {'id': '160', 'type': 'call', 'children': ['161', '164']}; {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'endEditBlock'}; {'id': '164', 'type': 'argument_list', 'children': []}; {'id': '165', 'type': 'expression_statement', 'children': ['166']}; {'id': '166', 'type': 'call', 'children': ['167', '172']}; {'id': '167', 'type': 'attribute', 'children': ['168', '171']}; {'id': '168', 'type': 'attribute', 'children': ['169', '170']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'editor'}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'setTextCursor'}; {'id': '172', 'type': 'argument_list', 'children': ['173']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '174', 'type': 'expression_statement', 'children': ['175']}; {'id': '175', 'type': 'call', 'children': ['176', '181']}; {'id': '176', 'type': 'attribute', 'children': ['177', '180']}; {'id': '177', 'type': 'call', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '179', 'type': 'argument_list', 'children': []}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '181', 'type': 'argument_list', 'children': ['182']}; {'id': '182', 'type': 'call', 'children': ['183', '190']}; {'id': '183', 'type': 'attribute', 'children': ['184', '189']}; {'id': '184', 'type': 'call', 'children': ['185', '188']}; {'id': '185', 'type': 'attribute', 'children': ['186', '187']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '187', 'type': 'identifier', 'children': [], 'value': 'block'}; {'id': '188', 'type': 'argument_list', 'children': []}; {'id': '189', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '190', 'type': 'argument_list', 'children': []}
Un-indents text at cursor position.
def _should_defer(input_layer, args, kwargs): for arg in itertools.chain([input_layer], args, six.itervalues(kwargs)): if isinstance(arg, (_DeferredLayer, UnboundVariable)): return True elif (isinstance(arg, collections.Sequence) and not isinstance(arg, six.string_types)): if _should_defer(None, arg, {}): return True elif isinstance(arg, collections.Mapping): if _should_defer(None, (), arg): return True return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_should_defer'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'input_layer'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '84']}; {'id': '8', 'type': 'for_statement', 'children': ['9', '10', '24']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'itertools'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'chain'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '17', '18']}; {'id': '15', 'type': 'list', 'children': ['16'], 'value': '[input_layer]'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'input_layer'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'itervalues'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'if_statement', 'children': ['26', '33', '36', '65']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '30', 'type': 'tuple', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_DeferredLayer'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'UnboundVariable'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'True', 'children': []}; {'id': '36', 'type': 'elif_clause', 'children': ['37', '54']}; {'id': '37', 'type': '()', 'children': ['38']}; {'id': '38', 'type': 'boolean_operator', 'children': ['39', '46'], 'value': 'and'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'collections'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'Sequence'}; {'id': '46', 'type': 'not_operator', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'string_types'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'if_statement', 'children': ['56', '62']}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '_should_defer'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60', '61']}; {'id': '59', 'type': 'None', 'children': []}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '61', 'type': 'dictionary', 'children': []}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'True', 'children': []}; {'id': '65', 'type': 'elif_clause', 'children': ['66', '73']}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '68', 'type': 'argument_list', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'collections'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'Mapping'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'if_statement', 'children': ['75', '81']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': '_should_defer'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79', '80']}; {'id': '78', 'type': 'None', 'children': []}; {'id': '79', 'type': 'tuple', 'children': []}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'return_statement', 'children': ['83']}; {'id': '83', 'type': 'True', 'children': []}; {'id': '84', 'type': 'return_statement', 'children': ['85']}; {'id': '85', 'type': 'False', 'children': []}
Checks to see if any of the args are templates.
def _handle_tag_enabledebugger2(self): obj = _make_object("EnableDebugger2") obj.Reserved = unpack_ui16(self._src) obj.Password = self._get_struct_string() return obj
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_handle_tag_enabledebugger2'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '24', '34']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_make_object'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'string', 'children': [], 'value': '"EnableDebugger2"'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Reserved'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'unpack_ui16'}; {'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': '_src'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Password'}; {'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': '_get_struct_string'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'obj'}
Handle the EnableDebugger2 tag.
def audio_load_time(self): load_times = self.get_load_times('audio') return round(mean(load_times), self.decimal_precision)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'audio_load_time'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'load_times'}; {'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': 'get_load_times'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'audio'"}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '23']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'mean'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'load_times'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'decimal_precision'}
Returns aggregate audio load time for all pages.
def create_modelo(self): return Modelo( self.networkapi_url, self.user, self.password, self.user_ldap)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_modelo'}; {'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': 'Modelo'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '13', '16', '19']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'networkapi_url'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'user_ldap'}
Get an instance of modelo services facade.
def _fill_out_err(result, testcase): if result.get("stdout"): system_out = etree.SubElement(testcase, "system-out") system_out.text = utils.get_unicode_str(result["stdout"]) if result.get("stderr"): system_err = etree.SubElement(testcase, "system-err") system_err.text = utils.get_unicode_str(result["stderr"])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_fill_out_err'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'testcase'}; {'id': '6', 'type': 'block', 'children': ['7', '38']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'string', 'children': [], 'value': '"stdout"'}; {'id': '14', 'type': 'block', 'children': ['15', '25']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'system_out'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'SubElement'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'testcase'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"system-out"'}; {'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': 'system_out'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'get_unicode_str'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '37', 'type': 'string', 'children': [], 'value': '"stdout"'}; {'id': '38', 'type': 'if_statement', 'children': ['39', '45']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'string', 'children': [], 'value': '"stderr"'}; {'id': '45', 'type': 'block', 'children': ['46', '56']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'system_err'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'SubElement'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'testcase'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"system-err"'}; {'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': 'system_err'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'get_unicode_str'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'subscript', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '68', 'type': 'string', 'children': [], 'value': '"stderr"'}
Adds stdout and stderr if present.
def packstr(instr, textwidth=160, breakchars=' ', break_words=True, newline_prefix='', indentation='', nlprefix=None, wordsep=' ', remove_newlines=True): if not isinstance(instr, six.string_types): instr = repr(instr) if nlprefix is not None: newline_prefix = nlprefix str_ = pack_into(instr, textwidth, breakchars, break_words, newline_prefix, wordsep, remove_newlines) if indentation != '': str_ = indent(str_, indentation) return str_
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '29']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'packstr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'instr'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'textwidth'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '160'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'breakchars'}; {'id': '10', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'break_words'}; {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'newline_prefix'}; {'id': '16', 'type': 'string', 'children': [], 'value': "''"}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'indentation'}; {'id': '19', 'type': 'string', 'children': [], 'value': "''"}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'nlprefix'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'default_parameter', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'wordsep'}; {'id': '25', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '26', 'type': 'default_parameter', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'remove_newlines'}; {'id': '28', 'type': 'True', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30', '47', '56', '69', '82']}; {'id': '30', 'type': 'if_statement', 'children': ['31', '39']}; {'id': '31', 'type': 'not_operator', 'children': ['32']}; {'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': 'instr'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'string_types'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'instr'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'instr'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '51']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': 'is not'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'nlprefix'}; {'id': '50', 'type': 'None', 'children': []}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'newline_prefix'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'nlprefix'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'str_'}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'pack_into'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63', '64', '65', '66', '67', '68']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'instr'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'textwidth'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'breakchars'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'break_words'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'newline_prefix'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'wordsep'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'remove_newlines'}; {'id': '69', 'type': 'if_statement', 'children': ['70', '73']}; {'id': '70', 'type': 'comparison_operator', 'children': ['71', '72'], 'value': '!='}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'indentation'}; {'id': '72', 'type': 'string', 'children': [], 'value': "''"}; {'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': 'str_'}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'indent'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'str_'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'indentation'}; {'id': '82', 'type': 'return_statement', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'str_'}
alias for pack_into. has more up to date kwargs
def validate(self): _validate_operator_name(self.operator, BinaryComposition.SUPPORTED_OPERATORS) if not isinstance(self.left, Expression): raise TypeError(u'Expected Expression left, got: {} {} {}'.format( type(self.left).__name__, self.left, self)) if not isinstance(self.right, Expression): raise TypeError(u'Expected Expression right, got: {} {}'.format( type(self.right).__name__, self.right))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '47']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': '_validate_operator_name'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'BinaryComposition'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'SUPPORTED_OPERATORS'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '25']}; {'id': '17', 'type': 'not_operator', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'left'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'Expression'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'raise_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': "u'Expected Expression left, got: {} {} {}'"}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '43', '46']}; {'id': '35', 'type': 'attribute', 'children': ['36', '42']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'left'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'left'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '56']}; {'id': '48', 'type': 'not_operator', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'Expression'}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'raise_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'string', 'children': [], 'value': "u'Expected Expression right, got: {} {}'"}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '74']}; {'id': '66', 'type': 'attribute', 'children': ['67', '73']}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'right'}
Validate that the BinaryComposition is correctly representable.
def mute_parse_args(self, text): error = AzCliCommandParser.error _check_value = AzCliCommandParser._check_value AzCliCommandParser.error = error_pass AzCliCommandParser._check_value = _check_value_muted try: parse_args = self.argsfinder.get_parsed_args(parse_quotes(text, quotes=False, string=False)) except Exception: pass AzCliCommandParser.error = error AzCliCommandParser._check_value = _check_value return parse_args
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mute_parse_args'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '19', '25', '31', '57', '63', '69']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'AzCliCommandParser'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_check_value'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'AzCliCommandParser'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_check_value'}; {'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': 'AzCliCommandParser'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'error_pass'}; {'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': 'AzCliCommandParser'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_check_value'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_check_value_muted'}; {'id': '31', 'type': 'try_statement', 'children': ['32', '53']}; {'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': 'parse_args'}; {'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': 'argsfinder'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'get_parsed_args'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'parse_quotes'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47', '50']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'quotes'}; {'id': '49', 'type': 'False', 'children': []}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '52', 'type': 'False', 'children': []}; {'id': '53', 'type': 'except_clause', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'pass_statement', 'children': []}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'AzCliCommandParser'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'AzCliCommandParser'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': '_check_value'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': '_check_value'}; {'id': '69', 'type': 'return_statement', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'parse_args'}
mutes the parser error when parsing, then puts it back
def all_floating_ips(self): if self.api_version == 2: json = self.request('/floating_ips') return json['floating_ips'] else: raise DoError(v2_api_required_str)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'all_floating_ips'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12', '26']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': '=='}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'api_version'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '12', 'type': 'block', 'children': ['13', '22']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'/floating_ips'"}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'floating_ips'"}; {'id': '26', 'type': 'else_clause', 'children': ['27']}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'raise_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'DoError'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'v2_api_required_str'}
Lists all of the Floating IPs available on the account.
def _get_argument_list_from_toolkit_function_name(fn): unity = _get_unity() fnprops = unity.describe_toolkit_function(fn) argnames = fnprops['arguments'] return argnames
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_argument_list_from_toolkit_function_name'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '21', '27']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'unity'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_get_unity'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'fnprops'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'unity'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'describe_toolkit_function'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'argnames'}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'fnprops'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'arguments'"}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'argnames'}
Given a toolkit function name, return the argument list
def android_example(): env = holodeck.make("AndroidPlayground") command = np.ones(94) * 10 for i in range(10): env.reset() for j in range(1000): if j % 50 == 0: command *= -1 state, reward, terminal, _ = env.step(command) pixels = state[Sensors.PIXEL_CAMERA] orientation = state[Sensors.ORIENTATION_SENSOR]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'android_example'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '14', '25']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'holodeck'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'make'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'string', 'children': [], 'value': '"AndroidPlayground"'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '24'], 'value': '*'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ones'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'integer', 'children': [], 'value': '94'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '25', 'type': 'for_statement', 'children': ['26', '27', '31']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '31', 'type': 'block', 'children': ['32', '38']}; {'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': 'env'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'reset'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'for_statement', 'children': ['39', '40', '44']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'integer', 'children': [], 'value': '1000'}; {'id': '44', 'type': 'block', 'children': ['45', '57', '70', '78']}; {'id': '45', 'type': 'if_statement', 'children': ['46', '51']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '50'], 'value': '=='}; {'id': '47', 'type': 'binary_operator', 'children': ['48', '49'], 'value': '%'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '50'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'augmented_assignment', 'children': ['54', '55'], 'value': '*='}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '55', 'type': 'unary_operator', 'children': ['56'], 'value': '-'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '64']}; {'id': '59', 'type': 'pattern_list', 'children': ['60', '61', '62', '63']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'reward'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'terminal'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'pixels'}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'Sensors'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'PIXEL_CAMERA'}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'orientation'}; {'id': '81', 'type': 'subscript', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'Sensors'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'ORIENTATION_SENSOR'}
A basic example of how to use the android agent.
def _build_body_schema(serializer, body_parameters): description = "" if isinstance(body_parameters, Param): schema = serializer.to_json_schema(body_parameters.arginfo.type) description = body_parameters.description required = True else: if len(body_parameters) == 0: return None required = set() body_properties = {} for name, param in body_parameters.items(): arginfo = param.arginfo body_properties[name] = serializer.to_json_schema(arginfo.type) body_properties[name]["description"] = param.description if arginfo.default is NoDefault: required.add(name) schema = { "type": "object", "required": list(required), "properties": body_properties, } required = len(required) > 0 return BodyParameter( { "name": "body", "description": description, "required": required, "schema": schema, } )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_build_body_schema'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'body_parameters'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '141']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '10', 'type': 'string', 'children': [], 'value': '""'}; {'id': '11', 'type': 'if_statement', 'children': ['12', '17', '41']}; {'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': 'body_parameters'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'Param'}; {'id': '17', 'type': 'block', 'children': ['18', '31', '37']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'to_json_schema'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'body_parameters'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'arginfo'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'body_parameters'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '40', 'type': 'True', 'children': []}; {'id': '41', 'type': 'else_clause', 'children': ['42']}; {'id': '42', 'type': 'block', 'children': ['43', '53', '59', '63', '116', '132']}; {'id': '43', 'type': 'if_statement', 'children': ['44', '50']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '49'], 'value': '=='}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'body_parameters'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'None', 'children': []}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'set'}; {'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': 'body_properties'}; {'id': '62', 'type': 'dictionary', 'children': []}; {'id': '63', 'type': 'for_statement', 'children': ['64', '67', '72']}; {'id': '64', 'type': 'pattern_list', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'body_parameters'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '71', 'type': 'argument_list', 'children': []}; {'id': '72', 'type': 'block', 'children': ['73', '79', '92', '102']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'arginfo'}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'arginfo'}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '84']}; {'id': '81', 'type': 'subscript', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'body_properties'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'to_json_schema'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'arginfo'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '99']}; {'id': '94', 'type': 'subscript', 'children': ['95', '98']}; {'id': '95', 'type': 'subscript', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'body_properties'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '98', 'type': 'string', 'children': [], 'value': '"description"'}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '102', 'type': 'if_statement', 'children': ['103', '108']}; {'id': '103', 'type': 'comparison_operator', 'children': ['104', '107'], 'value': 'is'}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'arginfo'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'NoDefault'}; {'id': '108', 'type': 'block', 'children': ['109']}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'assignment', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '119', 'type': 'dictionary', 'children': ['120', '123', '129']}; {'id': '120', 'type': 'pair', 'children': ['121', '122']}; {'id': '121', 'type': 'string', 'children': [], 'value': '"type"'}; {'id': '122', 'type': 'string', 'children': [], 'value': '"object"'}; {'id': '123', 'type': 'pair', 'children': ['124', '125']}; {'id': '124', 'type': 'string', 'children': [], 'value': '"required"'}; {'id': '125', 'type': 'call', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '129', 'type': 'pair', 'children': ['130', '131']}; {'id': '130', 'type': 'string', 'children': [], 'value': '"properties"'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'body_properties'}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'assignment', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '135', 'type': 'comparison_operator', 'children': ['136', '140'], 'value': '>'}; {'id': '136', 'type': 'call', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '138', 'type': 'argument_list', 'children': ['139']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '140', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '141', 'type': 'return_statement', 'children': ['142']}; {'id': '142', 'type': 'call', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'BodyParameter'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}; {'id': '145', 'type': 'dictionary', 'children': ['146', '149', '152', '155']}; {'id': '146', 'type': 'pair', 'children': ['147', '148']}; {'id': '147', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '148', 'type': 'string', 'children': [], 'value': '"body"'}; {'id': '149', 'type': 'pair', 'children': ['150', '151']}; {'id': '150', 'type': 'string', 'children': [], 'value': '"description"'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '152', 'type': 'pair', 'children': ['153', '154']}; {'id': '153', 'type': 'string', 'children': [], 'value': '"required"'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '155', 'type': 'pair', 'children': ['156', '157']}; {'id': '156', 'type': 'string', 'children': [], 'value': '"schema"'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'schema'}
body is built differently, since it's a single argument no matter what.
def tileXYZToQuadKey(self, x, y, z): quadKey = '' for i in range(z, 0, -1): digit = 0 mask = 1 << (i - 1) if (x & mask) != 0: digit += 1 if (y & mask) != 0: digit += 2 quadKey += str(digit) return quadKey
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tileXYZToQuadKey'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'z'}; {'id': '8', 'type': 'block', 'children': ['9', '13', '67']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'quadKey'}; {'id': '12', 'type': 'string', 'children': [], 'value': "''"}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '22']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19', '20']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'z'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '20', 'type': 'unary_operator', 'children': ['21'], 'value': '-'}; {'id': '21', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '22', 'type': 'block', 'children': ['23', '27', '36', '48', '60']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'digit'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '30', 'type': 'binary_operator', 'children': ['31', '32'], 'value': '<<'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '32', 'type': '()', 'children': ['33']}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '35'], 'value': '-'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '43']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '42'], 'value': '!='}; {'id': '38', 'type': '()', 'children': ['39']}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '41'], 'value': '&'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'augmented_assignment', 'children': ['46', '47'], 'value': '+='}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'digit'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '55']}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '54'], 'value': '!='}; {'id': '50', 'type': '()', 'children': ['51']}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '53'], 'value': '&'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'augmented_assignment', 'children': ['58', '59'], 'value': '+='}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'digit'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'augmented_assignment', 'children': ['62', '63'], 'value': '+='}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'quadKey'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'digit'}; {'id': '67', 'type': 'return_statement', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'quadKey'}
Computes quadKey value based on tile x, y and z values.
def parse_url(request, url): try: validate = URLValidator() validate(url) except ValidationError: if url.startswith('/'): host = request.get_host() scheme = 'https' if request.is_secure() else 'http' url = '{scheme}://{host}{uri}'.format(scheme=scheme, host=host, uri=url) else: url = request.build_absolute_uri(reverse(url)) return url
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_url'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '6', 'type': 'block', 'children': ['7', '81']}; {'id': '7', 'type': 'try_statement', 'children': ['8', '20']}; {'id': '8', 'type': 'block', 'children': ['9', '15']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'validate'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'URLValidator'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'validate'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '20', 'type': 'except_clause', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ValidationError'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'if_statement', 'children': ['24', '30', '67']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '30', 'type': 'block', 'children': ['31', '39', '50']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'get_host'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'scheme'}; {'id': '42', 'type': 'conditional_expression', 'children': ['43', '44', '49'], 'value': 'if'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'https'"}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'is_secure'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'string', 'children': [], 'value': "'http'"}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'{scheme}://{host}{uri}'"}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '61', '64']}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'scheme'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'scheme'}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'uri'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '67', 'type': 'else_clause', 'children': ['68']}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'build_absolute_uri'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '81', 'type': 'return_statement', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'url'}
Parse url URL parameter.
def scores_to_probs(scores, proba, eps=0.01): if np.any(~proba): probs = copy.deepcopy(scores) n_class = len(proba) for m in range(n_class): if not proba[m]: max_extreme_score = max(np.abs(np.min(scores[:,m])),\ np.abs(np.max(scores[:,m]))) k = np.log((1-eps)/eps)/max_extreme_score self._probs[:,m] = expit(k * self.scores[:,m]) return probs else: return scores
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scores_to_probs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'scores'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'proba'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'eps'}; {'id': '8', 'type': 'float', 'children': [], 'value': '0.01'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '18', '124']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'unary_operator', 'children': ['17'], 'value': '~'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'proba'}; {'id': '18', 'type': 'block', 'children': ['19', '28', '35', '122']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'probs'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'deepcopy'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'scores'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'n_class'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'proba'}; {'id': '35', 'type': 'for_statement', 'children': ['36', '37', '41']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'n_class'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'if_statement', 'children': ['43', '47']}; {'id': '43', 'type': 'not_operator', 'children': ['44']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'proba'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '47', 'type': 'block', 'children': ['48', '85', '101']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'max_extreme_score'}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '69', '70']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'abs'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'subscript', 'children': ['65', '66', '68']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'scores'}; {'id': '66', 'type': 'slice', 'children': ['67']}; {'id': '67', 'type': 'colon', 'children': []}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '69', 'type': 'line_continuation', 'children': [], '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': 'abs'}; {'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': 'np'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'subscript', 'children': ['81', '82', '84']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'scores'}; {'id': '82', 'type': 'slice', 'children': ['83']}; {'id': '83', 'type': 'colon', 'children': []}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '88', 'type': 'binary_operator', 'children': ['89', '100'], 'value': '/'}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'binary_operator', 'children': ['95', '99'], 'value': '/'}; {'id': '95', 'type': '()', 'children': ['96']}; {'id': '96', 'type': 'binary_operator', 'children': ['97', '98'], 'value': '-'}; {'id': '97', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'eps'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'eps'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'max_extreme_score'}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '110']}; {'id': '103', 'type': 'subscript', 'children': ['104', '107', '109']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': '_probs'}; {'id': '107', 'type': 'slice', 'children': ['108']}; {'id': '108', 'type': 'colon', 'children': []}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'expit'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'binary_operator', 'children': ['114', '115'], 'value': '*'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '115', 'type': 'subscript', 'children': ['116', '119', '121']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'scores'}; {'id': '119', 'type': 'slice', 'children': ['120']}; {'id': '120', 'type': 'colon', 'children': []}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '122', 'type': 'return_statement', 'children': ['123']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'probs'}; {'id': '124', 'type': 'else_clause', 'children': ['125']}; {'id': '125', 'type': 'block', 'children': ['126']}; {'id': '126', 'type': 'return_statement', 'children': ['127']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'scores'}
Transforms scores to probabilities by applying the logistic function
def _on_client_latency_changed(self, data): self._clients.get(data.get('id')).update_latency(data)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_on_client_latency_changed'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '24']}; {'id': '9', 'type': 'attribute', 'children': ['10', '23']}; {'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': '_clients'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'update_latency'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'data'}
Handle client latency changed.
def GetSOAPPart(self): head, part = self.parts[0] return StringIO.StringIO(part.getvalue())
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetSOAPPart'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'head'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '11', 'type': 'subscript', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'parts'}; {'id': '15', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'StringIO'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'StringIO'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'getvalue'}; {'id': '26', 'type': 'argument_list', 'children': []}
Get the SOAP body part.
def load_user_envs(self): installed_packages = self._list_packages() gym_package = 'gym ({})'.format(installed_packages['gym']) if 'gym' in installed_packages else 'gym' core_specs = registry.all() for spec in core_specs: spec.source = 'OpenAI Gym Core Package' spec.package = gym_package if not os.path.isfile(self.cache_path): return with open(self.cache_path) as cache: for line in cache: user_package, registered_envs = self._load_package(line.rstrip('\n'), installed_packages) if logger.level <= logging.DEBUG: logger.debug('Installed %d user environments from package "%s"', len(registered_envs), user_package['name']) if self.cache_needs_update: self._update_cache() if len(self.env_ids) > 0: logger.info('Found and registered %d user environments.', len(self.env_ids))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_user_envs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '30', '38', '54', '68', '125', '136']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'installed_packages'}; {'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': '_list_packages'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'gym_package'}; {'id': '17', 'type': 'conditional_expression', 'children': ['18', '26', '29'], 'value': 'if'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'gym ({})'"}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'installed_packages'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'gym'"}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'in'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'gym'"}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'installed_packages'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'gym'"}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'core_specs'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'registry'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'for_statement', 'children': ['39', '40', '41']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'core_specs'}; {'id': '41', 'type': 'block', 'children': ['42', '48']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'OpenAI Gym Core Package'"}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'gym_package'}; {'id': '54', 'type': 'if_statement', 'children': ['55', '66']}; {'id': '55', 'type': 'not_operator', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '62']}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'cache_path'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'return_statement', 'children': []}; {'id': '68', 'type': 'with_statement', 'children': ['69', '80']}; {'id': '69', 'type': 'with_clause', 'children': ['70']}; {'id': '70', 'type': 'with_item', 'children': ['71']}; {'id': '71', 'type': 'as_pattern', 'children': ['72', '78']}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'cache_path'}; {'id': '78', 'type': 'as_pattern_target', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'cache'}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'for_statement', 'children': ['82', '83', '84']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'cache'}; {'id': '84', 'type': 'block', 'children': ['85', '102']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '90']}; {'id': '87', 'type': 'pattern_list', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'user_package'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'registered_envs'}; {'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': '_load_package'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '101']}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'rstrip'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'installed_packages'}; {'id': '102', 'type': 'if_statement', 'children': ['103', '110']}; {'id': '103', 'type': 'comparison_operator', 'children': ['104', '107'], 'value': '<='}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'DEBUG'}; {'id': '110', 'type': 'block', 'children': ['111']}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'call', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '116', 'type': 'argument_list', 'children': ['117', '118', '122']}; {'id': '117', 'type': 'string', 'children': [], 'value': '\'Installed %d user environments from package "%s"\''}; {'id': '118', 'type': 'call', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '120', 'type': 'argument_list', 'children': ['121']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'registered_envs'}; {'id': '122', 'type': 'subscript', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'user_package'}; {'id': '124', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '125', 'type': 'if_statement', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'cache_needs_update'}; {'id': '129', 'type': 'block', 'children': ['130']}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': '_update_cache'}; {'id': '135', 'type': 'argument_list', 'children': []}; {'id': '136', 'type': 'if_statement', 'children': ['137', '145']}; {'id': '137', 'type': 'comparison_operator', 'children': ['138', '144'], 'value': '>'}; {'id': '138', 'type': 'call', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'env_ids'}; {'id': '144', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '145', 'type': 'block', 'children': ['146']}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}; {'id': '147', 'type': 'call', 'children': ['148', '151']}; {'id': '148', 'type': 'attribute', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '151', 'type': 'argument_list', 'children': ['152', '153']}; {'id': '152', 'type': 'string', 'children': [], 'value': "'Found and registered %d user environments.'"}; {'id': '153', 'type': 'call', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '155', 'type': 'argument_list', 'children': ['156']}; {'id': '156', 'type': 'attribute', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'env_ids'}
Loads downloaded user envs from filesystem cache on `import gym`
def optimize_no(self): self.optimization = 0 self.relax = False self.gc_sections = False self.ffunction_sections = False self.fdata_sections = False self.fno_inline_small_functions = False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'optimize_no'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '18', '24', '30', '36']}; {'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': 'optimization'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'relax'}; {'id': '17', 'type': 'False', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'gc_sections'}; {'id': '23', 'type': 'False', 'children': []}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ffunction_sections'}; {'id': '29', 'type': 'False', 'children': []}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'fdata_sections'}; {'id': '35', 'type': 'False', 'children': []}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'fno_inline_small_functions'}; {'id': '41', 'type': 'False', 'children': []}
all options set to default
def apool(self, k_height, k_width, d_height=2, d_width=2, mode="VALID", input_layer=None, num_channels_in=None): return self._pool("apool", pooling_layers.average_pooling2d, k_height, k_width, d_height, d_width, mode, input_layer, num_channels_in)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'apool'}; {'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': 'k_height'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'k_width'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'd_height'}; {'id': '9', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'd_width'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"VALID"'}; {'id': '16', 'type': 'default_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'input_layer'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'default_parameter', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'num_channels_in'}; {'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': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_pool'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30', '33', '34', '35', '36', '37', '38', '39']}; {'id': '29', 'type': 'string', 'children': [], 'value': '"apool"'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'pooling_layers'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'average_pooling2d'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'k_height'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'k_width'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'd_height'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'd_width'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'input_layer'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'num_channels_in'}
Construct an average pooling layer.
def Y_tighter(self): self.parent.value('y_distance', self.parent.value('y_distance') / 1.4) self.parent.traces.display()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Y_tighter'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '25']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'y_distance'"}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '24'], 'value': '/'}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'y_distance'"}; {'id': '24', 'type': 'float', 'children': [], 'value': '1.4'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '34']}; {'id': '27', 'type': 'attribute', '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': 'parent'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'traces'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'display'}; {'id': '34', 'type': 'argument_list', 'children': []}
Decrease the distance of the lines.
def clear_cache_delete_selected(modeladmin, request, queryset): result = delete_selected(modeladmin, request, queryset) if not result and hasattr(modeladmin, 'invalidate_cache'): modeladmin.invalidate_cache(queryset=queryset) return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear_cache_delete_selected'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'modeladmin'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'queryset'}; {'id': '7', 'type': 'block', 'children': ['8', '17', '36']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'delete_selected'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15', '16']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'modeladmin'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'queryset'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '26']}; {'id': '18', 'type': 'boolean_operator', 'children': ['19', '21'], 'value': 'and'}; {'id': '19', 'type': 'not_operator', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'modeladmin'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'invalidate_cache'"}; {'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': 'modeladmin'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'invalidate_cache'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'queryset'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'queryset'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'result'}
A delete action that will invalidate cache after being called.
def config_scale(self, cnf={}, **kwargs): self._scale.config(cnf, **kwargs) self._variable.configure(high=self._scale['to'], low=self._scale['from']) if 'orient' in cnf or 'orient' in kwargs: self._grid_widgets()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'config_scale'}; {'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': 'cnf'}; {'id': '7', 'type': 'dictionary', 'children': []}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11', '22', '44']}; {'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': '_scale'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'cnf'}; {'id': '20', 'type': 'dictionary_splat', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_variable'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'configure'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '37']}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'high'}; {'id': '32', 'type': 'subscript', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_scale'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'to'"}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'low'}; {'id': '39', 'type': 'subscript', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '_scale'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'from'"}; {'id': '44', 'type': 'if_statement', 'children': ['45', '52']}; {'id': '45', 'type': 'boolean_operator', 'children': ['46', '49'], 'value': 'or'}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': 'in'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'orient'"}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'cnf'}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '51'], 'value': 'in'}; {'id': '50', 'type': 'string', 'children': [], 'value': "'orient'"}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '_grid_widgets'}; {'id': '58', 'type': 'argument_list', 'children': []}
Configure resources of the Scale widget.
def __addNode(self, name, cls): if name in self.nodes: raise Exception("A node by the name {} already exists. Can't add a duplicate.".format(name)) self.__nxgraph.add_node(name) self.__nxgraph.node[name]['label'] = name self.__nxgraph.node[name]['nodeobj'] = cls() self.__nxgraph.node[name]['type'] = cls.__name__
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__addNode'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '7', 'type': 'block', 'children': ['8', '25', '34', '46', '60']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'in'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'raise_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': '"A node by the name {} already exists. Can\'t add a duplicate."'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '__nxgraph'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'add_node'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '45']}; {'id': '36', 'type': 'subscript', 'children': ['37', '44']}; {'id': '37', 'type': 'subscript', 'children': ['38', '43']}; {'id': '38', 'type': 'attribute', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '__nxgraph'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'label'"}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '57']}; {'id': '48', 'type': 'subscript', 'children': ['49', '56']}; {'id': '49', 'type': 'subscript', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': '__nxgraph'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '56', 'type': 'string', 'children': [], 'value': "'nodeobj'"}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '71']}; {'id': '62', 'type': 'subscript', 'children': ['63', '70']}; {'id': '63', 'type': 'subscript', 'children': ['64', '69']}; {'id': '64', 'type': 'attribute', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': '__nxgraph'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '70', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': '__name__'}
Add a node to the topology
def dispatch(self, *args, **kwargs): return super(QuickEntry, self).dispatch(*args, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dispatch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'list_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'return_statement', 'children': ['11']}; {'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': 'QuickEntry'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'dispatch'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '22']}; {'id': '20', 'type': 'list_splat', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '22', 'type': 'dictionary_splat', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Decorate the view dispatcher with permission_required.
def properties_changed(self, properties, changed_properties, invalidated_properties): value = changed_properties.get('Value') if value is not None: self.service.device.characteristic_value_updated(characteristic=self, value=bytes(value))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'properties_changed'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'properties'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'changed_properties'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'invalidated_properties'}; {'id': '8', 'type': 'block', 'children': ['9', '18']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'changed_properties'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'Value'"}; {'id': '18', 'type': 'if_statement', 'children': ['19', '22']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': 'is not'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', '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': 'service'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'characteristic_value_updated'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '36']}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'characteristic'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'value'}
Called when a Characteristic property has changed.
def process_build_metrics(context, build_processors): build_metrics = OrderedDict() for p in build_processors: p.reset() for p in build_processors: build_metrics.update(p.build_metrics) return build_metrics
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_build_metrics'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'build_processors'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '23', '36']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'build_metrics'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '16']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'build_processors'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'reset'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'for_statement', 'children': ['24', '25', '26']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'build_processors'}; {'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': 'build_metrics'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'build_metrics'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'build_metrics'}
use processors to collect build metrics.
def response(self, msgtype, msgid, error, result): self._proxy.response(msgid, error, result)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'response'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'msgtype'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'msgid'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_proxy'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19', '20']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'msgid'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'result'}
Handle an incoming response.
def index(): kwdb = current_app.kwdb libraries = get_collections(kwdb, libtype="library") resource_files = get_collections(kwdb, libtype="resource") return flask.render_template("libraryNames.html", data={"libraries": libraries, "version": __version__, "resource_files": resource_files })
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'index'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '21', '31']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwdb'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'kwdb'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'libraries'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get_collections'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'kwdb'}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'libtype'}; {'id': '20', 'type': 'string', 'children': [], 'value': '"library"'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'resource_files'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'get_collections'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'kwdb'}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'libtype'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"resource"'}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'flask'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'render_template'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"libraryNames.html"'}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '40', 'type': 'dictionary', 'children': ['41', '44', '47']}; {'id': '41', 'type': 'pair', 'children': ['42', '43']}; {'id': '42', 'type': 'string', 'children': [], 'value': '"libraries"'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'libraries'}; {'id': '44', 'type': 'pair', 'children': ['45', '46']}; {'id': '45', 'type': 'string', 'children': [], 'value': '"version"'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '__version__'}; {'id': '47', 'type': 'pair', 'children': ['48', '49']}; {'id': '48', 'type': 'string', 'children': [], 'value': '"resource_files"'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'resource_files'}
Show a list of available libraries, and resource files
def write_summary_cnts_all(self): cnts = self.get_cnts_levels_depths_recs(set(self.obo.values())) self._write_summary_cnts(cnts)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_summary_cnts_all'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '24']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'cnts'}; {'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': 'get_cnts_levels_depths_recs'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '16', 'type': 'argument_list', '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': 'obo'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_write_summary_cnts'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'cnts'}
Write summary of level and depth counts for all active GO Terms.
def _convert_to_identifier_json(self, address_data): if isinstance(address_data, str): return {"slug": address_data} if isinstance(address_data, tuple) and len(address_data) > 0: address_json = {"address": address_data[0]} if len(address_data) > 1: address_json["zipcode"] = address_data[1] if len(address_data) > 2: address_json["meta"] = address_data[2] return address_json if isinstance(address_data, dict): allowed_keys = ["address", "zipcode", "unit", "city", "state", "slug", "meta", "client_value", "client_value_sqft"] for key in address_data: if key not in allowed_keys: msg = "Key in address input not allowed: " + key raise housecanary.exceptions.InvalidInputException(msg) if "address" in address_data or "slug" in address_data: return address_data msg = ("Input is invalid. Must be a list of (address, zipcode) tuples, or a dict or list" " of dicts with each item containing at least an 'address' or 'slug' key.") raise housecanary.exceptions.InvalidInputException((msg))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_to_identifier_json'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '6', 'type': 'block', 'children': ['7', '19', '76', '131', '138']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'dictionary', 'children': ['16']}; {'id': '16', 'type': 'pair', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"slug"'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '32']}; {'id': '20', 'type': 'boolean_operator', 'children': ['21', '26'], 'value': 'and'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '31'], 'value': '>'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '32', 'type': 'block', 'children': ['33', '42', '58', '74']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'address_json'}; {'id': '36', 'type': 'dictionary', 'children': ['37']}; {'id': '37', 'type': 'pair', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': '"address"'}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '49']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '48'], 'value': '>'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '55']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'address_json'}; {'id': '54', 'type': 'string', 'children': [], 'value': '"zipcode"'}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '65']}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '64'], 'value': '>'}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '64', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '71']}; {'id': '68', 'type': 'subscript', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'address_json'}; {'id': '70', 'type': 'string', 'children': [], 'value': '"meta"'}; {'id': '71', 'type': 'subscript', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '73', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'address_json'}; {'id': '76', 'type': 'if_statement', 'children': ['77', '82']}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '82', 'type': 'block', 'children': ['83', '96', '120']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'allowed_keys'}; {'id': '86', 'type': 'list', 'children': ['87', '88', '89', '90', '91', '92', '93', '94', '95'], 'value': '["address", "zipcode", "unit", "city", "state", "slug", "meta",\n "client_value", "client_value_sqft"]'}; {'id': '87', 'type': 'string', 'children': [], 'value': '"address"'}; {'id': '88', 'type': 'string', 'children': [], 'value': '"zipcode"'}; {'id': '89', 'type': 'string', 'children': [], 'value': '"unit"'}; {'id': '90', 'type': 'string', 'children': [], 'value': '"city"'}; {'id': '91', 'type': 'string', 'children': [], 'value': '"state"'}; {'id': '92', 'type': 'string', 'children': [], 'value': '"slug"'}; {'id': '93', 'type': 'string', 'children': [], 'value': '"meta"'}; {'id': '94', 'type': 'string', 'children': [], 'value': '"client_value"'}; {'id': '95', 'type': 'string', 'children': [], 'value': '"client_value_sqft"'}; {'id': '96', 'type': 'for_statement', 'children': ['97', '98', '99']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'if_statement', 'children': ['101', '104']}; {'id': '101', 'type': 'comparison_operator', 'children': ['102', '103'], 'value': 'not in'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'allowed_keys'}; {'id': '104', 'type': 'block', 'children': ['105', '111']}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '108', 'type': 'binary_operator', 'children': ['109', '110'], 'value': '+'}; {'id': '109', 'type': 'string', 'children': [], 'value': '"Key in address input not allowed: "'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '111', 'type': 'raise_statement', 'children': ['112']}; {'id': '112', 'type': 'call', 'children': ['113', '118']}; {'id': '113', 'type': 'attribute', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'housecanary'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'InvalidInputException'}; {'id': '118', 'type': 'argument_list', 'children': ['119']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '120', 'type': 'if_statement', 'children': ['121', '128']}; {'id': '121', 'type': 'boolean_operator', 'children': ['122', '125'], 'value': 'or'}; {'id': '122', 'type': 'comparison_operator', 'children': ['123', '124'], 'value': 'in'}; {'id': '123', 'type': 'string', 'children': [], 'value': '"address"'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '125', 'type': 'comparison_operator', 'children': ['126', '127'], 'value': 'in'}; {'id': '126', 'type': 'string', 'children': [], 'value': '"slug"'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '128', 'type': 'block', 'children': ['129']}; {'id': '129', 'type': 'return_statement', 'children': ['130']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'address_data'}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'assignment', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '134', 'type': '()', 'children': ['135']}; {'id': '135', 'type': 'concatenated_string', 'children': ['136', '137']}; {'id': '136', 'type': 'string', 'children': [], 'value': '"Input is invalid. Must be a list of (address, zipcode) tuples, or a dict or list"'}; {'id': '137', 'type': 'string', 'children': [], 'value': '" of dicts with each item containing at least an \'address\' or \'slug\' key."'}; {'id': '138', 'type': 'raise_statement', 'children': ['139']}; {'id': '139', 'type': 'call', 'children': ['140', '145']}; {'id': '140', 'type': 'attribute', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'housecanary'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'InvalidInputException'}; {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': '()', 'children': ['147']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'msg'}
Convert input address data into json format
def check_enum(enum, name=None, valid=None): name = name or 'enum' res = None if isinstance(enum, int): if hasattr(enum, 'name') and enum.name.startswith('GL_'): res = enum.name[3:].lower() elif isinstance(enum, string_types): res = enum.lower() if res is None: raise ValueError('Could not determine string represenatation for' 'enum %r' % enum) elif valid and res not in valid: raise ValueError('Value of %s must be one of %r, not %r' % (name, valid, enum)) return res
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_enum'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'enum'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'valid'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '18', '22', '74', '105']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '15', 'type': 'boolean_operator', 'children': ['16', '17'], 'value': 'or'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'enum'"}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'if_statement', 'children': ['23', '28', '59']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'enum'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'if_statement', 'children': ['30', '44']}; {'id': '30', 'type': 'boolean_operator', 'children': ['31', '36'], 'value': 'and'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'enum'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'name'"}; {'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': 'enum'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'GL_'"}; {'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': 'res'}; {'id': '48', 'type': 'call', 'children': ['49', '58']}; {'id': '49', 'type': 'attribute', 'children': ['50', '57']}; {'id': '50', 'type': 'subscript', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'enum'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '54', 'type': 'slice', 'children': ['55', '56']}; {'id': '55', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '56', 'type': 'colon', 'children': []}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '58', 'type': 'argument_list', 'children': []}; {'id': '59', 'type': 'elif_clause', 'children': ['60', '65']}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'enum'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'string_types'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'enum'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '73', 'type': 'argument_list', 'children': []}; {'id': '74', 'type': 'if_statement', 'children': ['75', '78', '88']}; {'id': '75', 'type': 'comparison_operator', 'children': ['76', '77'], 'value': 'is'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '77', 'type': 'None', 'children': []}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'raise_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'binary_operator', 'children': ['84', '87'], 'value': '%'}; {'id': '84', 'type': 'concatenated_string', 'children': ['85', '86']}; {'id': '85', 'type': 'string', 'children': [], 'value': "'Could not determine string represenatation for'"}; {'id': '86', 'type': 'string', 'children': [], 'value': "'enum %r'"}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'enum'}; {'id': '88', 'type': 'elif_clause', 'children': ['89', '94']}; {'id': '89', 'type': 'boolean_operator', 'children': ['90', '91'], 'value': 'and'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'valid'}; {'id': '91', 'type': 'comparison_operator', 'children': ['92', '93'], 'value': 'not in'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'valid'}; {'id': '94', 'type': 'block', 'children': ['95']}; {'id': '95', 'type': 'raise_statement', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'binary_operator', 'children': ['100', '101'], 'value': '%'}; {'id': '100', 'type': 'string', 'children': [], 'value': "'Value of %s must be one of %r, not %r'"}; {'id': '101', 'type': 'tuple', 'children': ['102', '103', '104']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'valid'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'enum'}; {'id': '105', 'type': 'return_statement', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'res'}
Get lowercase string representation of enum.
def callback_result(self): if self._state == self._PENDING: self._loop.run_until_complete(self) if self._callbacks: result = self._callback_result else: result = self.result() return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'callback_result'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '24', '45']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '14']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': '=='}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_state'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_PENDING'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_loop'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'run_until_complete'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '28', '35']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_callbacks'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_callback_result'}; {'id': '35', 'type': 'else_clause', 'children': ['36']}; {'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': 'result'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'result'}
Blocking until the task finish and return the callback_result.until
def execute(self): self._collect_garbage() upstream_channels = {} for node in nx.topological_sort(self.logical_topo): operator = self.operators[node] downstream_channels = self._generate_channels(operator) handles = self.__generate_actors(operator, upstream_channels, downstream_channels) if handles: self.actor_handles.extend(handles) upstream_channels.update(downstream_channels) logger.debug("Running...") return self.actor_handles
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execute'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '16', '74', '81']}; {'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': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_collect_garbage'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'upstream_channels'}; {'id': '15', 'type': 'dictionary', 'children': []}; {'id': '16', 'type': 'for_statement', 'children': ['17', '18', '26']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'nx'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'topological_sort'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'logical_topo'}; {'id': '26', 'type': 'block', 'children': ['27', '35', '44', '55', '67']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '30', 'type': 'subscript', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'operators'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'downstream_channels'}; {'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': '_generate_channels'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'handles'}; {'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': '__generate_actors'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53', '54']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'upstream_channels'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'downstream_channels'}; {'id': '55', 'type': 'if_statement', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'handles'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '65']}; {'id': '60', 'type': 'attribute', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'actor_handles'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'handles'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'upstream_channels'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'downstream_channels'}; {'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': 'logger'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'string', 'children': [], 'value': '"Running..."'}; {'id': '81', 'type': 'return_statement', 'children': ['82']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'actor_handles'}
Deploys and executes the physical dataflow.
def template_to_base_path(template, google_songs): if template == os.getcwd() or template == '%suggested%': base_path = os.getcwd() else: template = os.path.abspath(template) song_paths = [template_to_filepath(template, song) for song in google_songs] base_path = os.path.dirname(os.path.commonprefix(song_paths)) return base_path
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'template_to_base_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'google_songs'}; {'id': '6', 'type': 'block', 'children': ['7', '71']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '19', '28']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '16'], 'value': 'or'}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': '=='}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'getcwd'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': '=='}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'%suggested%'"}; {'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': 'base_path'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'getcwd'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'else_clause', 'children': ['29']}; {'id': '29', 'type': 'block', 'children': ['30', '41', '53']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '33', 'type': 'call', 'children': ['34', '39']}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'song_paths'}; {'id': '44', 'type': 'list_comprehension', 'children': ['45', '50']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'template_to_filepath'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'song'}; {'id': '50', 'type': 'for_in_clause', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'song'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'google_songs'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'base_path'}; {'id': '56', 'type': 'call', 'children': ['57', '62']}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '69']}; {'id': '64', 'type': 'attribute', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'commonprefix'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'song_paths'}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'base_path'}
Get base output path for a list of songs for download.
def fingerprint_from_var(var): vsn = gpg_version() cmd = flatten([gnupg_bin(), gnupg_home()]) if vsn[0] >= 2 and vsn[1] < 1: cmd.append("--with-fingerprint") output = polite_string(stderr_with_input(cmd, var)).split('\n') if not output[0].startswith('pub'): raise CryptoritoError('probably an invalid gpg key') if vsn[0] >= 2 and vsn[1] < 1: return output[1] \ .split('=')[1] \ .replace(' ', '') return output[1].strip()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fingerprint_from_var'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '25', '45', '61', '77', '109']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'vsn'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'gpg_version'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'flatten'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'list', 'children': ['19', '22'], 'value': '[gnupg_bin(), gnupg_home()]'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'gnupg_bin'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'gnupg_home'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'if_statement', 'children': ['26', '37']}; {'id': '26', 'type': 'boolean_operator', 'children': ['27', '32'], 'value': 'and'}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '31'], 'value': '>='}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'vsn'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '36'], 'value': '<'}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'vsn'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'string', 'children': [], 'value': '"--with-fingerprint"'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '48', 'type': 'call', 'children': ['49', '59']}; {'id': '49', 'type': 'attribute', 'children': ['50', '58']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'polite_string'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'stderr_with_input'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '61', 'type': 'if_statement', 'children': ['62', '71']}; {'id': '62', 'type': 'not_operator', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '69']}; {'id': '64', 'type': 'attribute', 'children': ['65', '68']}; {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'pub'"}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'raise_statement', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'CryptoritoError'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'string', 'children': [], 'value': "'probably an invalid gpg key'"}; {'id': '77', 'type': 'if_statement', 'children': ['78', '89']}; {'id': '78', 'type': 'boolean_operator', 'children': ['79', '84'], 'value': 'and'}; {'id': '79', 'type': 'comparison_operator', 'children': ['80', '83'], 'value': '>='}; {'id': '80', 'type': 'subscript', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'vsn'}; {'id': '82', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '83', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '84', 'type': 'comparison_operator', 'children': ['85', '88'], 'value': '<'}; {'id': '85', 'type': 'subscript', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'vsn'}; {'id': '87', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '88', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'return_statement', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '106']}; {'id': '92', 'type': 'attribute', 'children': ['93', '104', '105']}; {'id': '93', 'type': 'subscript', 'children': ['94', '103']}; {'id': '94', 'type': 'call', 'children': ['95', '101']}; {'id': '95', 'type': 'attribute', 'children': ['96', '99', '100']}; {'id': '96', 'type': 'subscript', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '98', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '99', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'string', 'children': [], 'value': "'='"}; {'id': '103', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '104', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '106', 'type': 'argument_list', 'children': ['107', '108']}; {'id': '107', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '108', 'type': 'string', 'children': [], 'value': "''"}; {'id': '109', 'type': 'return_statement', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '116']}; {'id': '111', 'type': 'attribute', 'children': ['112', '115']}; {'id': '112', 'type': 'subscript', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '114', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '116', 'type': 'argument_list', 'children': []}
Extract a fingerprint from a GPG public key
def humanize_hours(total_hours, frmt='{hours:02d}:{minutes:02d}:{seconds:02d}', negative_frmt=None): seconds = int(float(total_hours) * 3600) return humanize_seconds(seconds, frmt, negative_frmt)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'humanize_hours'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'total_hours'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'frmt'}; {'id': '7', 'type': 'string', 'children': [], 'value': "'{hours:02d}:{minutes:02d}:{seconds:02d}'"}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'negative_frmt'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '24']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '23'], 'value': '*'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'total_hours'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '3600'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'humanize_seconds'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'frmt'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'negative_frmt'}
Given time in hours, return a string representing the time.
def _update_axes(ax, xincrease, yincrease, xscale=None, yscale=None, xticks=None, yticks=None, xlim=None, ylim=None): if xincrease is None: pass elif xincrease and ax.xaxis_inverted(): ax.invert_xaxis() elif not xincrease and not ax.xaxis_inverted(): ax.invert_xaxis() if yincrease is None: pass elif yincrease and ax.yaxis_inverted(): ax.invert_yaxis() elif not yincrease and not ax.yaxis_inverted(): ax.invert_yaxis() if xscale is not None: ax.set_xscale(xscale) if yscale is not None: ax.set_yscale(yscale) if xticks is not None: ax.set_xticks(xticks) if yticks is not None: ax.set_yticks(yticks) if xlim is not None: ax.set_xlim(xlim) if ylim is not None: ax.set_ylim(ylim)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '25']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_axes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '19', '22']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'xincrease'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'yincrease'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'xscale'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'yscale'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'xticks'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'default_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'yticks'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'default_parameter', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'xlim'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'default_parameter', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ylim'}; {'id': '24', 'type': 'None', 'children': []}; {'id': '25', 'type': 'block', 'children': ['26', '64', '102', '114', '126', '138', '150', '162']}; {'id': '26', 'type': 'if_statement', 'children': ['27', '30', '32', '47']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'is'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'xincrease'}; {'id': '29', 'type': 'None', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'pass_statement', 'children': []}; {'id': '32', 'type': 'elif_clause', 'children': ['33', '40']}; {'id': '33', 'type': 'boolean_operator', 'children': ['34', '35'], 'value': 'and'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'xincrease'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'xaxis_inverted'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'invert_xaxis'}; {'id': '46', 'type': 'argument_list', 'children': []}; {'id': '47', 'type': 'elif_clause', 'children': ['48', '57']}; {'id': '48', 'type': 'boolean_operator', 'children': ['49', '51'], 'value': 'and'}; {'id': '49', 'type': 'not_operator', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'xincrease'}; {'id': '51', 'type': 'not_operator', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'xaxis_inverted'}; {'id': '56', 'type': 'argument_list', 'children': []}; {'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': 'ax'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'invert_xaxis'}; {'id': '63', 'type': 'argument_list', 'children': []}; {'id': '64', 'type': 'if_statement', 'children': ['65', '68', '70', '85']}; {'id': '65', 'type': 'comparison_operator', 'children': ['66', '67'], 'value': 'is'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'yincrease'}; {'id': '67', 'type': 'None', 'children': []}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'pass_statement', 'children': []}; {'id': '70', 'type': 'elif_clause', 'children': ['71', '78']}; {'id': '71', 'type': 'boolean_operator', 'children': ['72', '73'], 'value': 'and'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'yincrease'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'yaxis_inverted'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'invert_yaxis'}; {'id': '84', 'type': 'argument_list', 'children': []}; {'id': '85', 'type': 'elif_clause', 'children': ['86', '95']}; {'id': '86', 'type': 'boolean_operator', 'children': ['87', '89'], 'value': 'and'}; {'id': '87', 'type': 'not_operator', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'yincrease'}; {'id': '89', 'type': 'not_operator', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'yaxis_inverted'}; {'id': '94', 'type': 'argument_list', 'children': []}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'invert_yaxis'}; {'id': '101', 'type': 'argument_list', 'children': []}; {'id': '102', 'type': 'if_statement', 'children': ['103', '106']}; {'id': '103', 'type': 'comparison_operator', 'children': ['104', '105'], 'value': 'is not'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'xscale'}; {'id': '105', 'type': 'None', 'children': []}; {'id': '106', 'type': 'block', 'children': ['107']}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'set_xscale'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'xscale'}; {'id': '114', 'type': 'if_statement', 'children': ['115', '118']}; {'id': '115', 'type': 'comparison_operator', 'children': ['116', '117'], 'value': 'is not'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'yscale'}; {'id': '117', 'type': 'None', 'children': []}; {'id': '118', 'type': 'block', 'children': ['119']}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'set_yscale'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'yscale'}; {'id': '126', 'type': 'if_statement', 'children': ['127', '130']}; {'id': '127', 'type': 'comparison_operator', 'children': ['128', '129'], 'value': 'is not'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'xticks'}; {'id': '129', 'type': 'None', 'children': []}; {'id': '130', 'type': 'block', 'children': ['131']}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'call', 'children': ['133', '136']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'set_xticks'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'xticks'}; {'id': '138', 'type': 'if_statement', 'children': ['139', '142']}; {'id': '139', 'type': 'comparison_operator', 'children': ['140', '141'], 'value': 'is not'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'yticks'}; {'id': '141', 'type': 'None', 'children': []}; {'id': '142', 'type': 'block', 'children': ['143']}; {'id': '143', 'type': 'expression_statement', 'children': ['144']}; {'id': '144', 'type': 'call', 'children': ['145', '148']}; {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'set_yticks'}; {'id': '148', 'type': 'argument_list', 'children': ['149']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'yticks'}; {'id': '150', 'type': 'if_statement', 'children': ['151', '154']}; {'id': '151', 'type': 'comparison_operator', 'children': ['152', '153'], 'value': 'is not'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'xlim'}; {'id': '153', 'type': 'None', 'children': []}; {'id': '154', 'type': 'block', 'children': ['155']}; {'id': '155', 'type': 'expression_statement', 'children': ['156']}; {'id': '156', 'type': 'call', 'children': ['157', '160']}; {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'set_xlim'}; {'id': '160', 'type': 'argument_list', 'children': ['161']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'xlim'}; {'id': '162', 'type': 'if_statement', 'children': ['163', '166']}; {'id': '163', 'type': 'comparison_operator', 'children': ['164', '165'], 'value': 'is not'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'ylim'}; {'id': '165', 'type': 'None', 'children': []}; {'id': '166', 'type': 'block', 'children': ['167']}; {'id': '167', 'type': 'expression_statement', 'children': ['168']}; {'id': '168', 'type': 'call', 'children': ['169', '172']}; {'id': '169', 'type': 'attribute', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'set_ylim'}; {'id': '172', 'type': 'argument_list', 'children': ['173']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'ylim'}
Update axes with provided parameters
def editor_js_initialization(selector, **extra_settings): init_template = loader.get_template( settings.MARKDOWN_EDITOR_INIT_TEMPLATE) options = dict( previewParserPath=reverse('django_markdown_preview'), **settings.MARKDOWN_EDITOR_SETTINGS) options.update(extra_settings) ctx = dict( selector=selector, extra_settings=simplejson.dumps(options) ) return init_template.render(ctx)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'editor_js_initialization'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'extra_settings'}; {'id': '7', 'type': 'block', 'children': ['8', '19', '35', '42', '59']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'init_template'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'loader'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_template'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'MARKDOWN_EDITOR_INIT_TEMPLATE'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '31']}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'previewParserPath'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'django_markdown_preview'"}; {'id': '31', 'type': 'dictionary_splat', 'children': ['32']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'MARKDOWN_EDITOR_SETTINGS'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'extra_settings'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '51']}; {'id': '48', 'type': 'keyword_argument', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '51', 'type': 'keyword_argument', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'extra_settings'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'simplejson'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'init_template'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'render'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'ctx'}
Return script tag with initialization code.
def serialize_checks(check_set): check_set_list = [] for check in check_set.all()[:25]: check_set_list.append( { 'datetime': check.checked_datetime.isoformat(), 'value': check.response_time, 'success': 1 if check.success else 0 } ) return check_set_list
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'serialize_checks'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'check_set'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '51']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'check_set_list'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '21']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'check'}; {'id': '12', 'type': 'subscript', 'children': ['13', '18']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'check_set'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'slice', 'children': ['19', '20']}; {'id': '19', 'type': 'colon', 'children': []}; {'id': '20', 'type': 'integer', 'children': [], 'value': '25'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'check_set_list'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'dictionary', 'children': ['29', '38', '43']}; {'id': '29', 'type': 'pair', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'datetime'"}; {'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': 'check'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'checked_datetime'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'isoformat'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'pair', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'check'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'response_time'}; {'id': '43', 'type': 'pair', 'children': ['44', '45']}; {'id': '44', 'type': 'string', 'children': [], 'value': "'success'"}; {'id': '45', 'type': 'conditional_expression', 'children': ['46', '47', '50'], 'value': 'if'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'check'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'success'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'check_set_list'}
Serialize a check_set for raphael
def list(self): service = self._service lxc_names = service.list_names() lxc_list = [] for name in lxc_names: lxc = self.get(name) lxc_list.append(lxc) return lxc_list
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '20', '24', '44']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_service'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'lxc_names'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'list_names'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'lxc_list'}; {'id': '23', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '24', 'type': 'for_statement', 'children': ['25', '26', '27']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'lxc_names'}; {'id': '27', 'type': 'block', 'children': ['28', '37']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'lxc'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'lxc_list'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'lxc'}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'lxc_list'}
Get's all of the LXC's and creates objects for them
def monitor(self): while self.monitor_running.is_set(): if time.time() - self.last_flush > self.batch_time: if not self.queue.empty(): logger.info("Queue Flush: time without flush exceeded") self.flush_queue() time.sleep(self.batch_time)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'monitor'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'while_statement', 'children': ['7', '14']}; {'id': '7', 'type': 'call', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'monitor_running'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'is_set'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '53']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '29']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '26'], 'value': '>'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '23'], 'value': '-'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'last_flush'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'batch_time'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'if_statement', 'children': ['31', '39']}; {'id': '31', 'type': 'not_operator', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'empty'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'block', 'children': ['40', '47']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': '"Queue Flush: time without flush exceeded"'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'flush_queue'}; {'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': 'time'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'batch_time'}
Flushes the queue periodically.
def close(self): if VERBOSE: _print_out('\nDummy_serial: Closing port\n') if not self._isOpen: raise IOError('Dummy_serial: The port is already closed') self._isOpen = False self.port = None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '25', '31']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'VERBOSE'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_print_out'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'\\nDummy_serial: Closing port\\n'"}; {'id': '14', 'type': 'if_statement', 'children': ['15', '19']}; {'id': '15', 'type': 'not_operator', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_isOpen'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'raise_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'Dummy_serial: The port is already closed'"}; {'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': '_isOpen'}; {'id': '30', 'type': 'False', 'children': []}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '36', 'type': 'None', 'children': []}
Close a port on dummy_serial.
def _post_build(self, module, encoding): module.file_encoding = encoding self._manager.cache_module(module) for from_node in module._import_from_nodes: if from_node.modname == "__future__": for symbol, _ in from_node.names: module.future_imports.add(symbol) self.add_from_names_to_locals(from_node) for delayed in module._delayed_assattr: self.delayed_assattr(delayed) if self._apply_transforms: module = self._manager.visit_transforms(module) return module
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_post_build'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '7', 'type': 'block', 'children': ['8', '14', '23', '60', '73', '89']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'file_encoding'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '21']}; {'id': '16', 'type': 'attribute', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_manager'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'cache_module'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '23', 'type': 'for_statement', 'children': ['24', '25', '28']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'from_node'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_import_from_nodes'}; {'id': '28', 'type': 'block', 'children': ['29', '53']}; {'id': '29', 'type': 'if_statement', 'children': ['30', '35']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '34'], 'value': '=='}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'from_node'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'modname'}; {'id': '34', 'type': 'string', 'children': [], 'value': '"__future__"'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'for_statement', 'children': ['37', '40', '43']}; {'id': '37', 'type': 'pattern_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'from_node'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '51']}; {'id': '46', 'type': 'attribute', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'future_imports'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'add_from_names_to_locals'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'from_node'}; {'id': '60', 'type': 'for_statement', 'children': ['61', '62', '65']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'delayed'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '_delayed_assattr'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'delayed_assattr'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'delayed'}; {'id': '73', 'type': 'if_statement', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': '_apply_transforms'}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'module'}; {'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': '_manager'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'visit_transforms'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '89', 'type': 'return_statement', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'module'}
Handles encoding and delayed nodes after a module has been built
def _get_data_from_list_of_lists(source, fields='*', first_row=0, count=-1, schema=None): if schema is None: schema = google.datalab.bigquery.Schema.from_data(source) fields = get_field_list(fields, schema) gen = source[first_row:first_row + count] if count >= 0 else source cols = [schema.find(name) for name in fields] rows = [{'c': [{'v': row[i]} for i in cols]} for row in gen] return {'cols': _get_cols(fields, schema), 'rows': rows}, len(source)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_data_from_list_of_lists'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '15']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '7', 'type': 'string', 'children': [], 'value': "'*'"}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'first_row'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '13', 'type': 'unary_operator', 'children': ['14'], 'value': '-'}; {'id': '14', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19', '39', '47', '63', '76', '96']}; {'id': '19', 'type': 'if_statement', 'children': ['20', '23']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': 'is'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '22', 'type': 'None', 'children': []}; {'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': 'schema'}; {'id': '27', 'type': 'call', 'children': ['28', '37']}; {'id': '28', 'type': 'attribute', 'children': ['29', '36']}; {'id': '29', 'type': 'attribute', 'children': ['30', '35']}; {'id': '30', 'type': 'attribute', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'google'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'datalab'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'bigquery'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'Schema'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'from_data'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'get_field_list'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'gen'}; {'id': '50', 'type': 'conditional_expression', 'children': ['51', '59', '62'], 'value': 'if'}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '53', 'type': 'slice', 'children': ['54', '55', '56']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'first_row'}; {'id': '55', 'type': 'colon', 'children': []}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '58'], 'value': '+'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'first_row'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '61'], 'value': '>='}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'cols'}; {'id': '66', 'type': 'list_comprehension', 'children': ['67', '73']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '73', 'type': 'for_in_clause', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '79', 'type': 'list_comprehension', 'children': ['80', '93']}; {'id': '80', 'type': 'dictionary', 'children': ['81']}; {'id': '81', 'type': 'pair', 'children': ['82', '83']}; {'id': '82', 'type': 'string', 'children': [], 'value': "'c'"}; {'id': '83', 'type': 'list_comprehension', 'children': ['84', '90']}; {'id': '84', 'type': 'dictionary', 'children': ['85']}; {'id': '85', 'type': 'pair', 'children': ['86', '87']}; {'id': '86', 'type': 'string', 'children': [], 'value': "'v'"}; {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '90', 'type': 'for_in_clause', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'cols'}; {'id': '93', 'type': 'for_in_clause', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'gen'}; {'id': '96', 'type': 'return_statement', 'children': ['97']}; {'id': '97', 'type': 'expression_list', 'children': ['98', '109']}; {'id': '98', 'type': 'dictionary', 'children': ['99', '106']}; {'id': '99', 'type': 'pair', 'children': ['100', '101']}; {'id': '100', 'type': 'string', 'children': [], 'value': "'cols'"}; {'id': '101', 'type': 'call', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': '_get_cols'}; {'id': '103', 'type': 'argument_list', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '106', 'type': 'pair', 'children': ['107', '108']}; {'id': '107', 'type': 'string', 'children': [], 'value': "'rows'"}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '109', 'type': 'call', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'source'}
Helper function for _get_data that handles lists of lists.
def _match_magic(self, full_path): for magic in self.magics: if magic.matches(full_path): return magic
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_match_magic'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'full_path'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '9', '12']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'magic'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'magics'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '20']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'magic'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'matches'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'full_path'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'magic'}
Return the first magic that matches this path or None.
def import_graph(self, t_input=None, scope='import', forget_xy_shape=True): graph = tf.get_default_graph() assert graph.unique_name(scope, False) == scope, ( 'Scope "%s" already exists. Provide explicit scope names when ' 'importing multiple instances of the model.') % scope t_input, t_prep_input = self.create_input(t_input, forget_xy_shape) tf.import_graph_def( self.graph_def, {self.input_name: t_prep_input}, name=scope) self.post_import(scope)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'import_graph'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 't_input'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '10', 'type': 'string', 'children': [], 'value': "'import'"}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'forget_xy_shape'}; {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '23', '39', '51', '69']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'graph'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'get_default_graph'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'assert_statement', 'children': ['24', '33']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '32'], 'value': '=='}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'graph'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'unique_name'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '31', 'type': 'False', 'children': []}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '38'], 'value': '%'}; {'id': '34', 'type': '()', 'children': ['35']}; {'id': '35', 'type': 'concatenated_string', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': '\'Scope "%s" already exists. Provide explicit scope names when \''}; {'id': '37', 'type': 'string', 'children': [], 'value': "'importing multiple instances of the model.'"}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '44']}; {'id': '41', 'type': 'pattern_list', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 't_input'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 't_prep_input'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'create_input'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 't_input'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'forget_xy_shape'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'import_graph_def'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '60', '66']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'graph_def'}; {'id': '60', 'type': 'dictionary', 'children': ['61']}; {'id': '61', 'type': 'pair', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'input_name'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 't_prep_input'}; {'id': '66', 'type': 'keyword_argument', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'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': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'post_import'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'scope'}
Import model GraphDef into the current graph.
def _is_reference(arg): return isinstance(arg, dict) and len(arg) == 1 and isinstance(next(six.itervalues(arg)), six.string_types)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_is_reference'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '20'], 'value': 'and'}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '14'], 'value': 'and'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '19'], 'value': '=='}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '32']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'next'}; {'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': 'six'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'itervalues'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'string_types'}
Return True, if arg is a reference to a previously defined statement.
def action(arguments): source_format = (arguments.source_format or fileformat.from_handle(arguments.source_file)) output_format = (arguments.output_format or fileformat.from_handle(arguments.output_file)) with arguments.source_file: sequences = SeqIO.parse( arguments.source_file, source_format, alphabet=Alphabet.Gapped(Alphabet.single_letter_alphabet)) (forward_start, forward_end), (reverse_start, reverse_end) = locate_primers( sequences, arguments.forward_primer, arguments.reverse_primer, arguments.reverse_complement, arguments.max_hamming_distance) if arguments.include_primers: start = forward_start end = reverse_end + 1 else: start = forward_end + 1 end = reverse_start arguments.source_file.seek(0) sequences = SeqIO.parse( arguments.source_file, source_format, alphabet=Alphabet.Gapped(Alphabet.single_letter_alphabet)) prune_action = _ACTIONS[arguments.prune_action] transformed_sequences = prune_action(sequences, start, end) with arguments.output_file: SeqIO.write(transformed_sequences, arguments.output_file, output_format)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'action'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '5', 'type': 'block', 'children': ['6', '22', '38']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'source_format'}; {'id': '9', 'type': '()', 'children': ['10']}; {'id': '10', 'type': 'boolean_operator', 'children': ['11', '14'], 'value': 'or'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'source_format'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'fileformat'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'from_handle'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'source_file'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'output_format'}; {'id': '25', 'type': '()', 'children': ['26']}; {'id': '26', 'type': 'boolean_operator', 'children': ['27', '30'], 'value': 'or'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'output_format'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'fileformat'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'from_handle'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'output_file'}; {'id': '38', 'type': 'with_statement', 'children': ['39', '44']}; {'id': '39', 'type': 'with_clause', 'children': ['40']}; {'id': '40', 'type': 'with_item', 'children': ['41']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'source_file'}; {'id': '44', 'type': 'block', 'children': ['45', '67', '92', '119', '128', '150', '158', '167']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'sequences'}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'SeqIO'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'parse'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '56', '57']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'source_file'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'source_format'}; {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'alphabet'}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'Alphabet'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'Gapped'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'Alphabet'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'single_letter_alphabet'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '76']}; {'id': '69', 'type': 'pattern_list', 'children': ['70', '73']}; {'id': '70', 'type': 'tuple_pattern', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'forward_start'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'forward_end'}; {'id': '73', 'type': 'tuple_pattern', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'reverse_start'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'reverse_end'}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'locate_primers'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80', '83', '86', '89']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'sequences'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'forward_primer'}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'reverse_primer'}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'reverse_complement'}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'max_hamming_distance'}; {'id': '92', 'type': 'if_statement', 'children': ['93', '96', '107']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'include_primers'}; {'id': '96', 'type': 'block', 'children': ['97', '101']}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'forward_start'}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '104', 'type': 'binary_operator', 'children': ['105', '106'], 'value': '+'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'reverse_end'}; {'id': '106', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '107', 'type': 'else_clause', 'children': ['108']}; {'id': '108', 'type': 'block', 'children': ['109', '115']}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '112', 'type': 'binary_operator', 'children': ['113', '114'], 'value': '+'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'forward_end'}; {'id': '114', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'assignment', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'reverse_start'}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '126']}; {'id': '121', 'type': 'attribute', 'children': ['122', '125']}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'source_file'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'seek'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}; {'id': '129', 'type': 'assignment', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'sequences'}; {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'SeqIO'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'parse'}; {'id': '135', 'type': 'argument_list', 'children': ['136', '139', '140']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'source_file'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'source_format'}; {'id': '140', 'type': 'keyword_argument', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'alphabet'}; {'id': '142', 'type': 'call', 'children': ['143', '146']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'Alphabet'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'Gapped'}; {'id': '146', 'type': 'argument_list', 'children': ['147']}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'Alphabet'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'single_letter_alphabet'}; {'id': '150', 'type': 'expression_statement', 'children': ['151']}; {'id': '151', 'type': 'assignment', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'prune_action'}; {'id': '153', 'type': 'subscript', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': '_ACTIONS'}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'prune_action'}; {'id': '158', 'type': 'expression_statement', 'children': ['159']}; {'id': '159', 'type': 'assignment', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'transformed_sequences'}; {'id': '161', 'type': 'call', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'prune_action'}; {'id': '163', 'type': 'argument_list', 'children': ['164', '165', '166']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'sequences'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '167', 'type': 'with_statement', 'children': ['168', '173']}; {'id': '168', 'type': 'with_clause', 'children': ['169']}; {'id': '169', 'type': 'with_item', 'children': ['170']}; {'id': '170', 'type': 'attribute', 'children': ['171', '172']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'output_file'}; {'id': '173', 'type': 'block', 'children': ['174']}; {'id': '174', 'type': 'expression_statement', 'children': ['175']}; {'id': '175', 'type': 'call', 'children': ['176', '179']}; {'id': '176', 'type': 'attribute', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'SeqIO'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '179', 'type': 'argument_list', 'children': ['180', '181', '184']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'transformed_sequences'}; {'id': '181', 'type': 'attribute', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'output_file'}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'output_format'}
Trim the alignment as specified
def parse_buffer_to_jpeg(data): return [ Image.open(BytesIO(image_data + b'\xff\xd9')) for image_data in data.split(b'\xff\xd9')[:-1] ]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_buffer_to_jpeg'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'list_comprehension', 'children': ['8', '19']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Image'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'BytesIO'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '18'], 'value': '+'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'image_data'}; {'id': '18', 'type': 'string', 'children': [], 'value': "b'\\xff\\xd9'"}; {'id': '19', 'type': 'for_in_clause', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'image_data'}; {'id': '21', 'type': 'subscript', 'children': ['22', '28']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': "b'\\xff\\xd9'"}; {'id': '28', 'type': 'slice', 'children': ['29', '30']}; {'id': '29', 'type': 'colon', 'children': []}; {'id': '30', 'type': 'unary_operator', 'children': ['31'], 'value': '-'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '1'}
Parse JPEG file bytes to Pillow Image
def load_vstr(buf, pos): slen, pos = load_vint(buf, pos) return load_bytes(buf, slen, pos)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_vstr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '6', 'type': 'block', 'children': ['7', '17']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '12']}; {'id': '9', 'type': 'pattern_list', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'slen'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'load_vint'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'load_bytes'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22', '23']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'slen'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pos'}
Load bytes prefixed by vint length
def check_config(config): url = config.get("Server", "url") try: urlopen(url) except Exception as e: logger.error( "The configured OpenSubmit server URL ({0}) seems to be invalid: {1}".format(url, e)) return False targetdir = config.get("Execution", "directory") if platform.system() is not "Windows" and not targetdir.startswith("/"): logger.error( "Please use absolute paths, starting with a /, in your Execution-directory setting.") return False if not targetdir.endswith(os.sep): logger.error( "Your Execution-directory setting must end with a " + os.sep) return False return True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_config'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '44', '54', '80', '104']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"Server"'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"url"'}; {'id': '16', 'type': 'try_statement', 'children': ['17', '23']}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'urlopen'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '23', 'type': 'except_clause', 'children': ['24', '28']}; {'id': '24', 'type': 'as_pattern', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '26', 'type': 'as_pattern_target', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '28', 'type': 'block', 'children': ['29', '42']}; {'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': 'logger'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"The configured OpenSubmit server URL ({0}) seems to be invalid: {1}"'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'False', 'children': []}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'targetdir'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'string', 'children': [], 'value': '"Execution"'}; {'id': '53', 'type': 'string', 'children': [], 'value': '"directory"'}; {'id': '54', 'type': 'if_statement', 'children': ['55', '70']}; {'id': '55', 'type': 'boolean_operator', 'children': ['56', '63'], 'value': 'and'}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '62'], 'value': 'is not'}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'system'}; {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'string', 'children': [], 'value': '"Windows"'}; {'id': '63', 'type': 'not_operator', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'targetdir'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'string', 'children': [], 'value': '"/"'}; {'id': '70', 'type': 'block', 'children': ['71', '78']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'string', 'children': [], 'value': '"Please use absolute paths, starting with a /, in your Execution-directory setting."'}; {'id': '78', 'type': 'return_statement', 'children': ['79']}; {'id': '79', 'type': 'False', 'children': []}; {'id': '80', 'type': 'if_statement', 'children': ['81', '90']}; {'id': '81', 'type': 'not_operator', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'targetdir'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '90', 'type': 'block', 'children': ['91', '102']}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'binary_operator', 'children': ['98', '99'], 'value': '+'}; {'id': '98', 'type': 'string', 'children': [], 'value': '"Your Execution-directory setting must end with a "'}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '102', 'type': 'return_statement', 'children': ['103']}; {'id': '103', 'type': 'False', 'children': []}; {'id': '104', 'type': 'return_statement', 'children': ['105']}; {'id': '105', 'type': 'True', 'children': []}
Check the executor config file for consistency.
def remove_droppable(self, droppable_id): updated_droppables = [] for droppable in self.my_osid_object_form._my_map['droppables']: if droppable['id'] != droppable_id: updated_droppables.append(droppable) self.my_osid_object_form._my_map['droppables'] = updated_droppables
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_droppable'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'droppable_id'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '35']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'updated_droppables'}; {'id': '10', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '11', 'type': 'for_statement', 'children': ['12', '13', '20']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'droppable'}; {'id': '13', 'type': 'subscript', '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': 'my_osid_object_form'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_my_map'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'droppables'"}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'if_statement', 'children': ['22', '27']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '26'], 'value': '!='}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'droppable'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'droppable_id'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'updated_droppables'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'droppable'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '44']}; {'id': '37', 'type': 'subscript', 'children': ['38', '43']}; {'id': '38', 'type': 'attribute', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'my_osid_object_form'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '_my_map'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'droppables'"}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'updated_droppables'}
remove a droppable, given the id
def cmd_devid(self, args): for p in self.mav_param.keys(): if p.startswith('COMPASS_DEV_ID'): mp_util.decode_devid(self.mav_param[p], p) if p.startswith('INS_') and p.endswith('_ID'): mp_util.decode_devid(self.mav_param[p], p)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cmd_devid'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '9', '16']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'p'}; {'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': 'mav_param'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17', '37']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '24']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'COMPASS_DEV_ID'"}; {'id': '24', 'type': 'block', 'children': ['25']}; {'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': 'mp_util'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'decode_devid'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '36']}; {'id': '31', 'type': 'subscript', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'mav_param'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '37', 'type': 'if_statement', 'children': ['38', '51']}; {'id': '38', 'type': 'boolean_operator', 'children': ['39', '45'], 'value': 'and'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'string', 'children': [], 'value': "'INS_'"}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'string', 'children': [], 'value': "'_ID'"}; {'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': 'mp_util'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'decode_devid'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '63']}; {'id': '58', 'type': 'subscript', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'mav_param'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'p'}
decode device IDs from parameters
def webob_to_django_response(webob_response): from django.http import HttpResponse django_response = HttpResponse( webob_response.app_iter, content_type=webob_response.content_type, status=webob_response.status_code, ) for name, value in webob_response.headerlist: django_response[name] = value return django_response
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'webob_to_django_response'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'webob_response'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '31', '45']}; {'id': '6', 'type': 'import_from_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'dotted_name', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'django'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'http'}; {'id': '10', 'type': 'dotted_name', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'HttpResponse'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'django_response'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'HttpResponse'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '21', '26']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'webob_response'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'app_iter'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'content_type'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'webob_response'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'content_type'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'webob_response'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '31', 'type': 'for_statement', 'children': ['32', '35', '38']}; {'id': '32', 'type': 'pattern_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'webob_response'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'headerlist'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '44']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'django_response'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'django_response'}
Returns a django response to the `webob_response`
def correct(self, image, keepSize=False, borderValue=0): image = imread(image) (h, w) = image.shape[:2] mapx, mapy = self.getUndistortRectifyMap(w, h) self.img = cv2.remap(image, mapx, mapy, cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT, borderValue=borderValue ) if not keepSize: xx, yy, ww, hh = self.roi self.img = self.img[yy: yy + hh, xx: xx + ww] return self.img
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'correct'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'keepSize'}; {'id': '8', 'type': 'False', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'borderValue'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '12', 'type': 'block', 'children': ['13', '20', '32', '44', '68', '103']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'imread'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '25']}; {'id': '22', 'type': 'tuple_pattern', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '25', 'type': 'subscript', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '29', 'type': 'slice', 'children': ['30', '31']}; {'id': '30', 'type': 'colon', 'children': []}; {'id': '31', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '37']}; {'id': '34', 'type': 'pattern_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'mapx'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'mapy'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'getUndistortRectifyMap'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'img'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cv2'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'remap'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55', '56', '57', '60', '65']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'mapx'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'mapy'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'cv2'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'INTER_LINEAR'}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'borderMode'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'cv2'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'BORDER_CONSTANT'}; {'id': '65', 'type': 'keyword_argument', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'borderValue'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'borderValue'}; {'id': '68', 'type': 'if_statement', 'children': ['69', '71']}; {'id': '69', 'type': 'not_operator', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'keepSize'}; {'id': '71', 'type': 'block', 'children': ['72', '82']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '79']}; {'id': '74', 'type': 'pattern_list', 'children': ['75', '76', '77', '78']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'xx'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'yy'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'ww'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'hh'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'roi'}; {'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': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'img'}; {'id': '87', 'type': 'subscript', 'children': ['88', '91', '97']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'img'}; {'id': '91', 'type': 'slice', 'children': ['92', '93', '94']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'yy'}; {'id': '93', 'type': 'colon', 'children': []}; {'id': '94', 'type': 'binary_operator', 'children': ['95', '96'], 'value': '+'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'yy'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'hh'}; {'id': '97', 'type': 'slice', 'children': ['98', '99', '100']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'xx'}; {'id': '99', 'type': 'colon', 'children': []}; {'id': '100', 'type': 'binary_operator', 'children': ['101', '102'], 'value': '+'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'xx'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'ww'}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'img'}
remove lens distortion from given image
def update(self): if self.input_method == 'local': if self._thread is None: thread_is_running = False else: thread_is_running = self._thread.isAlive() if self.timer_ports.finished() and not thread_is_running: self._thread = ThreadScanner(self.stats) self._thread.start() if len(self.stats) > 0: self.timer_ports = Timer(self.stats[0]['refresh']) else: self.timer_ports = Timer(0) else: pass return self.stats
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '106']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12', '103']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': '=='}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'input_method'}; {'id': '11', 'type': 'string', 'children': [], 'value': "'local'"}; {'id': '12', 'type': 'block', 'children': ['13', '36']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '19', '24']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '18'], 'value': 'is'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_thread'}; {'id': '18', 'type': 'None', 'children': []}; {'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': 'thread_is_running'}; {'id': '23', 'type': 'False', 'children': []}; {'id': '24', 'type': 'else_clause', 'children': ['25']}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'thread_is_running'}; {'id': '29', 'type': 'call', 'children': ['30', '35']}; {'id': '30', 'type': 'attribute', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_thread'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'isAlive'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'if_statement', 'children': ['37', '47']}; {'id': '37', 'type': 'boolean_operator', 'children': ['38', '45'], 'value': 'and'}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'timer_ports'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'finished'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'not_operator', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'thread_is_running'}; {'id': '47', 'type': 'block', 'children': ['48', '59', '67']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '_thread'}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'ThreadScanner'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '66']}; {'id': '61', 'type': 'attribute', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '_thread'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '66', 'type': 'argument_list', 'children': []}; {'id': '67', 'type': 'if_statement', 'children': ['68', '76', '92']}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '75'], 'value': '>'}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'timer_ports'}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'Timer'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'subscript', 'children': ['86', '91']}; {'id': '86', 'type': 'subscript', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '90', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '91', 'type': 'string', 'children': [], 'value': "'refresh'"}; {'id': '92', 'type': 'else_clause', 'children': ['93']}; {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'timer_ports'}; {'id': '99', 'type': 'call', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'Timer'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '103', 'type': 'else_clause', 'children': ['104']}; {'id': '104', 'type': 'block', 'children': ['105']}; {'id': '105', 'type': 'pass_statement', 'children': []}; {'id': '106', 'type': 'return_statement', 'children': ['107']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'stats'}
Update the ports list.
def create_variable(descriptor): if descriptor['type'] == 'continuous': return ContinuousVariable(descriptor['name'], descriptor['domain'], descriptor.get('dimensionality', 1)) elif descriptor['type'] == 'bandit': return BanditVariable(descriptor['name'], descriptor['domain'], descriptor.get('dimensionality', None)) elif descriptor['type'] == 'discrete': return DiscreteVariable(descriptor['name'], descriptor['domain'], descriptor.get('dimensionality', 1)) elif descriptor['type'] == 'categorical': return CategoricalVariable(descriptor['name'], descriptor['domain'], descriptor.get('dimensionality', 1)) else: raise InvalidConfigError('Unknown variable type ' + descriptor['type'])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_variable'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12', '30', '54', '78', '102']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': '=='}; {'id': '8', 'type': 'subscript', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '10', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '11', 'type': 'string', 'children': [], 'value': "'continuous'"}; {'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': 'ContinuousVariable'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '20', '23']}; {'id': '17', 'type': 'subscript', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'domain'"}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'dimensionality'"}; {'id': '29', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '30', 'type': 'elif_clause', 'children': ['31', '36']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '35'], 'value': '=='}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '35', 'type': 'string', 'children': [], 'value': "'bandit'"}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'BanditVariable'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '44', '47']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'domain'"}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'string', 'children': [], 'value': "'dimensionality'"}; {'id': '53', 'type': 'None', 'children': []}; {'id': '54', 'type': 'elif_clause', 'children': ['55', '60']}; {'id': '55', 'type': 'comparison_operator', 'children': ['56', '59'], 'value': '=='}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '58', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '59', 'type': 'string', 'children': [], 'value': "'discrete'"}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'return_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'DiscreteVariable'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '68', '71']}; {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '68', 'type': 'subscript', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '70', 'type': 'string', 'children': [], 'value': "'domain'"}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '77']}; {'id': '76', 'type': 'string', 'children': [], 'value': "'dimensionality'"}; {'id': '77', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '78', 'type': 'elif_clause', 'children': ['79', '84']}; {'id': '79', 'type': 'comparison_operator', 'children': ['80', '83'], 'value': '=='}; {'id': '80', 'type': 'subscript', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '82', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '83', 'type': 'string', 'children': [], 'value': "'categorical'"}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'return_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'CategoricalVariable'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '92', '95']}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '91', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '92', 'type': 'subscript', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '94', 'type': 'string', 'children': [], 'value': "'domain'"}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '99', 'type': 'argument_list', 'children': ['100', '101']}; {'id': '100', 'type': 'string', 'children': [], 'value': "'dimensionality'"}; {'id': '101', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '102', 'type': 'else_clause', 'children': ['103']}; {'id': '103', 'type': 'block', 'children': ['104']}; {'id': '104', 'type': 'raise_statement', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'InvalidConfigError'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'binary_operator', 'children': ['109', '110'], 'value': '+'}; {'id': '109', 'type': 'string', 'children': [], 'value': "'Unknown variable type '"}; {'id': '110', 'type': 'subscript', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'descriptor'}; {'id': '112', 'type': 'string', 'children': [], 'value': "'type'"}
Creates a variable from a dictionary descriptor
def strip_uri(repo): splits = repo.split() for idx in range(len(splits)): if any(splits[idx].startswith(x) for x in ('http://', 'https://', 'ftp://')): splits[idx] = splits[idx].rstrip('/') return ' '.join(splits)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'strip_uri'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '56']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'splits'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'for_statement', 'children': ['15', '16', '23']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'splits'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'if_statement', 'children': ['25', '42']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '27', 'type': 'generator_expression', 'children': ['28', '36']}; {'id': '28', 'type': 'call', 'children': ['29', '34']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'splits'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '36', 'type': 'for_in_clause', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '38', 'type': 'tuple', 'children': ['39', '40', '41']}; {'id': '39', 'type': 'string', 'children': [], 'value': "'http://'"}; {'id': '40', 'type': 'string', 'children': [], 'value': "'https://'"}; {'id': '41', 'type': 'string', 'children': [], 'value': "'ftp://'"}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '48']}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'splits'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '48', 'type': 'call', 'children': ['49', '54']}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'splits'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'rstrip'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'splits'}
Remove the trailing slash from the URI in a repo definition
def build_ebound_table(self): cols = [ Column(name="E_MIN", dtype=float, data=self._emin, unit='MeV'), Column(name="E_MAX", dtype=float, data=self._emax, unit='MeV'), Column(name="E_REF", dtype=float, data=self._eref, unit='MeV'), Column(name="REF_DNDE", dtype=float, data=self._ref_dnde, unit='ph / (MeV cm2 s)'), Column(name="REF_FLUX", dtype=float, data=self._ref_flux, unit='ph / (cm2 s)'), Column(name="REF_EFLUX", dtype=float, data=self._ref_eflux, unit='MeV / (cm2 s)'), Column(name="REF_NPRED", dtype=float, data=self._ref_npred, unit='ph') ] tab = Table(data=cols) return tab
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_ebound_table'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '129', '138']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'cols'}; {'id': '9', 'type': 'list', 'children': ['10', '27', '44', '61', '78', '95', '112'], 'value': '[\n Column(name="E_MIN", dtype=float, data=self._emin, unit=\'MeV\'),\n Column(name="E_MAX", dtype=float, data=self._emax, unit=\'MeV\'),\n Column(name="E_REF", dtype=float, data=self._eref, unit=\'MeV\'),\n Column(name="REF_DNDE", dtype=float, data=self._ref_dnde,\n unit=\'ph / (MeV cm2 s)\'),\n Column(name="REF_FLUX", dtype=float, data=self._ref_flux,\n unit=\'ph / (cm2 s)\'),\n Column(name="REF_EFLUX", dtype=float, data=self._ref_eflux,\n unit=\'MeV / (cm2 s)\'),\n Column(name="REF_NPRED", dtype=float, data=self._ref_npred,\n unit=\'ph\')\n ]'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'Column'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '16', '19', '24']}; {'id': '13', 'type': 'keyword_argument', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"E_MIN"'}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_emin'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'MeV'"}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Column'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '33', '36', '41']}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '32', 'type': 'string', 'children': [], 'value': '"E_MAX"'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_emax'}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'MeV'"}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'Column'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '50', '53', '58']}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '49', 'type': 'string', 'children': [], 'value': '"E_REF"'}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '_eref'}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '60', 'type': 'string', 'children': [], 'value': "'MeV'"}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'Column'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '67', '70', '75']}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '66', 'type': 'string', 'children': [], 'value': '"REF_DNDE"'}; {'id': '67', 'type': 'keyword_argument', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '70', 'type': 'keyword_argument', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': '_ref_dnde'}; {'id': '75', 'type': 'keyword_argument', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'ph / (MeV cm2 s)'"}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'Column'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '84', '87', '92']}; {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '83', 'type': 'string', 'children': [], 'value': '"REF_FLUX"'}; {'id': '84', 'type': 'keyword_argument', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '87', 'type': 'keyword_argument', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': '_ref_flux'}; {'id': '92', 'type': 'keyword_argument', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '94', 'type': 'string', 'children': [], 'value': "'ph / (cm2 s)'"}; {'id': '95', 'type': 'call', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'Column'}; {'id': '97', 'type': 'argument_list', 'children': ['98', '101', '104', '109']}; {'id': '98', 'type': 'keyword_argument', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '100', 'type': 'string', 'children': [], 'value': '"REF_EFLUX"'}; {'id': '101', 'type': 'keyword_argument', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '104', 'type': 'keyword_argument', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': '_ref_eflux'}; {'id': '109', 'type': 'keyword_argument', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '111', 'type': 'string', 'children': [], 'value': "'MeV / (cm2 s)'"}; {'id': '112', 'type': 'call', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'Column'}; {'id': '114', 'type': 'argument_list', 'children': ['115', '118', '121', '126']}; {'id': '115', 'type': 'keyword_argument', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '117', 'type': 'string', 'children': [], 'value': '"REF_NPRED"'}; {'id': '118', 'type': 'keyword_argument', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '121', 'type': 'keyword_argument', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': '_ref_npred'}; {'id': '126', 'type': 'keyword_argument', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '128', 'type': 'string', 'children': [], 'value': "'ph'"}; {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'assignment', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'tab'}; {'id': '132', 'type': 'call', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'Table'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}; {'id': '135', 'type': 'keyword_argument', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'cols'}; {'id': '138', 'type': 'return_statement', 'children': ['139']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'tab'}
Build and return an EBOUNDS table with the encapsulated data.
def connections(self): conn = lambda x: str(x).replace('connection:', '') return [conn(name) for name in self.sections()]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connections'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '22']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '9', 'type': 'lambda', 'children': ['10', '12']}; {'id': '10', 'type': 'lambda_parameters', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '12', 'type': 'call', 'children': ['13', '19']}; {'id': '13', 'type': 'attribute', 'children': ['14', '18']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'connection:'"}; {'id': '21', 'type': 'string', 'children': [], 'value': "''"}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'list_comprehension', 'children': ['24', '28']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '28', 'type': 'for_in_clause', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'sections'}; {'id': '34', 'type': 'argument_list', 'children': []}
Returns all of the loaded connections names as a list
def _CreateSingleValueCondition(self, value, operator): if isinstance(value, str) or isinstance(value, unicode): value = '"%s"' % value return '%s %s %s' % (self._field, operator, value)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_CreateSingleValueCondition'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '7', 'type': 'block', 'children': ['8', '27']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '20']}; {'id': '9', 'type': 'boolean_operator', 'children': ['10', '15'], 'value': 'or'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'unicode'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '26'], 'value': '%'}; {'id': '25', 'type': 'string', 'children': [], 'value': '\'"%s"\''}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '30'], 'value': '%'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'%s %s %s'"}; {'id': '30', 'type': 'tuple', 'children': ['31', '34', '35']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_field'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'value'}
Creates a single-value condition with the provided value and operator.
def column(m, linkpart): assert linkpart in (0, 1, 2, 3) seen = set() for link in m.match(): val = link[linkpart] if val not in seen: seen.add(val) yield val
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'column'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'linkpart'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '21']}; {'id': '7', 'type': 'assert_statement', 'children': ['8']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'in'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'linkpart'}; {'id': '10', 'type': 'tuple', 'children': ['11', '12', '13', '14']}; {'id': '11', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '14', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'seen'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'for_statement', 'children': ['22', '23', '28']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'block', 'children': ['29', '35']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'linkpart'}; {'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': 'val'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'seen'}; {'id': '39', 'type': 'block', 'children': ['40', '47']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'seen'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'yield', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'val'}
Generate all parts of links according to the parameter
def _query(self, cmd, *datas): cmd = Command(query=cmd) return cmd.query(self._transport, self._protocol, *datas)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_query'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '6', 'type': 'list_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'datas'}; {'id': '8', 'type': 'block', 'children': ['9', '18']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'Command'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '27', '30']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_transport'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_protocol'}; {'id': '30', 'type': 'list_splat', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'datas'}
Helper function to allow method queries.
def clean_aliases(ctx, force_yes): inactive_aliases = [] for (alias, mapping) in six.iteritems(aliases_database): if mapping.mapping is None: continue project = ctx.obj['projects_db'].get(mapping.mapping[0], mapping.backend) if (project is None or not project.is_active() or (mapping.mapping[1] is not None and project.get_activity(mapping.mapping[1]) is None)): inactive_aliases.append(((alias, mapping), project)) if not inactive_aliases: ctx.obj['view'].msg("No inactive aliases found.") return if not force_yes: confirm = ctx.obj['view'].clean_inactive_aliases(inactive_aliases) if force_yes or confirm: ctx.obj['settings'].remove_aliases( [item[0] for item in inactive_aliases] ) ctx.obj['settings'].write_config() ctx.obj['view'].msg("%d inactive aliases have been successfully" " cleaned." % len(inactive_aliases))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clean_aliases'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'force_yes'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '96', '112', '129']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'inactive_aliases'}; {'id': '10', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '11', 'type': 'for_statement', 'children': ['12', '15', '21']}; {'id': '12', 'type': 'tuple_pattern', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'alias'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'aliases_database'}; {'id': '21', 'type': 'block', 'children': ['22', '30', '50']}; {'id': '22', 'type': 'if_statement', 'children': ['23', '28']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '27'], 'value': 'is'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'continue_statement', 'children': []}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '33', 'type': 'call', 'children': ['34', '41']}; {'id': '34', 'type': 'attribute', 'children': ['35', '40']}; {'id': '35', 'type': 'subscript', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'projects_db'"}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '47']}; {'id': '42', 'type': 'subscript', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'backend'}; {'id': '50', 'type': 'if_statement', 'children': ['51', '84']}; {'id': '51', 'type': '()', 'children': ['52']}; {'id': '52', 'type': 'boolean_operator', 'children': ['53', '63'], 'value': 'or'}; {'id': '53', 'type': 'boolean_operator', 'children': ['54', '57'], 'value': 'or'}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '56'], 'value': 'is'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '56', 'type': 'None', 'children': []}; {'id': '57', 'type': 'not_operator', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'is_active'}; {'id': '62', 'type': 'argument_list', 'children': []}; {'id': '63', 'type': '()', 'children': ['64']}; {'id': '64', 'type': 'boolean_operator', 'children': ['65', '72'], 'value': 'and'}; {'id': '65', 'type': 'comparison_operator', 'children': ['66', '71'], 'value': 'is not'}; {'id': '66', 'type': 'subscript', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '70', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '71', 'type': 'None', 'children': []}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '83'], 'value': 'is'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'get_activity'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'subscript', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '82', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '83', 'type': 'None', 'children': []}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'inactive_aliases'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'tuple', 'children': ['92', '95']}; {'id': '92', 'type': 'tuple', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'alias'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '96', 'type': 'if_statement', 'children': ['97', '99']}; {'id': '97', 'type': 'not_operator', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'inactive_aliases'}; {'id': '99', 'type': 'block', 'children': ['100', '111']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '109']}; {'id': '102', 'type': 'attribute', 'children': ['103', '108']}; {'id': '103', 'type': 'subscript', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '107', 'type': 'string', 'children': [], 'value': "'view'"}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'string', 'children': [], 'value': '"No inactive aliases found."'}; {'id': '111', 'type': 'return_statement', 'children': []}; {'id': '112', 'type': 'if_statement', 'children': ['113', '115']}; {'id': '113', 'type': 'not_operator', 'children': ['114']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'force_yes'}; {'id': '115', 'type': 'block', 'children': ['116']}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'assignment', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'confirm'}; {'id': '119', 'type': 'call', 'children': ['120', '127']}; {'id': '120', 'type': 'attribute', 'children': ['121', '126']}; {'id': '121', 'type': 'subscript', 'children': ['122', '125']}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '125', 'type': 'string', 'children': [], 'value': "'view'"}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'clean_inactive_aliases'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'inactive_aliases'}; {'id': '129', 'type': 'if_statement', 'children': ['130', '133']}; {'id': '130', 'type': 'boolean_operator', 'children': ['131', '132'], 'value': 'or'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'force_yes'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'confirm'}; {'id': '133', 'type': 'block', 'children': ['134', '151', '161']}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'call', 'children': ['136', '143']}; {'id': '136', 'type': 'attribute', 'children': ['137', '142']}; {'id': '137', 'type': 'subscript', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '141', 'type': 'string', 'children': [], 'value': "'settings'"}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'remove_aliases'}; {'id': '143', 'type': 'argument_list', 'children': ['144']}; {'id': '144', 'type': 'list_comprehension', 'children': ['145', '148']}; {'id': '145', 'type': 'subscript', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '147', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '148', 'type': 'for_in_clause', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'inactive_aliases'}; {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'call', 'children': ['153', '160']}; {'id': '153', 'type': 'attribute', 'children': ['154', '159']}; {'id': '154', 'type': 'subscript', 'children': ['155', '158']}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '158', 'type': 'string', 'children': [], 'value': "'settings'"}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'write_config'}; {'id': '160', 'type': 'argument_list', 'children': []}; {'id': '161', 'type': 'expression_statement', 'children': ['162']}; {'id': '162', 'type': 'call', 'children': ['163', '170']}; {'id': '163', 'type': 'attribute', 'children': ['164', '169']}; {'id': '164', 'type': 'subscript', 'children': ['165', '168']}; {'id': '165', 'type': 'attribute', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '168', 'type': 'string', 'children': [], 'value': "'view'"}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '170', 'type': 'argument_list', 'children': ['171']}; {'id': '171', 'type': 'binary_operator', 'children': ['172', '175'], 'value': '%'}; {'id': '172', 'type': 'concatenated_string', 'children': ['173', '174']}; {'id': '173', 'type': 'string', 'children': [], 'value': '"%d inactive aliases have been successfully"'}; {'id': '174', 'type': 'string', 'children': [], 'value': '" cleaned."'}; {'id': '175', 'type': 'call', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '177', 'type': 'argument_list', 'children': ['178']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'inactive_aliases'}
Removes aliases from your config file that point to inactive projects.
def show(cls, msg=None): if msg: cls.add(msg) cls.overlay.show() cls.overlay.el.bind("click", lambda x: cls.hide()) cls.el.style.display = "block" cls.bind()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '19', '27', '46', '56']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'overlay'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'show'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '36']}; {'id': '29', 'type': 'attribute', 'children': ['30', '35']}; {'id': '30', 'type': 'attribute', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'overlay'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'el'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'bind'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"click"'}; {'id': '38', 'type': 'lambda', 'children': ['39', '41']}; {'id': '39', 'type': 'lambda_parameters', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'hide'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '55']}; {'id': '48', 'type': 'attribute', 'children': ['49', '54']}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'el'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'display'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"block"'}; {'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': 'cls'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'bind'}; {'id': '61', 'type': 'argument_list', 'children': []}
Show the log interface on the page.
def from_name_re(cls, path:PathOrStr, fnames:FilePathList, pat:str, valid_pct:float=0.2, **kwargs): "Create from list of `fnames` in `path` with re expression `pat`." pat = re.compile(pat) def _get_label(fn): if isinstance(fn, Path): fn = fn.as_posix() res = pat.search(str(fn)) assert res,f'Failed to find "{pat}" in "{fn}"' return res.group(1) return cls.from_name_func(path, fnames, _get_label, valid_pct=valid_pct, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '24']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_name_re'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '13', '17', '22']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'PathOrStr'}; {'id': '9', 'type': 'typed_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'fnames'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'FilePathList'}; {'id': '13', 'type': 'typed_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'pat'}; {'id': '15', 'type': 'type', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '17', 'type': 'typed_default_parameter', 'children': ['18', '19', '21']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'valid_pct'}; {'id': '19', 'type': 'type', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '21', 'type': 'float', 'children': [], 'value': '0.2'}; {'id': '22', 'type': 'dictionary_splat_pattern', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '24', 'type': 'block', 'children': ['25', '27', '36', '78']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'string', 'children': [], 'value': '"Create from list of `fnames` in `path` with re expression `pat`."'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'pat'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'compile'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'pat'}; {'id': '36', 'type': 'function_definition', 'children': ['37', '38', '40']}; {'id': '37', 'type': 'function_name', 'children': [], 'value': '_get_label'}; {'id': '38', 'type': 'parameters', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '40', 'type': 'block', 'children': ['41', '56', '68', '71']}; {'id': '41', 'type': 'if_statement', 'children': ['42', '47']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'Path'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'as_posix'}; {'id': '55', 'type': 'argument_list', 'children': []}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'pat'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '68', 'type': 'assert_statement', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '70', 'type': 'string', 'children': [], 'value': 'f\'Failed to find "{pat}" in "{fn}"\''}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '78', 'type': 'return_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'from_name_func'}; {'id': '83', 'type': 'argument_list', 'children': ['84', '85', '86', '87', '90']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'fnames'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_get_label'}; {'id': '87', 'type': 'keyword_argument', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'valid_pct'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'valid_pct'}; {'id': '90', 'type': 'dictionary_splat', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Create from list of `fnames` in `path` with re expression `pat`.
def audit_ghosts(self): print_header = True for app_name in self._get_ghosts(): if print_header: print_header = False print ( "Found the following in the state database but not " "available as a configured job:" ) print "\t%s" % (app_name,)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'audit_ghosts'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'print_header'}; {'id': '9', 'type': 'True', 'children': []}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '17']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'app_name'}; {'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': '_get_ghosts'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18', '32']}; {'id': '18', 'type': 'if_statement', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'print_header'}; {'id': '20', 'type': 'block', 'children': ['21', '25']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'print_header'}; {'id': '24', 'type': 'False', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'concatenated_string', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"Found the following in the state database but not "'}; {'id': '31', 'type': 'string', 'children': [], 'value': '"available as a configured job:"'}; {'id': '32', 'type': 'print_statement', 'children': ['33']}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '35'], 'value': '%'}; {'id': '34', 'type': 'string', 'children': [], 'value': '"\\t%s"'}; {'id': '35', 'type': 'tuple', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'app_name'}
compare the list of configured jobs with the jobs in the state
def which(fname): if "PATH" not in os.environ or not os.environ["PATH"]: path = os.defpath else: path = os.environ["PATH"] for p in [fname] + [os.path.join(x, fname) for x in path.split(os.pathsep)]: p = os.path.abspath(p) if os.access(p, os.X_OK) and not os.path.isdir(p): return p p = sp.Popen("locate %s" % fname, shell=True, stdout=sp.PIPE, stderr=sp.PIPE) (stdout, stderr) = p.communicate() if not stderr: for p in stdout.decode().split("\n"): if (os.path.basename(p) == fname) and ( os.access(p, os.X_OK)) and ( not os.path.isdir(p)): return p
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'which'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '5', 'type': 'block', 'children': ['6', '36', '96', '120', '130']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '19', '26']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '13'], 'value': 'or'}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'not in'}; {'id': '9', 'type': 'string', 'children': [], 'value': '"PATH"'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '13', 'type': 'not_operator', 'children': ['14']}; {'id': '14', 'type': 'subscript', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '18', 'type': 'string', 'children': [], 'value': '"PATH"'}; {'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': 'path'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'defpath'}; {'id': '26', 'type': 'else_clause', 'children': ['27']}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '31', 'type': 'subscript', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '35', 'type': 'string', 'children': [], 'value': '"PATH"'}; {'id': '36', 'type': 'for_statement', 'children': ['37', '38', '61']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '41'], 'value': '+'}; {'id': '39', 'type': 'list', 'children': ['40'], 'value': '[fname]'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '41', 'type': 'list_comprehension', 'children': ['42', '51']}; {'id': '42', 'type': 'call', 'children': ['43', '48']}; {'id': '43', 'type': 'attribute', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '51', 'type': 'for_in_clause', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'pathsep'}; {'id': '61', 'type': 'block', 'children': ['62', '73']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '65', 'type': 'call', 'children': ['66', '71']}; {'id': '66', 'type': 'attribute', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '73', 'type': 'if_statement', 'children': ['74', '93']}; {'id': '74', 'type': 'boolean_operator', 'children': ['75', '84'], 'value': 'and'}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'access'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'X_OK'}; {'id': '84', 'type': 'not_operator', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '91']}; {'id': '86', 'type': 'attribute', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'isdir'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'return_statement', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'Popen'}; {'id': '103', 'type': 'argument_list', 'children': ['104', '107', '110', '115']}; {'id': '104', 'type': 'binary_operator', 'children': ['105', '106'], 'value': '%'}; {'id': '105', 'type': 'string', 'children': [], 'value': '"locate %s"'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '107', 'type': 'keyword_argument', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'shell'}; {'id': '109', 'type': 'True', 'children': []}; {'id': '110', 'type': 'keyword_argument', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'PIPE'}; {'id': '115', 'type': 'keyword_argument', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'PIPE'}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'assignment', 'children': ['122', '125']}; {'id': '122', 'type': 'tuple_pattern', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'communicate'}; {'id': '129', 'type': 'argument_list', 'children': []}; {'id': '130', 'type': 'if_statement', 'children': ['131', '133']}; {'id': '131', 'type': 'not_operator', 'children': ['132']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '133', 'type': 'block', 'children': ['134']}; {'id': '134', 'type': 'for_statement', 'children': ['135', '136', '146']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '136', 'type': 'call', 'children': ['137', '144']}; {'id': '137', 'type': 'attribute', 'children': ['138', '143']}; {'id': '138', 'type': 'call', 'children': ['139', '142']}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '142', 'type': 'argument_list', 'children': []}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}; {'id': '145', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '146', 'type': 'block', 'children': ['147']}; {'id': '147', 'type': 'if_statement', 'children': ['148', '181']}; {'id': '148', 'type': 'boolean_operator', 'children': ['149', '171'], 'value': 'and'}; {'id': '149', 'type': 'boolean_operator', 'children': ['150', '161'], 'value': 'and'}; {'id': '150', 'type': '()', 'children': ['151']}; {'id': '151', 'type': 'comparison_operator', 'children': ['152', '160'], 'value': '=='}; {'id': '152', 'type': 'call', 'children': ['153', '158']}; {'id': '153', 'type': 'attribute', 'children': ['154', '157']}; {'id': '154', 'type': 'attribute', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '158', 'type': 'argument_list', 'children': ['159']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '161', 'type': '()', 'children': ['162']}; {'id': '162', 'type': 'call', 'children': ['163', '166']}; {'id': '163', 'type': 'attribute', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'access'}; {'id': '166', 'type': 'argument_list', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '168', 'type': 'attribute', 'children': ['169', '170']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'X_OK'}; {'id': '171', 'type': '()', 'children': ['172']}; {'id': '172', 'type': 'not_operator', 'children': ['173']}; {'id': '173', 'type': 'call', 'children': ['174', '179']}; {'id': '174', 'type': 'attribute', 'children': ['175', '178']}; {'id': '175', 'type': 'attribute', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'isdir'}; {'id': '179', 'type': 'argument_list', 'children': ['180']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '181', 'type': 'block', 'children': ['182']}; {'id': '182', 'type': 'return_statement', 'children': ['183']}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'p'}
Find location of executable.
def _get(operation: Operation, url=URL, **params): prepped_request = _prep_get(operation, url=url, **params) return cgi.send(prepped_request)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '11']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'operation'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'Operation'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'URL'}; {'id': '11', 'type': 'dictionary_splat_pattern', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '13', 'type': 'block', 'children': ['14', '26']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'prepped_request'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_prep_get'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21', '24']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'operation'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '24', 'type': 'dictionary_splat', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'cgi'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'prepped_request'}
HTTP GET of the FlashAir command.cgi entrypoint
def _estimate_strains(self): for l in self._profile: l.reset() l.strain = self._motion.pgv / l.initial_shear_vel
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_estimate_strains'}; {'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', '11']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_profile'}; {'id': '11', 'type': 'block', 'children': ['12', '18']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'reset'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'strain'}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '29'], 'value': '/'}; {'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': '_motion'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'pgv'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'initial_shear_vel'}
Compute an estimate of the strains.
def from_analysis_period(cls, analysis_period, tau_b, tau_d, daylight_savings_indicator='No'): _check_analysis_period(analysis_period) return cls(analysis_period.st_month, analysis_period.st_day, tau_b, tau_d, daylight_savings_indicator)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_analysis_period'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'analysis_period'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'tau_b'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'tau_d'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'daylight_savings_indicator'}; {'id': '10', 'type': 'string', 'children': [], 'value': "'No'"}; {'id': '11', 'type': 'block', 'children': ['12', '17']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_check_analysis_period'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'analysis_period'}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '24', '27', '28', '29']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'analysis_period'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'st_month'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'analysis_period'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'st_day'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'tau_b'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'tau_d'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'daylight_savings_indicator'}
Initialize a RevisedClearSkyCondition from an analysis_period
def export_data(self): data_tuples = ((key, self._serialize(key, value)) for key, value in six.iteritems(self._data)) data_tuples = filter(lambda t: t[1] is not '', data_tuples) data = dict(data_tuples) return json.dumps(data, separators=(',', ':'))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'export_data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '31', '46', '53']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'data_tuples'}; {'id': '9', 'type': 'generator_expression', 'children': ['10', '19']}; {'id': '10', 'type': 'tuple', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'key'}; {'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': '_serialize'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '19', 'type': 'for_in_clause', 'children': ['20', '23']}; {'id': '20', 'type': 'pattern_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_data'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'data_tuples'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '45']}; {'id': '37', 'type': 'lambda', 'children': ['38', '40']}; {'id': '38', 'type': 'lambda_parameters', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '44'], 'value': 'is not'}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '44', 'type': 'string', 'children': [], 'value': "''"}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'data_tuples'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'data_tuples'}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'separators'}; {'id': '62', 'type': 'tuple', 'children': ['63', '64']}; {'id': '63', 'type': 'string', 'children': [], 'value': "','"}; {'id': '64', 'type': 'string', 'children': [], 'value': "':'"}
Exports current data contained in the Task as JSON
def next(self): if self._stopped_iteration: raise StopIteration() while True: try: chunk = self.process._pipe_queue.get(True, 0.001) except Empty: if self.call_args["iter_noblock"]: return errno.EWOULDBLOCK else: if chunk is None: self.wait() self._stopped_iteration = True raise StopIteration() try: return chunk.decode(self.call_args["encoding"], self.call_args["decode_errors"]) except UnicodeDecodeError: return chunk
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'next'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_stopped_iteration'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'raise_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'StopIteration'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'while_statement', 'children': ['16', '17']}; {'id': '16', 'type': 'True', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'try_statement', 'children': ['19', '34', '48']}; {'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': 'chunk'}; {'id': '23', 'type': 'call', 'children': ['24', '31']}; {'id': '24', 'type': 'attribute', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'process'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_pipe_queue'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'True', 'children': []}; {'id': '33', 'type': 'float', 'children': [], 'value': '0.001'}; {'id': '34', 'type': 'except_clause', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'Empty'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'if_statement', 'children': ['38', '43']}; {'id': '38', 'type': 'subscript', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'call_args'}; {'id': '42', 'type': 'string', 'children': [], 'value': '"iter_noblock"'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'errno'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'EWOULDBLOCK'}; {'id': '48', 'type': 'else_clause', 'children': ['49']}; {'id': '49', 'type': 'block', 'children': ['50', '71']}; {'id': '50', 'type': 'if_statement', 'children': ['51', '54']}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '53'], 'value': 'is'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'chunk'}; {'id': '53', 'type': 'None', 'children': []}; {'id': '54', 'type': 'block', 'children': ['55', '61', '67']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'wait'}; {'id': '60', 'type': 'argument_list', 'children': []}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': '_stopped_iteration'}; {'id': '66', 'type': 'True', 'children': []}; {'id': '67', 'type': 'raise_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'StopIteration'}; {'id': '70', 'type': 'argument_list', 'children': []}; {'id': '71', 'type': 'try_statement', 'children': ['72', '89']}; {'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': 'chunk'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '84']}; {'id': '79', 'type': 'subscript', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'call_args'}; {'id': '83', 'type': 'string', 'children': [], 'value': '"encoding"'}; {'id': '84', 'type': 'subscript', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'call_args'}; {'id': '88', 'type': 'string', 'children': [], 'value': '"decode_errors"'}; {'id': '89', 'type': 'except_clause', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'UnicodeDecodeError'}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'return_statement', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'chunk'}
allow us to iterate over the output of our command
def _if(cls, verb): pred = verb.predicate data = verb.data groups = set(_get_groups(verb)) if isinstance(pred, str): if not pred.endswith('_dtype'): pred = '{}_dtype'.format(pred) pred = getattr(pdtypes, pred) elif pdtypes.is_bool_dtype(np.array(pred)): it = iter(pred) def pred(col): return next(it) return [col for col in data if pred(data[col]) and col not in groups]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_if'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'verb'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '19', '29', '92']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'pred'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'verb'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'predicate'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'verb'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_get_groups'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'verb'}; {'id': '29', 'type': 'if_statement', 'children': ['30', '35', '62']}; {'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': 'pred'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '35', 'type': 'block', 'children': ['36', '54']}; {'id': '36', 'type': 'if_statement', 'children': ['37', '44']}; {'id': '37', 'type': 'not_operator', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'pred'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'_dtype'"}; {'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': 'pred'}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'string', 'children': [], 'value': "'{}_dtype'"}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'pred'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'pred'}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'pdtypes'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'pred'}; {'id': '62', 'type': 'elif_clause', 'children': ['63', '74']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'pdtypes'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'is_bool_dtype'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'pred'}; {'id': '74', 'type': 'block', 'children': ['75', '82']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'iter'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'pred'}; {'id': '82', 'type': 'function_definition', 'children': ['83', '84', '86']}; {'id': '83', 'type': 'function_name', 'children': [], 'value': 'pred'}; {'id': '84', 'type': 'parameters', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'return_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'next'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '92', 'type': 'return_statement', 'children': ['93']}; {'id': '93', 'type': 'list_comprehension', 'children': ['94', '95', '98']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '95', 'type': 'for_in_clause', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '98', 'type': 'if_clause', 'children': ['99']}; {'id': '99', 'type': 'boolean_operator', 'children': ['100', '106'], 'value': 'and'}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'pred'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'subscript', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '106', 'type': 'comparison_operator', 'children': ['107', '108'], 'value': 'not in'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'groups'}
A verb with a predicate function
def create_dialog(self): self.bbox = QDialogButtonBox(QDialogButtonBox.Close) self.idx_close = self.bbox.button(QDialogButtonBox.Close) self.idx_close.pressed.connect(self.reject) btnlayout = QHBoxLayout() btnlayout.addStretch(1) btnlayout.addWidget(self.bbox) layout = QVBoxLayout() layout.addWidget(self.toolbar) layout.addWidget(self.canvas) layout.addLayout(btnlayout) layout.addStretch(1) self.setLayout(layout)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_dialog'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '32', '45', '51', '58', '67', '73', '82', '91', '98', '105']}; {'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': 'bbox'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'QDialogButtonBox'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'QDialogButtonBox'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'Close'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'idx_close'}; {'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': 'bbox'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'button'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'QDialogButtonBox'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'Close'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'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': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'idx_close'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'pressed'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'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': 'reject'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'btnlayout'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'QHBoxLayout'}; {'id': '50', 'type': 'argument_list', 'children': []}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'btnlayout'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'addStretch'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'integer', 'children': [], 'value': '1'}; {'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': 'btnlayout'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'addWidget'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'bbox'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'layout'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'QVBoxLayout'}; {'id': '72', 'type': 'argument_list', 'children': []}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'layout'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'addWidget'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'toolbar'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'layout'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'addWidget'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'canvas'}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'layout'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'addLayout'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'btnlayout'}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'layout'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'addStretch'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'call', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'setLayout'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'layout'}
Create the basic dialog.
def freeze(self, number=None): if number is None: number = self.head_layers for idx, child in enumerate(self.model.children()): if idx < number: mu.freeze_layer(child)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'freeze'}; {'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': 'number'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '20']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'is'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'number'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'number'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'head_layers'}; {'id': '20', 'type': 'for_statement', 'children': ['21', '24', '34']}; {'id': '21', 'type': 'pattern_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '33']}; {'id': '28', 'type': 'attribute', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'if_statement', 'children': ['36', '39']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': '<'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'number'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'mu'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'freeze_layer'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'child'}
Freeze given number of layers in the model