code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def coordinates(self, x, y): state = self.state return state.mt.coord_from_area(x, y, state.lat, state.lon, state.width, state.ground_width)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'coordinates'}; {'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', '14']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'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': 'state'}; {'id': '14', 'type': 'return_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': 'state'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'mt'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'coord_from_area'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23', '24', '27', '30', '33']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'lat'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'lon'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ground_width'}
return coordinates of a pixel in the map
def summary(self): out = {} for bench in self.runner.runned: key = self.key(bench) runs = {} for method, results in bench.results.items(): mean = results.total / bench.times name = bench.label_for(method) runs[method] = { 'name': name, 'total': results.total, 'mean': mean } out[key] = { 'name': bench.label, 'times': bench.times, 'runs': runs } return out
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'summary'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '98']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '17']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'bench'}; {'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': 'runner'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'runned'}; {'id': '17', 'type': 'block', 'children': ['18', '27', '31', '79']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'bench'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'runs'}; {'id': '30', 'type': 'dictionary', 'children': []}; {'id': '31', 'type': 'for_statement', 'children': ['32', '35', '42']}; {'id': '32', 'type': 'pattern_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '35', 'type': 'call', 'children': ['36', '41']}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'bench'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'block', 'children': ['43', '53', '62']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'mean'}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '50'], 'value': '/'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'total'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'bench'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'times'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'bench'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'label_for'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '67']}; {'id': '64', 'type': 'subscript', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'runs'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '67', 'type': 'dictionary', 'children': ['68', '71', '76']}; {'id': '68', 'type': 'pair', 'children': ['69', '70']}; {'id': '69', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '71', 'type': 'pair', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': "'total'"}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'total'}; {'id': '76', 'type': 'pair', 'children': ['77', '78']}; {'id': '77', 'type': 'string', 'children': [], 'value': "'mean'"}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'mean'}; {'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': 'out'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '84', 'type': 'dictionary', 'children': ['85', '90', '95']}; {'id': '85', 'type': 'pair', 'children': ['86', '87']}; {'id': '86', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'bench'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '90', 'type': 'pair', 'children': ['91', '92']}; {'id': '91', 'type': 'string', 'children': [], 'value': "'times'"}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'bench'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'times'}; {'id': '95', 'type': 'pair', 'children': ['96', '97']}; {'id': '96', 'type': 'string', 'children': [], 'value': "'runs'"}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'runs'}; {'id': '98', 'type': 'return_statement', 'children': ['99']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'out'}
Compute the execution summary
def clear(self): self._undos.clear() self._redos.clear() self._savepoint = None self._receiver = self._undos
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '22', '28']}; {'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': '_undos'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'clear'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'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': '_redos'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'clear'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_savepoint'}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_receiver'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_undos'}
Clear the undo list.
def from_call(cls, call_node): callcontext = contextmod.CallContext(call_node.args, call_node.keywords) return cls(callcontext)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_call'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'call_node'}; {'id': '6', 'type': 'block', 'children': ['7', '21']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'callcontext'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'contextmod'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'CallContext'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'call_node'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'call_node'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'keywords'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'callcontext'}
Get a CallSite object from the given Call node.
def choose_args(metadata, config): return dict( connect_args=choose_connect_args(metadata, config), echo=config.echo, max_overflow=config.max_overflow, pool_size=config.pool_size, pool_timeout=config.pool_timeout, )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'choose_args'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '18', '23', '28', '33']}; {'id': '11', 'type': 'keyword_argument', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'connect_args'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'choose_connect_args'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'max_overflow'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'max_overflow'}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'pool_size'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'pool_size'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'pool_timeout'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'pool_timeout'}
Choose database connection arguments.
def convert_to_ik_angles(self, joints): if len(joints) != len(self.motors): raise ValueError('Incompatible data, len(joints) should be {}!'.format(len(self.motors))) raw_joints = [(j + m.offset) * (1 if m.direct else -1) for j, m in zip(joints, self.motors)] raw_joints *= self._reversed return [0] + [deg2rad(j) for j in raw_joints] + [0]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_to_ik_angles'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'joints'}; {'id': '6', 'type': 'block', 'children': ['7', '35', '65', '71']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '19']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '13'], 'value': '!='}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'joints'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'motors'}; {'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': 'ValueError'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'Incompatible data, len(joints) should be {}!'"}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'motors'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'raw_joints'}; {'id': '38', 'type': 'list_comprehension', 'children': ['39', '54']}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '46'], 'value': '*'}; {'id': '40', 'type': '()', 'children': ['41']}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '43'], 'value': '+'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '46', 'type': '()', 'children': ['47']}; {'id': '47', 'type': 'conditional_expression', 'children': ['48', '49', '52'], 'value': 'if'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'direct'}; {'id': '52', 'type': 'unary_operator', 'children': ['53'], 'value': '-'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '54', 'type': 'for_in_clause', 'children': ['55', '58']}; {'id': '55', 'type': 'pattern_list', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'joints'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'motors'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'augmented_assignment', 'children': ['67', '68'], 'value': '*='}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'raw_joints'}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '_reversed'}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'binary_operator', 'children': ['73', '84'], 'value': '+'}; {'id': '73', 'type': 'binary_operator', 'children': ['74', '76'], 'value': '+'}; {'id': '74', 'type': 'list', 'children': ['75'], 'value': '[0]'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '76', 'type': 'list_comprehension', 'children': ['77', '81']}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'deg2rad'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '81', 'type': 'for_in_clause', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'raw_joints'}; {'id': '84', 'type': 'list', 'children': ['85'], 'value': '[0]'}; {'id': '85', 'type': 'integer', 'children': [], 'value': '0'}
Convert from poppy representation to IKPY internal representation.
def updateFromKwargs(self, properties, kwargs, collector, **unused): properties[self.name] = self.getFromKwargs(kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'updateFromKwargs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'properties'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'collector'}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'unused'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '18']}; {'id': '13', 'type': 'subscript', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'properties'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'getFromKwargs'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Primary entry point to turn 'kwargs' into 'properties
def visit_Name(self, node: AST, dfltChaining: bool = True) -> str: return node.id
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'visit_Name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'AST'}; {'id': '9', 'type': 'typed_default_parameter', 'children': ['10', '11', '13']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'dfltChaining'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'id'}
Return `node`s id.
def session(self): engine = self.engine connection = engine.connect() db_session = scoped_session( sessionmaker(autocommit=False, autoflush=True, bind=engine)) yield db_session db_session.close() connection.close()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'session'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '20', '38', '41', '47']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'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': 'db_session'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'scoped_session'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'sessionmaker'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '32', '35']}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'autocommit'}; {'id': '31', 'type': 'False', 'children': []}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'autoflush'}; {'id': '34', 'type': 'True', 'children': []}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'bind'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'yield', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'db_session'}; {'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': 'db_session'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '46', 'type': 'argument_list', 'children': []}; {'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': 'connection'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '52', 'type': 'argument_list', 'children': []}
Creates a context with an open SQLAlchemy session.
def setup_temp_logger(log_level='error'): if is_temp_logging_configured(): logging.getLogger(__name__).warning( 'Temporary logging is already configured' ) return if log_level is None: log_level = 'warning' level = LOG_LEVELS.get(log_level.lower(), logging.ERROR) handler = None for handler in logging.root.handlers: if handler in (LOGGING_NULL_HANDLER, LOGGING_STORE_HANDLER): continue if not hasattr(handler, 'stream'): continue if handler.stream is sys.stderr: break else: handler = LOGGING_TEMP_HANDLER handler.setLevel(level) formatter = logging.Formatter( '[%(levelname)-8s] %(message)s', datefmt='%H:%M:%S' ) handler.setFormatter(formatter) logging.root.addHandler(handler) if LOGGING_NULL_HANDLER is not None: LOGGING_NULL_HANDLER.sync_with_handlers([handler]) else: logging.getLogger(__name__).debug( 'LOGGING_NULL_HANDLER is already None, can\'t sync messages ' 'with it' ) __remove_null_logging_handler() global __TEMP_LOGGING_CONFIGURED __TEMP_LOGGING_CONFIGURED = True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setup_temp_logger'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'log_level'}; {'id': '6', 'type': 'string', 'children': [], 'value': "'error'"}; {'id': '7', 'type': 'block', 'children': ['8', '26', '35', '51', '55', '96', '103', '115', '122', '131', '160', '164', '166']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'is_temp_logging_configured'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '25']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '23']}; {'id': '15', 'type': 'attribute', 'children': ['16', '22']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'getLogger'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'Temporary logging is already configured'"}; {'id': '25', 'type': 'return_statement', 'children': []}; {'id': '26', 'type': 'if_statement', 'children': ['27', '30']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'is'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'log_level'}; {'id': '29', 'type': 'None', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'log_level'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'warning'"}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'LOG_LEVELS'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '48']}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'log_level'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '47', 'type': 'argument_list', 'children': []}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'ERROR'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '54', 'type': 'None', 'children': []}; {'id': '55', 'type': 'for_statement', 'children': ['56', '57', '62', '90']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'handlers'}; {'id': '62', 'type': 'block', 'children': ['63', '71', '80']}; {'id': '63', 'type': 'if_statement', 'children': ['64', '69']}; {'id': '64', 'type': 'comparison_operator', 'children': ['65', '66'], 'value': 'in'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '66', 'type': 'tuple', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'LOGGING_NULL_HANDLER'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'LOGGING_STORE_HANDLER'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'continue_statement', 'children': []}; {'id': '71', 'type': 'if_statement', 'children': ['72', '78']}; {'id': '72', 'type': 'not_operator', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'stream'"}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'continue_statement', 'children': []}; {'id': '80', 'type': 'if_statement', 'children': ['81', '88']}; {'id': '81', 'type': 'comparison_operator', 'children': ['82', '85'], 'value': 'is'}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '88', 'type': 'block', 'children': ['89']}; {'id': '89', 'type': 'break_statement', 'children': []}; {'id': '90', 'type': 'else_clause', 'children': ['91']}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'LOGGING_TEMP_HANDLER'}; {'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': 'handler'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'setLevel'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'assignment', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'formatter'}; {'id': '106', 'type': 'call', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'Formatter'}; {'id': '110', 'type': 'argument_list', 'children': ['111', '112']}; {'id': '111', 'type': 'string', 'children': [], 'value': "'[%(levelname)-8s] %(message)s'"}; {'id': '112', 'type': 'keyword_argument', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'datefmt'}; {'id': '114', 'type': 'string', 'children': [], 'value': "'%H:%M:%S'"}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '120']}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'setFormatter'}; {'id': '120', 'type': 'argument_list', 'children': ['121']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'formatter'}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'call', 'children': ['124', '129']}; {'id': '124', 'type': 'attribute', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'addHandler'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '131', 'type': 'if_statement', 'children': ['132', '135', '144']}; {'id': '132', 'type': 'comparison_operator', 'children': ['133', '134'], 'value': 'is not'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'LOGGING_NULL_HANDLER'}; {'id': '134', 'type': 'None', 'children': []}; {'id': '135', 'type': 'block', 'children': ['136']}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}; {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'LOGGING_NULL_HANDLER'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'sync_with_handlers'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'list', 'children': ['143'], 'value': '[handler]'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '144', 'type': 'else_clause', 'children': ['145']}; {'id': '145', 'type': 'block', 'children': ['146']}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}; {'id': '147', 'type': 'call', 'children': ['148', '156']}; {'id': '148', 'type': 'attribute', 'children': ['149', '155']}; {'id': '149', 'type': 'call', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'getLogger'}; {'id': '153', 'type': 'argument_list', 'children': ['154']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}; {'id': '157', 'type': 'concatenated_string', 'children': ['158', '159']}; {'id': '158', 'type': 'string', 'children': [], 'value': "'LOGGING_NULL_HANDLER is already None, can\\'t sync messages '"}; {'id': '159', 'type': 'string', 'children': [], 'value': "'with it'"}; {'id': '160', 'type': 'expression_statement', 'children': ['161']}; {'id': '161', 'type': 'call', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': '__remove_null_logging_handler'}; {'id': '163', 'type': 'argument_list', 'children': []}; {'id': '164', 'type': 'global_statement', 'children': ['165']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': '__TEMP_LOGGING_CONFIGURED'}; {'id': '166', 'type': 'expression_statement', 'children': ['167']}; {'id': '167', 'type': 'assignment', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': '__TEMP_LOGGING_CONFIGURED'}; {'id': '169', 'type': 'True', 'children': []}
Setup the temporary console logger
def iso_string_to_python_datetime( isostring: str) -> Optional[datetime.datetime]: if not isostring: return None return dateutil.parser.parse(isostring)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iso_string_to_python_datetime'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'isostring'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '8', 'type': 'type', 'children': ['9']}; {'id': '9', 'type': 'generic_type', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Optional'}; {'id': '11', 'type': 'type_parameter', 'children': ['12']}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '16', 'type': 'block', 'children': ['17', '23']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '20']}; {'id': '18', 'type': 'not_operator', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'isostring'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'return_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': 'dateutil'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'parse'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'isostring'}
Takes an ISO-8601 string and returns a ``datetime``.
def children(self, vertex): return [self.head(edge) for edge in self.out_edges(vertex)]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'children'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'vertex'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'list_comprehension', 'children': ['9', '15']}; {'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': 'head'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'edge'}; {'id': '15', 'type': 'for_in_clause', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'edge'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'out_edges'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'vertex'}
Return the list of immediate children of the given vertex.
def connect(self): logger.info("Connecting to %s:%s", self._host, self._port) reader, writer = yield from asyncio.open_connection( self._host, self._port, loop=self._loop) self._ioloop_future = ensure_future( self._ioloop(reader, writer), loop=self._loop) logger.info("Connected")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connect'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '41', '61']}; {'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': 'logger'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13', '16']}; {'id': '12', 'type': 'string', 'children': [], 'value': '"Connecting to %s:%s"'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_host'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_port'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '24']}; {'id': '21', 'type': 'pattern_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'reader'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'writer'}; {'id': '24', 'type': 'yield', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'asyncio'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'open_connection'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '33', '36']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_host'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_port'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_loop'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': '_ioloop_future'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'ensure_future'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '56']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '_ioloop'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'reader'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'writer'}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '_loop'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'string', 'children': [], 'value': '"Connected"'}
Connect to the controller and start processing responses.
def find_by_b64id(self, _id, **kwargs): return self.find_one({"_id": ObjectId(base64.b64decode(_id))}, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_by_b64id'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': '_id'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'return_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'find_one'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '27']}; {'id': '15', 'type': 'dictionary', 'children': ['16']}; {'id': '16', 'type': 'pair', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"_id"'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ObjectId'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'base64'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'b64decode'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_id'}; {'id': '27', 'type': 'dictionary_splat', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Pass me a base64-encoded ObjectId
def reply_bytes(self, request): flags = struct.pack("<i", self._flags) cursor_id = struct.pack("<q", self._cursor_id) starting_from = struct.pack("<i", self._starting_from) number_returned = struct.pack("<i", len(self._docs)) reply_id = random.randint(0, 1000000) response_to = request.request_id data = b''.join([flags, cursor_id, starting_from, number_returned]) data += b''.join([bson.BSON.encode(doc) for doc in self._docs]) message = struct.pack("<i", 16 + len(data)) message += struct.pack("<i", reply_id) message += struct.pack("<i", response_to) message += struct.pack("<i", OP_REPLY) return message + data
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reply_bytes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'block', 'children': ['7', '19', '31', '43', '58', '68', '74', '87', '109', '124', '134', '144', '154']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'flags'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"<i"'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_flags'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cursor_id'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"<q"'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_cursor_id'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'starting_from'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"<i"'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '_starting_from'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'number_returned'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': '"<i"'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '_docs'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'reply_id'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'randint'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '1000000'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'response_to'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'request_id'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'string', 'children': [], 'value': "b''"}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'list', 'children': ['83', '84', '85', '86'], 'value': '[flags, cursor_id, starting_from, number_returned]'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'flags'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'cursor_id'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'starting_from'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'number_returned'}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'augmented_assignment', 'children': ['89', '90'], 'value': '+='}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'string', 'children': [], 'value': "b''"}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'list_comprehension', 'children': ['96', '104']}; {'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': 'bson'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'BSON'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '104', 'type': 'for_in_clause', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': '_docs'}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '112', 'type': 'call', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '116', 'type': 'argument_list', 'children': ['117', '118']}; {'id': '117', 'type': 'string', 'children': [], 'value': '"<i"'}; {'id': '118', 'type': 'binary_operator', 'children': ['119', '120'], 'value': '+'}; {'id': '119', 'type': 'integer', 'children': [], 'value': '16'}; {'id': '120', 'type': 'call', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'augmented_assignment', 'children': ['126', '127'], 'value': '+='}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '127', 'type': 'call', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '131', 'type': 'argument_list', 'children': ['132', '133']}; {'id': '132', 'type': 'string', 'children': [], 'value': '"<i"'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'reply_id'}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'augmented_assignment', 'children': ['136', '137'], 'value': '+='}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '141', 'type': 'argument_list', 'children': ['142', '143']}; {'id': '142', 'type': 'string', 'children': [], 'value': '"<i"'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'response_to'}; {'id': '144', 'type': 'expression_statement', 'children': ['145']}; {'id': '145', 'type': 'augmented_assignment', 'children': ['146', '147'], 'value': '+='}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '147', 'type': 'call', 'children': ['148', '151']}; {'id': '148', 'type': 'attribute', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '151', 'type': 'argument_list', 'children': ['152', '153']}; {'id': '152', 'type': 'string', 'children': [], 'value': '"<i"'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'OP_REPLY'}; {'id': '154', 'type': 'return_statement', 'children': ['155']}; {'id': '155', 'type': 'binary_operator', 'children': ['156', '157'], 'value': '+'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'data'}
Take a `Request` and return an OP_REPLY message as bytes.
def GetMethodConfig(self, method): method_config = self._method_configs.get(method) if method_config: return method_config func = getattr(self, method, None) if func is None: raise KeyError(method) method_config = getattr(func, 'method_config', None) if method_config is None: raise KeyError(method) self._method_configs[method] = config = method_config() return config
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetMethodConfig'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '6', 'type': 'block', 'children': ['7', '18', '23', '32', '42', '51', '61', '73']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'method_config'}; {'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': '_method_configs'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '18', 'type': 'if_statement', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'method_config'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'method_config'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30', '31']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '31', 'type': 'None', 'children': []}; {'id': '32', 'type': 'if_statement', 'children': ['33', '36']}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '35'], 'value': 'is'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '35', 'type': 'None', 'children': []}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'raise_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'method_config'}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49', '50']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '49', 'type': 'string', 'children': [], 'value': "'method_config'"}; {'id': '50', 'type': 'None', 'children': []}; {'id': '51', 'type': 'if_statement', 'children': ['52', '55']}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '54'], 'value': 'is'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'method_config'}; {'id': '54', 'type': 'None', 'children': []}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'raise_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '68']}; {'id': '63', 'type': 'subscript', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '_method_configs'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'method_config'}; {'id': '72', 'type': 'argument_list', 'children': []}; {'id': '73', 'type': 'return_statement', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'config'}
Returns service cached method config for given method.
def copy(self): attrs = {k: self.__dict__[k].copy() for k in self.containers} attrs.update({k: cp.deepcopy(self.__dict__[k]) for k in self.shared}) return self.__class__(**attrs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'copy'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '26', '50']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '9', 'type': 'dictionary_comprehension', 'children': ['10', '21']}; {'id': '10', 'type': 'pair', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '12', 'type': 'call', 'children': ['13', '20']}; {'id': '13', 'type': 'attribute', 'children': ['14', '19']}; {'id': '14', 'type': 'subscript', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '__dict__'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'for_in_clause', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'containers'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'dictionary_comprehension', 'children': ['33', '45']}; {'id': '33', 'type': 'pair', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'cp'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'deepcopy'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'subscript', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '__dict__'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '45', 'type': 'for_in_clause', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'shared'}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'dictionary_splat', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'attrs'}
Returns a copy of the object.
def generate(size, output, schema): pii_data = randomnames.NameList(size) if schema is not None: raise NotImplementedError randomnames.save_csv( pii_data.names, [f.identifier for f in pii_data.SCHEMA.fields], output)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '7', 'type': 'block', 'children': ['8', '17', '24']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'pii_data'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'randomnames'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'NameList'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '21']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': 'is not'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'raise_statement', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'NotImplementedError'}; {'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': 'randomnames'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'save_csv'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '33', '44']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'pii_data'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '33', 'type': 'list_comprehension', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '37', 'type': 'for_in_clause', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'pii_data'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'SCHEMA'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'output'}
Generate fake PII data for testing
def make_connector(self, app=None, bind=None): return _EngineConnector(self, self.get_app(app), bind)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_connector'}; {'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': 'app'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'bind'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_EngineConnector'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17', '23']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'get_app'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'app'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'bind'}
Creates the connector for a given state and bind.
def _visible(self, element): if element.name in self._disallowed_names: return False elif re.match(u'<!--.*-->', six.text_type(element.extract())): return False return True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_visible'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '6', 'type': 'block', 'children': ['7', '38']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '15', '18']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': 'in'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_disallowed_names'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'False', 'children': []}; {'id': '18', 'type': 'elif_clause', 'children': ['19', '35']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': "u'<!--.*-->'"}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'text_type'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'extract'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'False', 'children': []}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'True', 'children': []}
Used to filter text elements that have invisible text on the page.
def update_vcl(self, service_id, version_number, name_key, **kwargs): body = self._formdata(kwargs, FastlyVCL.FIELDS) content = self._fetch("/service/%s/version/%d/vcl/%s" % (service_id, version_number, name_key), method="PUT", body=body) return FastlyVCL(self, content)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_vcl'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'service_id'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'version_number'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'name_key'}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11', '23', '43']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_formdata'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'FastlyVCL'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'FIELDS'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_fetch'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '37', '40']}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '33'], 'value': '%'}; {'id': '32', 'type': 'string', 'children': [], 'value': '"/service/%s/version/%d/vcl/%s"'}; {'id': '33', 'type': 'tuple', 'children': ['34', '35', '36']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'service_id'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'version_number'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'name_key'}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '39', 'type': 'string', 'children': [], 'value': '"PUT"'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'FastlyVCL'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'content'}
Update the uploaded VCL for a particular service and version.
def _write_scalar(self, name:str, scalar_value, iteration:int)->None: "Writes single scalar value to Tensorboard." tag = self.metrics_root + name self.tbwriter.add_scalar(tag=tag, scalar_value=scalar_value, global_step=iteration)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_write_scalar'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'scalar_value'}; {'id': '10', 'type': 'typed_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'iteration'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17', '19', '27']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"Writes single scalar value to Tensorboard."'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '26'], 'value': '+'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'metrics_root'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '34']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'tbwriter'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'add_scalar'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '38', '41']}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'scalar_value'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'scalar_value'}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'global_step'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'iteration'}
Writes single scalar value to Tensorboard.
def _spawn_kafka_connection_thread(self): self.logger.debug("Spawn kafka connection thread") self.kafka_connected = False self._kafka_thread = Thread(target=self._setup_kafka) self._kafka_thread.setDaemon(True) self._kafka_thread.start()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_spawn_kafka_connection_thread'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '21', '34', '43']}; {'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': 'logger'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"Spawn kafka connection thread"'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'kafka_connected'}; {'id': '20', 'type': 'False', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_kafka_thread'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'Thread'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_setup_kafka'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '41']}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_kafka_thread'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'setDaemon'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'True', 'children': []}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '50']}; {'id': '45', 'type': 'attribute', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_kafka_thread'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '50', 'type': 'argument_list', 'children': []}
Spawns a kafka connection thread
def r(self): r_args = [_to_r(self.args), _to_r(self.kwargs)] r_args = ",".join([x for x in r_args if x != ""]) return "{}({})".format(self.name, r_args)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'r'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '22', '39']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'r_args'}; {'id': '9', 'type': 'list', 'children': ['10', '16'], 'value': '[_to_r(self.args), _to_r(self.kwargs)]'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_to_r'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_to_r'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'r_args'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': '","'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'list_comprehension', 'children': ['31', '32', '35']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '32', 'type': 'for_in_clause', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'r_args'}; {'id': '35', 'type': 'if_clause', 'children': ['36']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': '!='}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '38', 'type': 'string', 'children': [], 'value': '""'}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'string', 'children': [], 'value': '"{}({})"'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'r_args'}
Convert this GGStatement into its R equivalent expression
def _repr_html_(self, **kwargs): from jinja2 import Template from markdown import markdown as convert_markdown extensions = [ 'markdown.extensions.extra', 'markdown.extensions.admonition' ] return convert_markdown(self.markdown, extensions)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_repr_html_'}; {'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', '13', '20', '26']}; {'id': '8', 'type': 'import_from_statement', 'children': ['9', '11']}; {'id': '9', 'type': 'dotted_name', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'jinja2'}; {'id': '11', 'type': 'dotted_name', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Template'}; {'id': '13', 'type': 'import_from_statement', 'children': ['14', '16']}; {'id': '14', 'type': 'dotted_name', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'markdown'}; {'id': '16', 'type': 'aliased_import', 'children': ['17', '19']}; {'id': '17', 'type': 'dotted_name', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'markdown'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'convert_markdown'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'extensions'}; {'id': '23', 'type': 'list', 'children': ['24', '25'], 'value': "[\n 'markdown.extensions.extra',\n 'markdown.extensions.admonition'\n ]"}; {'id': '24', 'type': 'string', 'children': [], 'value': "'markdown.extensions.extra'"}; {'id': '25', 'type': 'string', 'children': [], 'value': "'markdown.extensions.admonition'"}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'convert_markdown'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'markdown'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'extensions'}
Produce HTML for Jupyter Notebook
def copy_image_from_url(url, cache_dir=None, use_cache=True): return cache_image_data(cache_dir, hashlib.sha1(url).hexdigest(), ImgurUploader().upload, url, use_cache=use_cache)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'copy_image_from_url'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'cache_dir'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'use_cache'}; {'id': '10', 'type': 'True', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'cache_image_data'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17', '27', '32', '33']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cache_dir'}; {'id': '17', 'type': 'call', 'children': ['18', '26']}; {'id': '18', 'type': 'attribute', 'children': ['19', '25']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'hashlib'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sha1'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'hexdigest'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ImgurUploader'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'upload'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'use_cache'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'use_cache'}
Copy image from given URL and return upload metadata.
def remove_xml_element(name, tree): remove = tree.findall( ".//{{http://soap.sforce.com/2006/04/metadata}}{}".format(name) ) if not remove: return tree parent_map = {c: p for p in tree.iter() for c in p} for elem in remove: parent = parent_map[elem] parent.remove(elem) return tree
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_xml_element'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '6', 'type': 'block', 'children': ['7', '21', '27', '44', '61']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'findall'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': '".//{{http://soap.sforce.com/2006/04/metadata}}{}"'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '24']}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'parent_map'}; {'id': '30', 'type': 'dictionary_comprehension', 'children': ['31', '34', '41']}; {'id': '31', 'type': 'pair', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '34', 'type': 'for_in_clause', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'iter'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'for_in_clause', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '44', 'type': 'for_statement', 'children': ['45', '46', '47']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'elem'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '47', 'type': 'block', 'children': ['48', '54']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'parent_map'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'elem'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'elem'}; {'id': '61', 'type': 'return_statement', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'tree'}
Removes XML elements from an ElementTree content tree
def echo(topic_name, num_print=None, out=sys.stdout, host=jps.env.get_master_host(), sub_port=jps.DEFAULT_SUB_PORT): class PrintWithCount(object): def __init__(self, out): self._printed = 0 self._out = out def print_and_increment(self, msg): self._out.write('{}\n'.format(msg)) self._printed += 1 def get_count(self): return self._printed counter = PrintWithCount(out) sub = jps.Subscriber( topic_name, counter.print_and_increment, host=host, sub_port=sub_port) try: while num_print is None or counter.get_count() < num_print: sub.spin_once() time.sleep(0.0001) except KeyboardInterrupt: pass
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '27']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'echo'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '13', '22']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'topic_name'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'num_print'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'host'}; {'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': 'jps'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'get_master_host'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'default_parameter', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sub_port'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'jps'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'DEFAULT_SUB_PORT'}; {'id': '27', 'type': 'block', 'children': ['28', '86', '93', '111']}; {'id': '28', 'type': 'class_definition', 'children': ['29', '30', '32']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'PrintWithCount'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '32', 'type': 'block', 'children': ['33', '51', '77']}; {'id': '33', 'type': 'function_definition', 'children': ['34', '35', '38']}; {'id': '34', 'type': 'function_name', 'children': [], 'value': '__init__'}; {'id': '35', 'type': 'parameters', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '38', 'type': 'block', 'children': ['39', '45']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_printed'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_out'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '51', 'type': 'function_definition', 'children': ['52', '53', '56']}; {'id': '52', 'type': 'function_name', 'children': [], 'value': 'print_and_increment'}; {'id': '53', 'type': 'parameters', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '56', 'type': 'block', 'children': ['57', '71']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '64']}; {'id': '59', 'type': 'attribute', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '_out'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'string', 'children': [], 'value': "'{}\\n'"}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'augmented_assignment', 'children': ['73', '76'], 'value': '+='}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': '_printed'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '77', 'type': 'function_definition', 'children': ['78', '79', '81']}; {'id': '78', 'type': 'function_name', 'children': [], 'value': 'get_count'}; {'id': '79', 'type': 'parameters', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'return_statement', 'children': ['83']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': '_printed'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'counter'}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'PrintWithCount'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '96', 'type': 'call', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'jps'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'Subscriber'}; {'id': '100', 'type': 'argument_list', 'children': ['101', '102', '105', '108']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'topic_name'}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'counter'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'print_and_increment'}; {'id': '105', 'type': 'keyword_argument', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '108', 'type': 'keyword_argument', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'sub_port'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'sub_port'}; {'id': '111', 'type': 'try_statement', 'children': ['112', '139']}; {'id': '112', 'type': 'block', 'children': ['113']}; {'id': '113', 'type': 'while_statement', 'children': ['114', '125']}; {'id': '114', 'type': 'boolean_operator', 'children': ['115', '118'], 'value': 'or'}; {'id': '115', 'type': 'comparison_operator', 'children': ['116', '117'], 'value': 'is'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'num_print'}; {'id': '117', 'type': 'None', 'children': []}; {'id': '118', 'type': 'comparison_operator', 'children': ['119', '124'], 'value': '<'}; {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'counter'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'get_count'}; {'id': '123', 'type': 'argument_list', 'children': []}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'num_print'}; {'id': '125', 'type': 'block', 'children': ['126', '132']}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'call', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'spin_once'}; {'id': '131', 'type': 'argument_list', 'children': []}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'call', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'float', 'children': [], 'value': '0.0001'}; {'id': '139', 'type': 'except_clause', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'KeyboardInterrupt'}; {'id': '141', 'type': 'block', 'children': ['142']}; {'id': '142', 'type': 'pass_statement', 'children': []}
print the data for the given topic forever
def post_parse(self): if self.cache and not self.cache_loaded: self.cache_writer_cls(self.file_name, self.wavefront).write()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'post_parse'}; {'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', '15']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '11'], 'value': 'and'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'cache'}; {'id': '11', 'type': 'not_operator', 'children': ['12']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'cache_loaded'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '31']}; {'id': '18', 'type': 'attribute', 'children': ['19', '30']}; {'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': 'cache_writer_cls'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'file_name'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'wavefront'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '31', 'type': 'argument_list', 'children': []}
Called after parsing is done
def combine_sets(*sets): combined = set() for s in sets: combined.update(s) return combined
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'combine_sets'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sets'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '24']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'combined'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '16']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'sets'}; {'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': 'combined'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'combined'}
Combine multiple sets to create a single larger set.
def build_suite(args): loader = Loader() if len(args.files) == 0 or args.files[0] == "-": suite = loader.load_suite_from_stdin() else: suite = loader.load(args.files) return suite
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_suite'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '51']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'loader'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Loader'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'if_statement', 'children': ['13', '29', '38']}; {'id': '13', 'type': 'boolean_operator', 'children': ['14', '22'], 'value': 'or'}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '21'], 'value': '=='}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '21', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '28'], 'value': '=='}; {'id': '23', 'type': 'subscript', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '27', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '28', 'type': 'string', 'children': [], 'value': '"-"'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'suite'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'loader'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'load_suite_from_stdin'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'else_clause', 'children': ['39']}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'suite'}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'loader'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'suite'}
Build a test suite by loading TAP files or a TAP stream.
def remove_module_load(state_dict): new_state_dict = OrderedDict() for k, v in state_dict.items(): new_state_dict[k[7:]] = v return new_state_dict
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_module_load'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'state_dict'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '32']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'new_state_dict'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'for_statement', 'children': ['13', '16', '21']}; {'id': '13', 'type': 'pattern_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'state_dict'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '31']}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'new_state_dict'}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '28', 'type': 'slice', 'children': ['29', '30']}; {'id': '29', 'type': 'integer', 'children': [], 'value': '7'}; {'id': '30', 'type': 'colon', 'children': []}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'new_state_dict'}
create new OrderedDict that does not contain `module.`
def where(self, **overrides): route_data = self.route.copy() route_data.update(overrides) return self.__class__(**route_data)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'where'}; {'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': 'overrides'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '25']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'route_data'}; {'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': 'route'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'route_data'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'overrides'}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'dictionary_splat', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'route_data'}
Creates a new route, based on the current route, with the specified overrided values
def _buildElementNsmap(using_elements): thisMap = {} for e in using_elements: thisMap[e.attrib['prefix']] = e.attrib['namespace'] return thisMap
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_buildElementNsmap'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'using_elements'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '28']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'thisMap'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '13']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'using_elements'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '23']}; {'id': '16', 'type': 'subscript', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'thisMap'}; {'id': '18', 'type': 'subscript', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'attrib'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'prefix'"}; {'id': '23', 'type': 'subscript', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'attrib'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'namespace'"}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'thisMap'}
build a namespace map for an ADMX element
def scores(self, result, add_new_line=True): if result.goalsHomeTeam > result.goalsAwayTeam: homeColor, awayColor = (self.colors.WIN, self.colors.LOSE) elif result.goalsHomeTeam < result.goalsAwayTeam: homeColor, awayColor = (self.colors.LOSE, self.colors.WIN) else: homeColor = awayColor = self.colors.TIE click.secho('%-25s %2s' % (result.homeTeam, result.goalsHomeTeam), fg=homeColor, nl=False) click.secho(" vs ", nl=False) click.secho('%2s %s' % (result.goalsAwayTeam, result.awayTeam.rjust(25)), fg=awayColor, nl=add_new_line)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scores'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'add_new_line'}; {'id': '8', 'type': 'True', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '72', '93', '103']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '18', '35', '60']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '15'], 'value': '>'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'goalsHomeTeam'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'goalsAwayTeam'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '24']}; {'id': '21', 'type': 'pattern_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'homeColor'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'awayColor'}; {'id': '24', 'type': 'tuple', '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': 'colors'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'WIN'}; {'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': 'colors'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'LOSE'}; {'id': '35', 'type': 'elif_clause', 'children': ['36', '43']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '40'], 'value': '<'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'goalsHomeTeam'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'goalsAwayTeam'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '49']}; {'id': '46', 'type': 'pattern_list', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'homeColor'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'awayColor'}; {'id': '49', 'type': 'tuple', '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': 'colors'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'LOSE'}; {'id': '55', 'type': 'attribute', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'colors'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'WIN'}; {'id': '60', 'type': 'else_clause', 'children': ['61']}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'homeColor'}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'awayColor'}; {'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': 'colors'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'TIE'}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'secho'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '87', '90']}; {'id': '78', 'type': 'binary_operator', 'children': ['79', '80'], 'value': '%'}; {'id': '79', 'type': 'string', 'children': [], 'value': "'%-25s %2s'"}; {'id': '80', 'type': 'tuple', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'homeTeam'}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'goalsHomeTeam'}; {'id': '87', 'type': 'keyword_argument', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'homeColor'}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'nl'}; {'id': '92', 'type': 'False', 'children': []}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'secho'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100']}; {'id': '99', 'type': 'string', 'children': [], 'value': '" vs "'}; {'id': '100', 'type': 'keyword_argument', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'nl'}; {'id': '102', 'type': 'False', 'children': []}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'secho'}; {'id': '108', 'type': 'argument_list', 'children': ['109', '123', '126']}; {'id': '109', 'type': 'binary_operator', 'children': ['110', '111'], 'value': '%'}; {'id': '110', 'type': 'string', 'children': [], 'value': "'%2s %s'"}; {'id': '111', 'type': 'tuple', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'goalsAwayTeam'}; {'id': '115', 'type': 'call', 'children': ['116', '121']}; {'id': '116', 'type': 'attribute', 'children': ['117', '120']}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'awayTeam'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'rjust'}; {'id': '121', 'type': 'argument_list', 'children': ['122']}; {'id': '122', 'type': 'integer', 'children': [], 'value': '25'}; {'id': '123', 'type': 'keyword_argument', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'awayColor'}; {'id': '126', 'type': 'keyword_argument', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'nl'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'add_new_line'}
Prints out the scores in a pretty format
def write_spelling(token_folder, spelling_file): token_pattern = r'[a-z]{3,}' tokens = [] for base, dirlist, fnlist in os.walk(token_folder): for fn in fnlist: fp = os.path.join(base, fn) with open(fp) as f: toks = re.findall(token_pattern, f.read()) tokens.extend(toks) token_ranked, _ = zip(*Counter(tokens).most_common()) with open(spelling_file, 'w') as f: f.write('\n'.join(token_ranked))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_spelling'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'token_folder'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'spelling_file'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '15', '75', '92']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'token_pattern'}; {'id': '10', 'type': 'string', 'children': [], 'value': "r'[a-z]{3,}'"}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '14', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '15', 'type': 'for_statement', 'children': ['16', '20', '26']}; {'id': '16', 'type': 'pattern_list', 'children': ['17', '18', '19']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'dirlist'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'fnlist'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'walk'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'token_folder'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'for_statement', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'fnlist'}; {'id': '30', 'type': 'block', 'children': ['31', '43']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'fp'}; {'id': '34', 'type': 'call', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '43', 'type': 'with_statement', 'children': ['44', '53']}; {'id': '44', 'type': 'with_clause', 'children': ['45']}; {'id': '45', 'type': 'with_item', 'children': ['46']}; {'id': '46', 'type': 'as_pattern', 'children': ['47', '51']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'fp'}; {'id': '51', 'type': 'as_pattern_target', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '53', 'type': 'block', 'children': ['54', '68']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'toks'}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'findall'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'token_pattern'}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '67', 'type': 'argument_list', 'children': []}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'toks'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '80']}; {'id': '77', 'type': 'pattern_list', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'token_ranked'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'list_splat', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '91']}; {'id': '85', 'type': 'attribute', 'children': ['86', '90']}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'Counter'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'most_common'}; {'id': '91', 'type': 'argument_list', 'children': []}; {'id': '92', 'type': 'with_statement', 'children': ['93', '103']}; {'id': '93', 'type': 'with_clause', 'children': ['94']}; {'id': '94', 'type': 'with_item', 'children': ['95']}; {'id': '95', 'type': 'as_pattern', 'children': ['96', '101']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'spelling_file'}; {'id': '100', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '101', 'type': 'as_pattern_target', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '103', 'type': 'block', 'children': ['104']}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'token_ranked'}
Generate the spelling correction file form token_folder and save to spelling_file
def _affine_mult(c:FlowField,m:AffineMatrix)->FlowField: "Multiply `c` by `m` - can adjust for rectangular shaped `c`." if m is None: return c size = c.flow.size() h,w = c.size m[0,1] *= h/w m[1,0] *= w/h c.flow = c.flow.view(-1,2) c.flow = torch.addmm(m[:2,2], c.flow, m[:2,:2].t()).view(size) return c
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_affine_mult'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'FlowField'}; {'id': '8', 'type': 'typed_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'AffineMatrix'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'FlowField'}; {'id': '14', 'type': 'block', 'children': ['15', '17', '24', '34', '42', '51', '60', '75', '111']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': '"Multiply `c` by `m` - can adjust for rectangular shaped `c`."'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '21']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': 'is'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'size'}; {'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': 'c'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '39']}; {'id': '36', 'type': 'pattern_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'augmented_assignment', 'children': ['44', '48'], 'value': '*='}; {'id': '44', 'type': 'subscript', 'children': ['45', '46', '47']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '50'], 'value': '/'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'augmented_assignment', 'children': ['53', '57'], 'value': '*='}; {'id': '53', 'type': 'subscript', 'children': ['54', '55', '56']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '55', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '57', 'type': 'binary_operator', 'children': ['58', '59'], 'value': '/'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'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': 'c'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '74']}; {'id': '72', 'type': 'unary_operator', 'children': ['73'], 'value': '-'}; {'id': '73', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '74', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'id': '80', 'type': 'call', 'children': ['81', '109']}; {'id': '81', 'type': 'attribute', 'children': ['82', '108']}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'torch'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'addmm'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '93', '96']}; {'id': '87', 'type': 'subscript', 'children': ['88', '89', '92']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '89', 'type': 'slice', 'children': ['90', '91']}; {'id': '90', 'type': 'colon', 'children': []}; {'id': '91', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '92', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'id': '96', 'type': 'call', 'children': ['97', '107']}; {'id': '97', 'type': 'attribute', 'children': ['98', '106']}; {'id': '98', 'type': 'subscript', 'children': ['99', '100', '103']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '100', 'type': 'slice', 'children': ['101', '102']}; {'id': '101', 'type': 'colon', 'children': []}; {'id': '102', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '103', 'type': 'slice', 'children': ['104', '105']}; {'id': '104', 'type': 'colon', 'children': []}; {'id': '105', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '107', 'type': 'argument_list', 'children': []}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '111', 'type': 'return_statement', 'children': ['112']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'c'}
Multiply `c` by `m` - can adjust for rectangular shaped `c`.
def put_device(self, pin, state, momentary=None, times=None, pause=None): url = self.base_url + '/device' payload = { "pin": pin, "state": state } if momentary is not None: payload["momentary"] = momentary if times is not None: payload["times"] = times if pause is not None: payload["pause"] = pause try: r = requests.put(url, json=payload, timeout=10) return r.json() except RequestException as err: raise Client.ClientError(err)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'put_device'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'pin'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'momentary'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'times'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'pause'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17', '25', '35', '46', '57', '68']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '24'], 'value': '+'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'base_url'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'/device'"}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '28', 'type': 'dictionary', 'children': ['29', '32']}; {'id': '29', 'type': 'pair', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"pin"'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'pin'}; {'id': '32', 'type': 'pair', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': '"state"'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '35', 'type': 'if_statement', 'children': ['36', '39']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': 'is not'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'momentary'}; {'id': '38', 'type': 'None', 'children': []}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '45']}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '44', 'type': 'string', 'children': [], 'value': '"momentary"'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'momentary'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '50']}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '49'], 'value': 'is not'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'times'}; {'id': '49', 'type': 'None', 'children': []}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '56']}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"times"'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'times'}; {'id': '57', 'type': 'if_statement', 'children': ['58', '61']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '60'], 'value': 'is not'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'pause'}; {'id': '60', 'type': 'None', 'children': []}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '67']}; {'id': '64', 'type': 'subscript', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '66', 'type': 'string', 'children': [], 'value': '"pause"'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'pause'}; {'id': '68', 'type': 'try_statement', 'children': ['69', '91']}; {'id': '69', 'type': 'block', 'children': ['70', '85']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'put'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79', '82']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '79', 'type': 'keyword_argument', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '82', 'type': 'keyword_argument', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '85', 'type': 'return_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '90', 'type': 'argument_list', 'children': []}; {'id': '91', 'type': 'except_clause', 'children': ['92', '96']}; {'id': '92', 'type': 'as_pattern', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'RequestException'}; {'id': '94', 'type': 'as_pattern_target', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '96', 'type': 'block', 'children': ['97']}; {'id': '97', 'type': 'raise_statement', 'children': ['98']}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'Client'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'ClientError'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'err'}
Actuate a device pin
def to_json_payload(self, data_rows): num_rows = len(data_rows) num_page = self.num_page num_rows_page = self.num_rows_page pages = num_rows / num_rows_page pages += divmod(num_rows, num_rows_page)[1] and 1 or 0 start = (num_page - 1) * num_rows_page end = num_page * num_rows_page payload = {"page": num_page, "total": pages, "records": num_rows, "rows": data_rows[start:end]} return json.dumps(payload)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_json_payload'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data_rows'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '20', '26', '32', '46', '55', '61', '82']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'num_rows'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'data_rows'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'num_page'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'num_page'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'num_rows_page'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'num_rows_page'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'pages'}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '31'], 'value': '/'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'num_rows'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'num_rows_page'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'augmented_assignment', 'children': ['34', '35'], 'value': '+='}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'pages'}; {'id': '35', 'type': 'boolean_operator', 'children': ['36', '45'], 'value': 'or'}; {'id': '36', 'type': 'boolean_operator', 'children': ['37', '44'], 'value': 'and'}; {'id': '37', 'type': 'subscript', 'children': ['38', '43']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'divmod'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'num_rows'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'num_rows_page'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '1'}; {'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': 'start'}; {'id': '49', 'type': 'binary_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': 'num_page'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'num_rows_page'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '60'], 'value': '*'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'num_page'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'num_rows_page'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '64', 'type': 'dictionary', 'children': ['65', '68', '71', '74']}; {'id': '65', 'type': 'pair', 'children': ['66', '67']}; {'id': '66', 'type': 'string', 'children': [], 'value': '"page"'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'num_page'}; {'id': '68', 'type': 'pair', 'children': ['69', '70']}; {'id': '69', 'type': 'string', 'children': [], 'value': '"total"'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'pages'}; {'id': '71', 'type': 'pair', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': '"records"'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'num_rows'}; {'id': '74', 'type': 'pair', 'children': ['75', '76']}; {'id': '75', 'type': 'string', 'children': [], 'value': '"rows"'}; {'id': '76', 'type': 'subscript', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'data_rows'}; {'id': '78', 'type': 'slice', 'children': ['79', '80', '81']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '80', 'type': 'colon', 'children': []}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '82', 'type': 'return_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'payload'}
Returns the json payload
def _found_barcode(self, record, sample, barcode=None): assert record.id == self.current_record['sequence_name'] self.current_record['sample'] = sample
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_found_barcode'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'barcode'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '21']}; {'id': '11', 'type': 'assert_statement', 'children': ['12']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '16'], 'value': '=='}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '16', 'type': 'subscript', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'current_record'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'sequence_name'"}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '28']}; {'id': '23', 'type': 'subscript', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'current_record'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'sample'"}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'sample'}
Hook called when barcode is found
def dict(self): post_dict = { 'id': self.id, 'link': self.link, 'permalink': self.permalink, 'content_type': self.content_type, 'slug': self.slug, 'updated': self.updated, 'published': self.published, 'title': self.title, 'description': self.description, 'author': self.author, 'categories': self.categories[1:-1].split(',') if self.categories else None, 'summary': self.summary, } if self.attributes: attributes = simplejson.loads(self.attributes) post_dict.update(attributes) return post_dict
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '86', '109']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'post_dict'}; {'id': '9', 'type': 'dictionary', 'children': ['10', '15', '20', '25', '30', '35', '40', '45', '50', '55', '60', '81']}; {'id': '10', 'type': 'pair', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '15', 'type': 'pair', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'link'"}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '20', 'type': 'pair', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'permalink'"}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'permalink'}; {'id': '25', 'type': 'pair', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'content_type'"}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'content_type'}; {'id': '30', 'type': 'pair', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'slug'"}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'slug'}; {'id': '35', 'type': 'pair', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'updated'"}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'updated'}; {'id': '40', 'type': 'pair', 'children': ['41', '42']}; {'id': '41', 'type': 'string', 'children': [], 'value': "'published'"}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'published'}; {'id': '45', 'type': 'pair', 'children': ['46', '47']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'title'"}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '50', 'type': 'pair', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': "'description'"}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '55', 'type': 'pair', 'children': ['56', '57']}; {'id': '56', 'type': 'string', 'children': [], 'value': "'author'"}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'author'}; {'id': '60', 'type': 'pair', 'children': ['61', '62']}; {'id': '61', 'type': 'string', 'children': [], 'value': "'categories'"}; {'id': '62', 'type': 'conditional_expression', 'children': ['63', '77', '80'], 'value': 'if'}; {'id': '63', 'type': 'call', 'children': ['64', '75']}; {'id': '64', 'type': 'attribute', 'children': ['65', '74']}; {'id': '65', 'type': 'subscript', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'categories'}; {'id': '69', 'type': 'slice', 'children': ['70', '71', '72']}; {'id': '70', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '71', 'type': 'colon', 'children': []}; {'id': '72', 'type': 'unary_operator', 'children': ['73'], 'value': '-'}; {'id': '73', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'string', 'children': [], 'value': "','"}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'categories'}; {'id': '80', 'type': 'None', 'children': []}; {'id': '81', 'type': 'pair', 'children': ['82', '83']}; {'id': '82', 'type': 'string', 'children': [], 'value': "'summary'"}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'summary'}; {'id': '86', 'type': 'if_statement', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '90', 'type': 'block', 'children': ['91', '102']}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'simplejson'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'post_dict'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '109', 'type': 'return_statement', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'post_dict'}
Returns dictionary of post fields and attributes
def sitegate_view(*args_dec, **kwargs_dec): if len(args_dec): return signup_view(signin_view(redirect_signedin(*args_dec, **kwargs_dec))) signin = signin_view(**kwargs_dec) signup = signup_view(**kwargs_dec) return lambda *args, **kwargs: signup(signin(redirect_signedin(*args, **kwargs)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sitegate_view'}; {'id': '3', 'type': 'parameters', 'children': ['4', '6']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args_dec'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs_dec'}; {'id': '8', 'type': 'block', 'children': ['9', '29', '37', '45']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '14']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'args_dec'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'signup_view'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'signin_view'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'redirect_signedin'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '27']}; {'id': '25', 'type': 'list_splat', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'args_dec'}; {'id': '27', 'type': 'dictionary_splat', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'kwargs_dec'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'signin'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'signin_view'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'dictionary_splat', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'kwargs_dec'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'signup'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'signup_view'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'dictionary_splat', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'kwargs_dec'}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'lambda', 'children': ['47', '52']}; {'id': '47', 'type': 'lambda_parameters', 'children': ['48', '50']}; {'id': '48', 'type': 'list_splat_pattern', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '50', 'type': 'dictionary_splat_pattern', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'signup'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'signin'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'redirect_signedin'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '63']}; {'id': '61', 'type': 'list_splat', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '63', 'type': 'dictionary_splat', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Decorator to mark views used both for signup & sign in.
def _convert_to_bytes(type_name, value): int_types = {'uint8_t': 'B', 'int8_t': 'b', 'uint16_t': 'H', 'int16_t': 'h', 'uint32_t': 'L', 'int32_t': 'l'} type_name = type_name.lower() if type_name not in int_types and type_name not in ['string', 'binary']: raise ArgumentError('Type must be a known integer type, integer type array, string', known_integers=int_types.keys(), actual_type=type_name) if type_name == 'string': bytevalue = bytes(value) elif type_name == 'binary': bytevalue = bytes(value) else: bytevalue = struct.pack("<%s" % int_types[type_name], value) return bytevalue
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_to_bytes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'type_name'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '6', 'type': 'block', 'children': ['7', '29', '37', '63', '103']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'int_types'}; {'id': '10', 'type': 'dictionary', 'children': ['11', '14', '17', '20', '23', '26']}; {'id': '11', 'type': 'pair', 'children': ['12', '13']}; {'id': '12', 'type': 'string', 'children': [], 'value': "'uint8_t'"}; {'id': '13', 'type': 'string', 'children': [], 'value': "'B'"}; {'id': '14', 'type': 'pair', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'int8_t'"}; {'id': '16', 'type': 'string', 'children': [], 'value': "'b'"}; {'id': '17', 'type': 'pair', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'uint16_t'"}; {'id': '19', 'type': 'string', 'children': [], 'value': "'H'"}; {'id': '20', 'type': 'pair', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'int16_t'"}; {'id': '22', 'type': 'string', 'children': [], 'value': "'h'"}; {'id': '23', 'type': 'pair', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'uint32_t'"}; {'id': '25', 'type': 'string', 'children': [], 'value': "'L'"}; {'id': '26', 'type': 'pair', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'int32_t'"}; {'id': '28', 'type': 'string', 'children': [], 'value': "'l'"}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'type_name'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'type_name'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '36', 'type': 'argument_list', 'children': []}; {'id': '37', 'type': 'if_statement', 'children': ['38', '47']}; {'id': '38', 'type': 'boolean_operator', 'children': ['39', '42'], 'value': 'and'}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '41'], 'value': 'not in'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'type_name'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'int_types'}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': 'not in'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'type_name'}; {'id': '44', 'type': 'list', 'children': ['45', '46'], 'value': "['string', 'binary']"}; {'id': '45', 'type': 'string', 'children': [], 'value': "'string'"}; {'id': '46', 'type': 'string', 'children': [], 'value': "'binary'"}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'raise_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'ArgumentError'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53', '60']}; {'id': '52', 'type': 'string', 'children': [], 'value': "'Type must be a known integer type, integer type array, string'"}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'known_integers'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'int_types'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'actual_type'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'type_name'}; {'id': '63', 'type': 'if_statement', 'children': ['64', '67', '75', '87']}; {'id': '64', 'type': 'comparison_operator', 'children': ['65', '66'], 'value': '=='}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'type_name'}; {'id': '66', 'type': 'string', 'children': [], 'value': "'string'"}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'bytevalue'}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '75', 'type': 'elif_clause', 'children': ['76', '79']}; {'id': '76', 'type': 'comparison_operator', 'children': ['77', '78'], 'value': '=='}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'type_name'}; {'id': '78', 'type': 'string', 'children': [], 'value': "'binary'"}; {'id': '79', 'type': 'block', 'children': ['80']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'bytevalue'}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '87', 'type': 'else_clause', 'children': ['88']}; {'id': '88', 'type': 'block', 'children': ['89']}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'bytevalue'}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '96', 'type': 'argument_list', 'children': ['97', '102']}; {'id': '97', 'type': 'binary_operator', 'children': ['98', '99'], 'value': '%'}; {'id': '98', 'type': 'string', 'children': [], 'value': '"<%s"'}; {'id': '99', 'type': 'subscript', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'int_types'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'type_name'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'bytevalue'}
Convert a typed value to a binary array
async def update(self, db=None, data=None): db = db or self.db if data: self.import_data(data) data = self.prepare_data() else: data = self.export_data(native=True) if self.primary_key not in data or data[self.primary_key] is None: raise Exception('Missing object primary key') query = {self.primary_key: self.pk} for i in self.connection_retries(): try: result = await db[self.get_collection_name()].find_one_and_replace( filter=query, replacement=data, return_document=ReturnDocument.AFTER ) if result: updated_obj = self.create_model(result) updated_obj._db = db asyncio.ensure_future(post_save.send( sender=self.__class__, db=db, instance=updated_obj, created=False) ) return updated_obj return None except ConnectionFailure as ex: exceed = await self.check_reconnect_tries_and_wait(i, 'update') if exceed: raise ex
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}; {'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': 'db'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '20', '51', '71', '82']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '15', 'type': 'boolean_operator', 'children': ['16', '17'], 'value': 'or'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '22', '38']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '22', 'type': 'block', 'children': ['23', '30']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'import_data'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'prepare_data'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'else_clause', 'children': ['39']}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'export_data'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'keyword_argument', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'native'}; {'id': '50', 'type': 'True', 'children': []}; {'id': '51', 'type': 'if_statement', 'children': ['52', '65']}; {'id': '52', 'type': 'boolean_operator', 'children': ['53', '58'], 'value': 'or'}; {'id': '53', 'type': 'comparison_operator', 'children': ['54', '57'], 'value': 'not in'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'primary_key'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '64'], 'value': 'is'}; {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'primary_key'}; {'id': '64', 'type': 'None', 'children': []}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'raise_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'Missing object primary key'"}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '74', 'type': 'dictionary', 'children': ['75']}; {'id': '75', 'type': 'pair', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'primary_key'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '82', 'type': 'for_statement', 'children': ['83', '84', '89']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'connection_retries'}; {'id': '88', 'type': 'argument_list', 'children': []}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'try_statement', 'children': ['91', '165']}; {'id': '91', 'type': 'block', 'children': ['92', '118', '163']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '95', 'type': 'await', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '106']}; {'id': '97', 'type': 'attribute', 'children': ['98', '105']}; {'id': '98', 'type': 'subscript', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '100', 'type': 'call', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'get_collection_name'}; {'id': '104', 'type': 'argument_list', 'children': []}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'find_one_and_replace'}; {'id': '106', 'type': 'argument_list', 'children': ['107', '110', '113']}; {'id': '107', 'type': 'keyword_argument', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '110', 'type': 'keyword_argument', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'replacement'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '113', 'type': 'keyword_argument', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'return_document'}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'ReturnDocument'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'AFTER'}; {'id': '118', 'type': 'if_statement', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '120', 'type': 'block', 'children': ['121', '130', '136', '161']}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'assignment', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'updated_obj'}; {'id': '124', 'type': 'call', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'create_model'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'assignment', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'updated_obj'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': '_db'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}; {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'asyncio'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'ensure_future'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'call', 'children': ['143', '146']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'post_save'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '146', 'type': 'argument_list', 'children': ['147', '152', '155', '158']}; {'id': '147', 'type': 'keyword_argument', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'sender'}; {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '152', 'type': 'keyword_argument', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '155', 'type': 'keyword_argument', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'updated_obj'}; {'id': '158', 'type': 'keyword_argument', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'created'}; {'id': '160', 'type': 'False', 'children': []}; {'id': '161', 'type': 'return_statement', 'children': ['162']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'updated_obj'}; {'id': '163', 'type': 'return_statement', 'children': ['164']}; {'id': '164', 'type': 'None', 'children': []}; {'id': '165', 'type': 'except_clause', 'children': ['166', '170']}; {'id': '166', 'type': 'as_pattern', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'ConnectionFailure'}; {'id': '168', 'type': 'as_pattern_target', 'children': ['169']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '170', 'type': 'block', 'children': ['171', '182']}; {'id': '171', 'type': 'expression_statement', 'children': ['172']}; {'id': '172', 'type': 'assignment', 'children': ['173', '174']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'exceed'}; {'id': '174', 'type': 'await', 'children': ['175']}; {'id': '175', 'type': 'call', 'children': ['176', '179']}; {'id': '176', 'type': 'attribute', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'check_reconnect_tries_and_wait'}; {'id': '179', 'type': 'argument_list', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '181', 'type': 'string', 'children': [], 'value': "'update'"}; {'id': '182', 'type': 'if_statement', 'children': ['183', '184']}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'exceed'}; {'id': '184', 'type': 'block', 'children': ['185']}; {'id': '185', 'type': 'raise_statement', 'children': ['186']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'ex'}
Update the entire document by replacing its content with new data, retaining its primary key
def release_node(self, node): try: node._release_script(keys=[self.resource], args=[self.lock_key]) except (redis.exceptions.ConnectionError, redis.exceptions.TimeoutError): pass
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'release_node'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'try_statement', 'children': ['8', '27']}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_release_script'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '21']}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '17', 'type': 'list', 'children': ['18'], 'value': '[self.resource]'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '23', 'type': 'list', 'children': ['24'], 'value': '[self.lock_key]'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'lock_key'}; {'id': '27', 'type': 'except_clause', 'children': ['28', '39']}; {'id': '28', 'type': 'tuple', 'children': ['29', '34']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'redis'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ConnectionError'}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'redis'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'TimeoutError'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'pass_statement', 'children': []}
release a single redis node
def fill_phenotype_label(self,inplace=False): def _get_phenotype(d): vals = [k for k,v in d.items() if v == 1] return np.nan if len(vals) == 0 else vals[0] if inplace: if self.shape[0] == 0: return self self['phenotype_label'] = self.apply(lambda x: _get_phenotype(x['phenotype_calls']),1) return fixed = self.copy() if fixed.shape[0] == 0: return fixed fixed['phenotype_label'] = fixed.apply(lambda x: _get_phenotype(x['phenotype_calls']),1) return fixed
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fill_phenotype_label'}; {'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': 'inplace'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '46', '81', '89', '100', '120']}; {'id': '9', 'type': 'function_definition', 'children': ['10', '11', '13']}; {'id': '10', 'type': 'function_name', 'children': [], 'value': '_get_phenotype'}; {'id': '11', 'type': 'parameters', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '13', 'type': 'block', 'children': ['14', '32']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '17', 'type': 'list_comprehension', 'children': ['18', '19', '28']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '19', 'type': 'for_in_clause', 'children': ['20', '23']}; {'id': '20', 'type': 'pattern_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'if_clause', 'children': ['29']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': '=='}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'conditional_expression', 'children': ['34', '37', '43'], 'value': 'if'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'nan'}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '42'], 'value': '=='}; {'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': 'vals'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'inplace'}; {'id': '48', 'type': 'block', 'children': ['49', '60', '80']}; {'id': '49', 'type': 'if_statement', 'children': ['50', '57']}; {'id': '50', 'type': 'comparison_operator', 'children': ['51', '56'], 'value': '=='}; {'id': '51', 'type': 'subscript', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '55', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '65']}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'string', 'children': [], 'value': "'phenotype_label'"}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'apply'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '79']}; {'id': '70', 'type': 'lambda', 'children': ['71', '73']}; {'id': '71', 'type': 'lambda_parameters', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': '_get_phenotype'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'subscript', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '78', 'type': 'string', 'children': [], 'value': "'phenotype_calls'"}; {'id': '79', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '80', 'type': 'return_statement', 'children': []}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'fixed'}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '88', 'type': 'argument_list', 'children': []}; {'id': '89', 'type': 'if_statement', 'children': ['90', '97']}; {'id': '90', 'type': 'comparison_operator', 'children': ['91', '96'], 'value': '=='}; {'id': '91', 'type': 'subscript', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'fixed'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '95', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '96', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'return_statement', 'children': ['99']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'fixed'}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '105']}; {'id': '102', 'type': 'subscript', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'fixed'}; {'id': '104', 'type': 'string', 'children': [], 'value': "'phenotype_label'"}; {'id': '105', 'type': 'call', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'fixed'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'apply'}; {'id': '109', 'type': 'argument_list', 'children': ['110', '119']}; {'id': '110', 'type': 'lambda', 'children': ['111', '113']}; {'id': '111', 'type': 'lambda_parameters', 'children': ['112']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '113', 'type': 'call', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': '_get_phenotype'}; {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'subscript', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '118', 'type': 'string', 'children': [], 'value': "'phenotype_calls'"}; {'id': '119', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '120', 'type': 'return_statement', 'children': ['121']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'fixed'}
Set the phenotype_label column according to our rules for mutual exclusion
def register(parser): cmd_login.register(parser) cmd_logout.register(parser) cmd_switch.register(parser) cmd_profiles.register(parser)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '20', '27']}; {'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': 'cmd_login'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'register'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cmd_logout'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'register'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cmd_switch'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'register'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'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': 'cmd_profiles'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'register'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'parser'}
Register profile commands with the given parser.
def endline_semicolon_check(self, original, loc, tokens): return self.check_strict("semicolon at end of line", original, loc, tokens)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'endline_semicolon_check'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'original'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'loc'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'return_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'check_strict'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16', '17', '18']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"semicolon at end of line"'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'original'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'loc'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'tokens'}
Check for semicolons at the end of lines.
def get(name): linkcheckers = get_enabled(ENTRYPOINT, current_app) linkcheckers.update(no_check=NoCheckLinkchecker) selected_linkchecker = linkcheckers.get(name) if not selected_linkchecker: default_linkchecker = current_app.config.get( 'LINKCHECKING_DEFAULT_LINKCHECKER') selected_linkchecker = linkcheckers.get(default_linkchecker) if not selected_linkchecker: log.error('No linkchecker found ({} requested and no fallback)'.format( name)) return selected_linkchecker
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '23', '32', '56', '72']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'linkcheckers'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'get_enabled'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'ENTRYPOINT'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'linkcheckers'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'no_check'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'NoCheckLinkchecker'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'selected_linkchecker'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'linkcheckers'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '32', 'type': 'if_statement', 'children': ['33', '35']}; {'id': '33', 'type': 'not_operator', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'selected_linkchecker'}; {'id': '35', 'type': 'block', 'children': ['36', '47']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'default_linkchecker'}; {'id': '39', 'type': 'call', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'LINKCHECKING_DEFAULT_LINKCHECKER'"}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'selected_linkchecker'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'linkcheckers'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'default_linkchecker'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '59']}; {'id': '57', 'type': 'not_operator', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'selected_linkchecker'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'string', 'children': [], 'value': "'No linkchecker found ({} requested and no fallback)'"}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '72', 'type': 'return_statement', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'selected_linkchecker'}
Get a linkchecker given its name or fallback on default
def _sector_and_sz_itr(self, elf, data_start): for entry_start in itertools.count(data_start, self.FLASH_SECTORS_STRUCT_SIZE): data = elf.read(entry_start, self.FLASH_SECTORS_STRUCT_SIZE) size, start = struct.unpack(self.FLASH_SECTORS_STRUCT, data) start_and_size = start, size if start_and_size == (self.SECTOR_END, self.SECTOR_END): return yield start_and_size
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sector_and_sz_itr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'elf'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'data_start'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'for_statement', 'children': ['9', '10', '19']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'entry_start'}; {'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': 'count'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'data_start'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'FLASH_SECTORS_STRUCT_SIZE'}; {'id': '19', 'type': 'block', 'children': ['20', '32', '46', '52', '64']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'elf'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'entry_start'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'FLASH_SECTORS_STRUCT_SIZE'}; {'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': 'size'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'unpack'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'FLASH_SECTORS_STRUCT'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'start_and_size'}; {'id': '49', 'type': 'expression_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '52', 'type': 'if_statement', 'children': ['53', '62']}; {'id': '53', 'type': 'comparison_operator', 'children': ['54', '55'], 'value': '=='}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'start_and_size'}; {'id': '55', 'type': 'tuple', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'SECTOR_END'}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'SECTOR_END'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'return_statement', 'children': []}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'yield', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'start_and_size'}
Iterator which returns starting address and sector size
def count(self): if self._primary_keys is None: return self.queryset.count() else: return len(self.pks)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'count'}; {'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', '21']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_primary_keys'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'queryset'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'else_clause', 'children': ['22']}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'len'}; {'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': 'pks'}
Return a count of instances.
def sort_by_speedup(self, reverse=True): self._confs.sort(key=lambda c: c.speedup, reverse=reverse) return self
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_by_speedup'}; {'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': 'reverse'}; {'id': '7', 'type': 'True', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '28']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_confs'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '25']}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '19', 'type': 'lambda', 'children': ['20', '22']}; {'id': '20', 'type': 'lambda_parameters', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'speedup'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}
Sort the configurations in place. items with highest speedup come first
def no_operation(self, onerror = None): request.NoOperation(display = self.display, onerror = onerror)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'no_operation'}; {'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': 'onerror'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'NoOperation'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '20']}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'display'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'display'}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'onerror'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'onerror'}
Do nothing but send a request to the server.
def call_env_updated(cls, kb_app, sphinx_app: Sphinx, sphinx_env: BuildEnvironment): for callback in EventAction.get_callbacks(kb_app, SphinxEvent.EU): callback(kb_app, sphinx_app, sphinx_env)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'call_env_updated'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'kb_app'}; {'id': '6', 'type': 'typed_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'sphinx_app'}; {'id': '8', 'type': 'type', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'Sphinx'}; {'id': '10', 'type': 'typed_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'sphinx_env'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'BuildEnvironment'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'for_statement', 'children': ['16', '17', '26']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'callback'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'EventAction'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'get_callbacks'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'kb_app'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'SphinxEvent'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'EU'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'callback'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32', '33']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'kb_app'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'sphinx_app'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'sphinx_env'}
On the env-updated event, do callbacks
def do_encode(cls, obj): if isinstance(obj, ConjureBeanType): return cls.encode_conjure_bean_type(obj) elif isinstance(obj, ConjureUnionType): return cls.encode_conjure_union_type(obj) elif isinstance(obj, ConjureEnumType): return obj.value elif isinstance(obj, list): return list(map(cls.do_encode, obj)) elif isinstance(obj, dict): return {cls.do_encode(key): cls.do_encode(value) for key, value in obj.items()} else: return cls.encode_primitive(obj)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_encode'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13', '21', '35', '46', '64', '95']}; {'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': 'obj'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'ConjureBeanType'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'encode_conjure_bean_type'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '21', 'type': 'elif_clause', 'children': ['22', '27']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ConjureUnionType'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'encode_conjure_union_type'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '35', 'type': 'elif_clause', 'children': ['36', '41']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ConjureEnumType'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '46', 'type': 'elif_clause', 'children': ['47', '52']}; {'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': 'obj'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'do_encode'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '64', 'type': 'elif_clause', 'children': ['65', '70']}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'dictionary_comprehension', 'children': ['73', '86']}; {'id': '73', 'type': 'pair', 'children': ['74', '80']}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'do_encode'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'do_encode'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '86', 'type': 'for_in_clause', 'children': ['87', '90']}; {'id': '87', 'type': 'pattern_list', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '94', 'type': 'argument_list', 'children': []}; {'id': '95', 'type': 'else_clause', 'children': ['96']}; {'id': '96', 'type': 'block', 'children': ['97']}; {'id': '97', 'type': 'return_statement', 'children': ['98']}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'encode_primitive'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'obj'}
Encodes the passed object into json
def _print_throbber(self): self._print('[') for position in range(self._bar_width): self._print('O' if position == self._throbber_index else ' ') self._print(']') self._throbber_index = next(self._throbber_iter)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_print_throbber'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '36', '43']}; {'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': '_print'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'string', 'children': [], 'value': "'['"}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '21']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_bar_width'}; {'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': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_print'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'conditional_expression', 'children': ['29', '30', '35'], 'value': 'if'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'O'"}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': '=='}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_throbber_index'}; {'id': '35', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_print'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'string', 'children': [], 'value': "']'"}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_throbber_index'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'next'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': '_throbber_iter'}
Print an indefinite progress bar.
def fnv(data, hval_init, fnv_prime, fnv_size): assert isinstance(data, bytes) hval = hval_init for byte in data: hval = (hval * fnv_prime) % fnv_size hval = hval ^ _get_byte(byte) return hval
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fnv'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'hval_init'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'fnv_prime'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'fnv_size'}; {'id': '8', 'type': 'block', 'children': ['9', '15', '19', '41']}; {'id': '9', 'type': 'assert_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'hval'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'hval_init'}; {'id': '19', 'type': 'for_statement', 'children': ['20', '21', '22']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'byte'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '22', 'type': 'block', 'children': ['23', '32']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'hval'}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '31'], 'value': '%'}; {'id': '27', 'type': '()', 'children': ['28']}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '30'], 'value': '*'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'hval'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'fnv_prime'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'fnv_size'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'hval'}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '37'], 'value': '^'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'hval'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_get_byte'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'byte'}; {'id': '41', 'type': 'return_statement', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'hval'}
Core FNV hash algorithm used in FNV0 and FNV1.
def _scheduling_block_config(num_blocks=5, start_sbi_id=0, start_pb_id=0, project='sip'): pb_id = start_pb_id for sb_id, sbi_id in _scheduling_block_ids(num_blocks, start_sbi_id, project): sub_array_id = 'subarray-{:02d}'.format(random.choice(range(5))) config = dict(id=sbi_id, sched_block_id=sb_id, sub_array_id=sub_array_id, processing_blocks=_generate_processing_blocks(pb_id)) pb_id += len(config['processing_blocks']) yield config
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_scheduling_block_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'num_blocks'}; {'id': '6', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'start_sbi_id'}; {'id': '9', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'start_pb_id'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '15', 'type': 'string', 'children': [], 'value': "'sip'"}; {'id': '16', 'type': 'block', 'children': ['17', '21']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'pb_id'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'start_pb_id'}; {'id': '21', 'type': 'for_statement', 'children': ['22', '25', '31']}; {'id': '22', 'type': 'pattern_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sb_id'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'sbi_id'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_scheduling_block_ids'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'num_blocks'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'start_sbi_id'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '31', 'type': 'block', 'children': ['32', '49', '70', '79']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'sub_array_id'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': "'subarray-{:02d}'"}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'choice'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '58', '61', '64']}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'sbi_id'}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'sched_block_id'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'sb_id'}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'sub_array_id'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'sub_array_id'}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'processing_blocks'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': '_generate_processing_blocks'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'pb_id'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'augmented_assignment', 'children': ['72', '73'], 'value': '+='}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'pb_id'}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'subscript', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '78', 'type': 'string', 'children': [], 'value': "'processing_blocks'"}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'yield', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'config'}
Return a Scheduling Block Configuration dictionary
def duplicate(self): a_per = self.analysis_period.duplicate() if self.analysis_period else None return self.__class__(self.data_type, self.unit, a_per, deepcopy(self.metadata))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'duplicate'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '21']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'a_per'}; {'id': '9', 'type': 'conditional_expression', 'children': ['10', '17', '20'], 'value': 'if'}; {'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': 'analysis_period'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'duplicate'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'analysis_period'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'return_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': '__class__'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '30', '33', '34']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'a_per'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'deepcopy'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'metadata'}
Return a copy of the header.
def convert_to_btc(self, amount, currency): if isinstance(amount, Decimal): use_decimal = True else: use_decimal = self._force_decimal url = 'https://api.coindesk.com/v1/bpi/currentprice/{}.json'.format(currency) response = requests.get(url) if response.status_code == 200: data = response.json() price = data.get('bpi').get(currency, {}).get('rate_float', None) if price: if use_decimal: price = Decimal(price) try: converted_btc = amount/price return converted_btc except TypeError: raise DecimalFloatMismatchError("convert_to_btc requires amount parameter is of type Decimal when force_decimal=True") raise RatesNotAvailableError("BitCoin Rates Source Not Ready For Given date")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_to_btc'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'amount'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'currency'}; {'id': '7', 'type': 'block', 'children': ['8', '27', '36', '45', '112']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14', '19']}; {'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': 'amount'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'Decimal'}; {'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': 'use_decimal'}; {'id': '18', 'type': 'True', 'children': []}; {'id': '19', 'type': 'else_clause', 'children': ['20']}; {'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': 'use_decimal'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_force_decimal'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'https://api.coindesk.com/v1/bpi/currentprice/{}.json'"}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'currency'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '45', 'type': 'if_statement', 'children': ['46', '51']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '50'], 'value': '=='}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '200'}; {'id': '51', 'type': 'block', 'children': ['52', '60', '81']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'price'}; {'id': '63', 'type': 'call', 'children': ['64', '78']}; {'id': '64', 'type': 'attribute', 'children': ['65', '77']}; {'id': '65', 'type': 'call', 'children': ['66', '74']}; {'id': '66', 'type': 'attribute', 'children': ['67', '73']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'string', 'children': [], 'value': "'bpi'"}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'currency'}; {'id': '76', 'type': 'dictionary', 'children': []}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}; {'id': '79', 'type': 'string', 'children': [], 'value': "'rate_float'"}; {'id': '80', 'type': 'None', 'children': []}; {'id': '81', 'type': 'if_statement', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'price'}; {'id': '83', 'type': 'block', 'children': ['84', '94']}; {'id': '84', 'type': 'if_statement', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'use_decimal'}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'price'}; {'id': '90', 'type': 'call', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'Decimal'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'price'}; {'id': '94', 'type': 'try_statement', 'children': ['95', '104']}; {'id': '95', 'type': 'block', 'children': ['96', '102']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'converted_btc'}; {'id': '99', 'type': 'binary_operator', 'children': ['100', '101'], 'value': '/'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'amount'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'price'}; {'id': '102', 'type': 'return_statement', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'converted_btc'}; {'id': '104', 'type': 'except_clause', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '106', 'type': 'block', 'children': ['107']}; {'id': '107', 'type': 'raise_statement', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'DecimalFloatMismatchError'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'string', 'children': [], 'value': '"convert_to_btc requires amount parameter is of type Decimal when force_decimal=True"'}; {'id': '112', 'type': 'raise_statement', 'children': ['113']}; {'id': '113', 'type': 'call', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'RatesNotAvailableError'}; {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'string', 'children': [], 'value': '"BitCoin Rates Source Not Ready For Given date"'}
Convert X amount to Bit Coins
def get(self, eid): data = self._http_req('connections/%u' % eid) self.debug(0x01, data['decoded']) return data['decoded']
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'eid'}; {'id': '6', 'type': 'block', 'children': ['7', '18', '28']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_http_req'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '17'], 'value': '%'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'connections/%u'"}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'eid'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'integer', 'children': [], 'value': '0x01'}; {'id': '25', 'type': 'subscript', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'decoded'"}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'decoded'"}
Returns a dict with the complete record of the entity with the given eID
def _get_machine_info(parallel, sys_config, dirs, config): if parallel.get("queue") and parallel.get("scheduler"): sched_info_dict = { "slurm": _slurm_info, "torque": _torque_info, "sge": _sge_info } if parallel["scheduler"].lower() in sched_info_dict: try: return sched_info_dict[parallel["scheduler"].lower()](parallel.get("queue", "")) except: logger.exception("Couldn't get machine information from resource query function for queue " "'{0}' on scheduler \"{1}\"; " "submitting job to queue".format(parallel.get("queue", ""), parallel["scheduler"])) else: logger.info("Resource query function not implemented for scheduler \"{0}\"; " "submitting job to queue".format(parallel["scheduler"])) from bcbio.distributed import prun with prun.start(parallel, [[sys_config]], config, dirs) as run_parallel: return run_parallel("machine_info", [[sys_config]])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_machine_info'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'parallel'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sys_config'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'dirs'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '8', 'type': 'block', 'children': ['9', '113', '119']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '23']}; {'id': '10', 'type': 'boolean_operator', 'children': ['11', '17'], 'value': 'and'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'parallel'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': '"queue"'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'parallel'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"scheduler"'}; {'id': '23', 'type': 'block', 'children': ['24', '37']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'sched_info_dict'}; {'id': '27', 'type': 'dictionary', 'children': ['28', '31', '34']}; {'id': '28', 'type': 'pair', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': '"slurm"'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_slurm_info'}; {'id': '31', 'type': 'pair', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': '"torque"'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_torque_info'}; {'id': '34', 'type': 'pair', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': '"sge"'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_sge_info'}; {'id': '37', 'type': 'if_statement', 'children': ['38', '47', '95']}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '46'], 'value': 'in'}; {'id': '39', 'type': 'call', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'parallel'}; {'id': '43', 'type': 'string', 'children': [], 'value': '"scheduler"'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'sched_info_dict'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'try_statement', 'children': ['49', '69']}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '61']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'sched_info_dict'}; {'id': '54', 'type': 'call', 'children': ['55', '60']}; {'id': '55', 'type': 'attribute', 'children': ['56', '59']}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'parallel'}; {'id': '58', 'type': 'string', 'children': [], 'value': '"scheduler"'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '60', 'type': 'argument_list', 'children': []}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'parallel'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '68']}; {'id': '67', 'type': 'string', 'children': [], 'value': '"queue"'}; {'id': '68', 'type': 'string', 'children': [], 'value': '""'}; {'id': '69', 'type': 'except_clause', 'children': ['70']}; {'id': '70', 'type': 'block', 'children': ['71']}; {'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': 'exception'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '84']}; {'id': '78', 'type': 'attribute', 'children': ['79', '83']}; {'id': '79', 'type': 'concatenated_string', 'children': ['80', '81', '82']}; {'id': '80', 'type': 'string', 'children': [], 'value': '"Couldn\'t get machine information from resource query function for queue "'}; {'id': '81', 'type': 'string', 'children': [], 'value': '"\'{0}\' on scheduler \\"{1}\\"; "'}; {'id': '82', 'type': 'string', 'children': [], 'value': '"submitting job to queue"'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '92']}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'parallel'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '89', 'type': 'argument_list', 'children': ['90', '91']}; {'id': '90', 'type': 'string', 'children': [], 'value': '"queue"'}; {'id': '91', 'type': 'string', 'children': [], 'value': '""'}; {'id': '92', 'type': 'subscript', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'parallel'}; {'id': '94', 'type': 'string', 'children': [], 'value': '"scheduler"'}; {'id': '95', 'type': 'else_clause', 'children': ['96']}; {'id': '96', 'type': 'block', 'children': ['97']}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '109']}; {'id': '104', 'type': 'attribute', 'children': ['105', '108']}; {'id': '105', 'type': 'concatenated_string', 'children': ['106', '107']}; {'id': '106', 'type': 'string', 'children': [], 'value': '"Resource query function not implemented for scheduler \\"{0}\\"; "'}; {'id': '107', 'type': 'string', 'children': [], 'value': '"submitting job to queue"'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'subscript', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'parallel'}; {'id': '112', 'type': 'string', 'children': [], 'value': '"scheduler"'}; {'id': '113', 'type': 'import_from_statement', 'children': ['114', '117']}; {'id': '114', 'type': 'dotted_name', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'bcbio'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'distributed'}; {'id': '117', 'type': 'dotted_name', 'children': ['118']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'prun'}; {'id': '119', 'type': 'with_statement', 'children': ['120', '136']}; {'id': '120', 'type': 'with_clause', 'children': ['121']}; {'id': '121', 'type': 'with_item', 'children': ['122']}; {'id': '122', 'type': 'as_pattern', 'children': ['123', '134']}; {'id': '123', 'type': 'call', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'prun'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '127', 'type': 'argument_list', 'children': ['128', '129', '132', '133']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'parallel'}; {'id': '129', 'type': 'list', 'children': ['130'], 'value': '[[sys_config]]'}; {'id': '130', 'type': 'list', 'children': ['131'], 'value': '[sys_config]'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'sys_config'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'dirs'}; {'id': '134', 'type': 'as_pattern_target', 'children': ['135']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'run_parallel'}; {'id': '136', 'type': 'block', 'children': ['137']}; {'id': '137', 'type': 'return_statement', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'run_parallel'}; {'id': '140', 'type': 'argument_list', 'children': ['141', '142']}; {'id': '141', 'type': 'string', 'children': [], 'value': '"machine_info"'}; {'id': '142', 'type': 'list', 'children': ['143'], 'value': '[[sys_config]]'}; {'id': '143', 'type': 'list', 'children': ['144'], 'value': '[sys_config]'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'sys_config'}
Get machine resource information from the job scheduler via either the command line or the queue.
def create_rule(self): return BlockRule( 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_rule'}; {'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': 'BlockRule'}; {'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 block rule services facade.
def register_pivot_wavelength(self, telescope, band, wlen): if (telescope, band) in self._pivot_wavelengths: raise AlreadyDefinedError('pivot wavelength for %s/%s already ' 'defined', telescope, band) self._note(telescope, band) self._pivot_wavelengths[telescope,band] = wlen return self
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register_pivot_wavelength'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'telescope'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'band'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'wlen'}; {'id': '8', 'type': 'block', 'children': ['9', '27', '35', '44']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '17']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '14'], 'value': 'in'}; {'id': '11', 'type': 'tuple', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'telescope'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'band'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_pivot_wavelengths'}; {'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': 'AlreadyDefinedError'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '25', '26']}; {'id': '22', 'type': 'concatenated_string', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'pivot wavelength for %s/%s already '"}; {'id': '24', 'type': 'string', 'children': [], 'value': "'defined'"}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'telescope'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'band'}; {'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': '_note'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'telescope'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'band'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '43']}; {'id': '37', 'type': 'subscript', 'children': ['38', '41', '42']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_pivot_wavelengths'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'telescope'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'band'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'wlen'}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}
Register precomputed pivot wavelengths.
def get(cls, id): client = cls._new_api_client() return client.make_request(cls, 'get', url_params={'id': id})
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '6', 'type': 'block', 'children': ['7', '15']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_new_api_client'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'make_request'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22', '23']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'get'"}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'url_params'}; {'id': '25', 'type': 'dictionary', 'children': ['26']}; {'id': '26', 'type': 'pair', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'id'}
Look up one Union object
def reroot_graph(G: nx.DiGraph, node: str) -> nx.DiGraph: G = G.copy() for n, successors in list(nx.bfs_successors(G, source=node)): for s in successors: G.add_edge(s, n, **G.edges[n, s]) G.remove_edge(n, s) return G
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reroot_graph'}; {'id': '3', 'type': 'parameters', 'children': ['4', '10']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'G'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'nx'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'DiGraph'}; {'id': '10', 'type': 'typed_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'nx'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'DiGraph'}; {'id': '18', 'type': 'block', 'children': ['19', '27', '71']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'G'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'G'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'for_statement', 'children': ['28', '31', '43']}; {'id': '28', 'type': 'pattern_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'successors'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'nx'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'bfs_successors'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'G'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'for_statement', 'children': ['45', '46', '47']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'successors'}; {'id': '47', 'type': 'block', 'children': ['48', '63']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'G'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'add_edge'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55', '56']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '56', 'type': 'dictionary_splat', 'children': ['57']}; {'id': '57', 'type': 'subscript', 'children': ['58', '61', '62']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'G'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'edges'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'G'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'remove_edge'}; {'id': '68', 'type': 'argument_list', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'G'}
Return a copy of the graph rooted at the given node
def json_data(self, name, default=None): value = self.get(name) if value is Missing.Value: return default return value
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'json_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '19', '28']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'value'}; {'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': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '25']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': 'is'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'Missing'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'Value'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'value'}
Get a JSON compatible value of the field
def returns(self) -> T.Optional[DocstringReturns]: try: return next( DocstringReturns.from_meta(meta) for meta in self.meta if meta.args[0] in {"return", "returns", "yield", "yields"} ) except StopIteration: return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'returns'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'type', 'children': ['6']}; {'id': '6', 'type': 'subscript', 'children': ['7', '10']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'Optional'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'DocstringReturns'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'try_statement', 'children': ['13', '41']}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'next'}; {'id': '17', 'type': 'generator_expression', 'children': ['18', '24', '29']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'DocstringReturns'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'from_meta'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '24', 'type': 'for_in_clause', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '29', 'type': 'if_clause', 'children': ['30']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '36'], 'value': 'in'}; {'id': '31', 'type': 'subscript', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '36', 'type': 'set', 'children': ['37', '38', '39', '40']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"return"'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"returns"'}; {'id': '39', 'type': 'string', 'children': [], 'value': '"yield"'}; {'id': '40', 'type': 'string', 'children': [], 'value': '"yields"'}; {'id': '41', 'type': 'except_clause', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'StopIteration'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'None', 'children': []}
Return return information indicated in docstring.
def pip_list(self, name=None, prefix=None, abspath=True): if (name and prefix) or not (name or prefix): raise TypeError("conda pip: exactly one of 'name' ""or 'prefix' " "required.") if name: prefix = self.get_prefix_envname(name) pip_command = os.sep.join([prefix, 'bin', 'python']) cmd_list = [pip_command, PIP_LIST_SCRIPT] process_worker = ProcessWorker(cmd_list, pip=True, parse=True, callback=self._pip_list, extra_kwargs={'prefix': prefix}) process_worker.sig_finished.connect(self._start) self._queue.append(process_worker) self._start() return process_worker
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pip_list'}; {'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': 'name'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '35', '47', '61', '67', '91', '102', '111', '117']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '26']}; {'id': '16', 'type': 'boolean_operator', 'children': ['17', '21'], 'value': 'or'}; {'id': '17', 'type': '()', 'children': ['18']}; {'id': '18', 'type': 'boolean_operator', 'children': ['19', '20'], 'value': 'and'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '21', 'type': 'not_operator', 'children': ['22']}; {'id': '22', 'type': '()', 'children': ['23']}; {'id': '23', 'type': 'boolean_operator', 'children': ['24', '25'], 'value': 'or'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'raise_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'concatenated_string', 'children': ['32', '33', '34']}; {'id': '32', 'type': 'string', 'children': [], 'value': '"conda pip: exactly one of \'name\' "'}; {'id': '33', 'type': 'string', 'children': [], 'value': '"or \'prefix\' "'}; {'id': '34', 'type': 'string', 'children': [], 'value': '"required."'}; {'id': '35', 'type': 'if_statement', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'get_prefix_envname'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'pip_command'}; {'id': '50', 'type': 'call', 'children': ['51', '56']}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'list', 'children': ['58', '59', '60'], 'value': "[prefix, 'bin', 'python']"}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '59', 'type': 'string', 'children': [], 'value': "'bin'"}; {'id': '60', 'type': 'string', 'children': [], 'value': "'python'"}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'cmd_list'}; {'id': '64', 'type': 'list', 'children': ['65', '66'], 'value': '[pip_command, PIP_LIST_SCRIPT]'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'pip_command'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'PIP_LIST_SCRIPT'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'process_worker'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'ProcessWorker'}; {'id': '72', 'type': 'argument_list', 'children': ['73', '74', '77', '80', '85']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'cmd_list'}; {'id': '74', 'type': 'keyword_argument', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'pip'}; {'id': '76', 'type': 'True', 'children': []}; {'id': '77', 'type': 'keyword_argument', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'parse'}; {'id': '79', 'type': 'True', 'children': []}; {'id': '80', 'type': 'keyword_argument', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'callback'}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': '_pip_list'}; {'id': '85', 'type': 'keyword_argument', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'extra_kwargs'}; {'id': '87', 'type': 'dictionary', 'children': ['88']}; {'id': '88', 'type': 'pair', 'children': ['89', '90']}; {'id': '89', 'type': 'string', 'children': [], 'value': "'prefix'"}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '98']}; {'id': '93', 'type': 'attribute', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'process_worker'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'sig_finished'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': '_start'}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '109']}; {'id': '104', 'type': 'attribute', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': '_queue'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'process_worker'}; {'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': 'self'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': '_start'}; {'id': '116', 'type': 'argument_list', 'children': []}; {'id': '117', 'type': 'return_statement', 'children': ['118']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'process_worker'}
Get list of pip installed packages.
def connect(self): self._connect() logger.debug('Connected to Deluge, detecting daemon version') self._detect_deluge_version() logger.debug('Daemon version {} detected, logging in'.format(self.deluge_version)) if self.deluge_version == 2: result = self.call('daemon.login', self.username, self.password, client_version='deluge-client') else: result = self.call('daemon.login', self.username, self.password) logger.debug('Logged in with value %r' % result) self.connected = True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connect'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '19', '25', '39', '81', '90']}; {'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': '_connect'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'Connected to Deluge, detecting daemon version'"}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_detect_deluge_version'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'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': 'logger'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'Daemon version {} detected, logging in'"}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'deluge_version'}; {'id': '39', 'type': 'if_statement', 'children': ['40', '45', '64']}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '44'], 'value': '=='}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'deluge_version'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'call'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55', '58', '61']}; {'id': '54', 'type': 'string', 'children': [], 'value': "'daemon.login'"}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'client_version'}; {'id': '63', 'type': 'string', 'children': [], 'value': "'deluge-client'"}; {'id': '64', 'type': 'else_clause', 'children': ['65']}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'call'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75', '78']}; {'id': '74', 'type': 'string', 'children': [], 'value': "'daemon.login'"}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'binary_operator', 'children': ['88', '89'], 'value': '%'}; {'id': '88', 'type': 'string', 'children': [], 'value': "'Logged in with value %r'"}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'connected'}; {'id': '95', 'type': 'True', 'children': []}
Connects to the Deluge instance
async def read(cls, boot_source, id): if isinstance(boot_source, int): boot_source_id = boot_source elif isinstance(boot_source, BootSource): boot_source_id = boot_source.id else: raise TypeError( "boot_source must be a BootSource or int, not %s" % type(boot_source).__name__) data = await cls._handler.read(boot_source_id=boot_source_id, id=id) return cls(data, {"boot_source_id": boot_source_id})
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'boot_source'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '7', 'type': 'block', 'children': ['8', '46', '63']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14', '19', '32']}; {'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': 'boot_source'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'int'}; {'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': 'boot_source_id'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'boot_source'}; {'id': '19', 'type': 'elif_clause', 'children': ['20', '25']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'boot_source'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'BootSource'}; {'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': 'boot_source_id'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'boot_source'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '32', 'type': 'else_clause', 'children': ['33']}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'raise_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '40'], 'value': '%'}; {'id': '39', 'type': 'string', 'children': [], 'value': '"boot_source must be a BootSource or int, not %s"'}; {'id': '40', 'type': 'attribute', 'children': ['41', '45']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'boot_source'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '49', 'type': 'await', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '56']}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_handler'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '60']}; {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'boot_source_id'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'boot_source_id'}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '68', 'type': 'dictionary', 'children': ['69']}; {'id': '69', 'type': 'pair', 'children': ['70', '71']}; {'id': '70', 'type': 'string', 'children': [], 'value': '"boot_source_id"'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'boot_source_id'}
Get `BootSourceSelection` by `id`.
def getmodeldefinition(self, storageobject, required=False): if isinstance(storageobject, StorageTableModel): definitionlist = [definition for definition in self._modeldefinitions if definition['modelname'] == storageobject.__class__.__name__] elif isinstance(storageobject, StorageTableQuery): storagemodel = storageobject._storagemodel definitionlist = [definition for definition in self._modeldefinitions if definition['modelname'] == storagemodel.__class__.__name__] else: raise Exception("Argument is not an StorageTableModel nor an StorageTableQuery") modeldefinition = None if len(definitionlist) == 1: modeldefinition = definitionlist[0] elif len(definitionlist) > 1: raise ModelRegisteredMoreThanOnceError(storageobject) if required and modeldefinition is None: raise ModelNotRegisteredError(storageobject) return modeldefinition
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getmodeldefinition'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'storageobject'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '8', 'type': 'False', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '77', '81', '108', '120']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '16', '37', '70']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'storageobject'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'StorageTableModel'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'definitionlist'}; {'id': '20', 'type': 'list_comprehension', 'children': ['21', '22', '27']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'definition'}; {'id': '22', 'type': 'for_in_clause', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'definition'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_modeldefinitions'}; {'id': '27', 'type': 'if_clause', 'children': ['28']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '32'], 'value': '=='}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'definition'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'modelname'"}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'storageobject'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '37', 'type': 'elif_clause', 'children': ['38', '43']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'storageobject'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'StorageTableQuery'}; {'id': '43', 'type': 'block', 'children': ['44', '50']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'storagemodel'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'storageobject'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_storagemodel'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'definitionlist'}; {'id': '53', 'type': 'list_comprehension', 'children': ['54', '55', '60']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'definition'}; {'id': '55', 'type': 'for_in_clause', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'definition'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': '_modeldefinitions'}; {'id': '60', 'type': 'if_clause', 'children': ['61']}; {'id': '61', 'type': 'comparison_operator', 'children': ['62', '65'], 'value': '=='}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'definition'}; {'id': '64', 'type': 'string', 'children': [], 'value': "'modelname'"}; {'id': '65', 'type': 'attribute', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'storagemodel'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '70', 'type': 'else_clause', 'children': ['71']}; {'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': 'Exception'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'string', 'children': [], 'value': '"Argument is not an StorageTableModel nor an StorageTableQuery"'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'modeldefinition'}; {'id': '80', 'type': 'None', 'children': []}; {'id': '81', 'type': 'if_statement', 'children': ['82', '88', '95']}; {'id': '82', 'type': 'comparison_operator', 'children': ['83', '87'], 'value': '=='}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'definitionlist'}; {'id': '87', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '88', 'type': 'block', 'children': ['89']}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'modeldefinition'}; {'id': '92', 'type': 'subscript', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'definitionlist'}; {'id': '94', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '95', 'type': 'elif_clause', 'children': ['96', '102']}; {'id': '96', 'type': 'comparison_operator', 'children': ['97', '101'], 'value': '>'}; {'id': '97', 'type': 'call', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'definitionlist'}; {'id': '101', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '102', 'type': 'block', 'children': ['103']}; {'id': '103', 'type': 'raise_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'ModelRegisteredMoreThanOnceError'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'storageobject'}; {'id': '108', 'type': 'if_statement', 'children': ['109', '114']}; {'id': '109', 'type': 'boolean_operator', 'children': ['110', '111'], 'value': 'and'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '111', 'type': 'comparison_operator', 'children': ['112', '113'], 'value': 'is'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'modeldefinition'}; {'id': '113', 'type': 'None', 'children': []}; {'id': '114', 'type': 'block', 'children': ['115']}; {'id': '115', 'type': 'raise_statement', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'ModelNotRegisteredError'}; {'id': '118', 'type': 'argument_list', 'children': ['119']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'storageobject'}; {'id': '120', 'type': 'return_statement', 'children': ['121']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'modeldefinition'}
find modeldefinition for StorageTableModel or StorageTableQuery
def input_files(self): return self.workspace.mets.find_files(fileGrp=self.input_file_grp, pageId=self.page_id)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'input_files'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '15']}; {'id': '8', 'type': 'attribute', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'workspace'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'mets'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'find_files'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '21']}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'fileGrp'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'input_file_grp'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'pageId'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'page_id'}
List the input files
def _first_and_last_element(arr): if isinstance(arr, np.ndarray) or hasattr(arr, 'data'): data = arr.data if sparse.issparse(arr) else arr return data.flat[0], data.flat[-1] else: return arr[0, 0], arr[-1, -1]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_first_and_last_element'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '20', '48']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '15'], 'value': 'or'}; {'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': 'arr'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ndarray'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '20', 'type': 'block', 'children': ['21', '35']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '24', 'type': 'conditional_expression', 'children': ['25', '28', '34'], 'value': 'if'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'sparse'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'issparse'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'expression_list', 'children': ['37', '42']}; {'id': '37', 'type': 'subscript', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'flat'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '42', 'type': 'subscript', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'flat'}; {'id': '46', 'type': 'unary_operator', 'children': ['47'], 'value': '-'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '48', 'type': 'else_clause', 'children': ['49']}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'expression_list', 'children': ['52', '56']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54', '55']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '55', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '56', 'type': 'subscript', 'children': ['57', '58', '60']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '58', 'type': 'unary_operator', 'children': ['59'], 'value': '-'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '60', 'type': 'unary_operator', 'children': ['61'], 'value': '-'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '1'}
Returns first and last element of numpy array or sparse matrix.
def complete_pool_name(arg): search_string = '^' if arg is not None: search_string += arg res = Pool.search({ 'operator': 'regex_match', 'val1': 'name', 'val2': search_string }) ret = [] for p in res['result']: ret.append(p.name) return ret
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'complete_pool_name'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '19', '37', '41', '56']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'search_string'}; {'id': '9', 'type': 'string', 'children': [], 'value': "'^'"}; {'id': '10', 'type': 'if_statement', 'children': ['11', '14']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': 'is not'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'augmented_assignment', 'children': ['17', '18'], 'value': '+='}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'search_string'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'Pool'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'dictionary', 'children': ['28', '31', '34']}; {'id': '28', 'type': 'pair', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'operator'"}; {'id': '30', 'type': 'string', 'children': [], 'value': "'regex_match'"}; {'id': '31', 'type': 'pair', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'val1'"}; {'id': '33', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '34', 'type': 'pair', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'val2'"}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'search_string'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '40', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '41', 'type': 'for_statement', 'children': ['42', '43', '46']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '45', 'type': 'string', 'children': [], 'value': "'result'"}; {'id': '46', 'type': 'block', 'children': ['47']}; {'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': 'ret'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'ret'}
Returns list of matching pool names
def _is_cow(path): dirname = os.path.dirname(path) return 'C' not in __salt__['file.lsattr'](dirname)[path]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_is_cow'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'block', 'children': ['6', '17']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': 'not in'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'C'"}; {'id': '20', 'type': 'subscript', 'children': ['21', '27']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '__salt__'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'file.lsattr'"}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'path'}
Check if the subvolume is copy on write
def _init_kind_converter(self): from ..utils import invert_dict kinds = self.session.query(Kind).all() self._kind_id_to_name = { kind.id: kind.name for kind in kinds } self._kind_name_to_id = invert_dict(self._kind_id_to_name)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_init_kind_converter'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '28', '44']}; {'id': '6', 'type': 'import_from_statement', 'children': ['7', '11']}; {'id': '7', 'type': 'relative_import', 'children': ['8', '9']}; {'id': '8', 'type': 'import_prefix', 'children': []}; {'id': '9', 'type': 'dotted_name', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '11', 'type': 'dotted_name', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'invert_dict'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'kinds'}; {'id': '16', 'type': 'call', 'children': ['17', '27']}; {'id': '17', 'type': 'attribute', 'children': ['18', '26']}; {'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': 'session'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'Kind'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_kind_id_to_name'}; {'id': '33', 'type': 'dictionary_comprehension', 'children': ['34', '41']}; {'id': '34', 'type': 'pair', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'kind'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'kind'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '41', 'type': 'for_in_clause', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'kind'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'kinds'}; {'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': '_kind_name_to_id'}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'invert_dict'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_kind_id_to_name'}
Make a dictionary mapping kind ids to the names.
def unicode_right(s, width): i = len(s) j = 0 for ch in reversed(s): j += __unicode_width_mapping[east_asian_width(ch)] if width < j: break i -= 1 return s[i:]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unicode_right'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '18', '44']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '18', 'type': 'for_statement', 'children': ['19', '20', '24']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ch'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'reversed'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '24', 'type': 'block', 'children': ['25', '34', '40']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'augmented_assignment', 'children': ['27', '28'], 'value': '+='}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '__unicode_width_mapping'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'east_asian_width'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ch'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '38']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': '<'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'break_statement', 'children': []}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'augmented_assignment', 'children': ['42', '43'], 'value': '-='}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '47', 'type': 'slice', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '49', 'type': 'colon', 'children': []}
Cut unicode string from right to fit a given width.
def deregister_entity_from_group(self, entity, group): if entity in self._entities: if entity in self._groups[group]: self._groups[group].remove(entity) else: raise UnmanagedEntityError(entity)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'deregister_entity_from_group'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'entity'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14', '35']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'in'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'entity'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_entities'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '23']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': 'in'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'entity'}; {'id': '18', 'type': 'subscript', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_groups'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '33']}; {'id': '26', 'type': 'attribute', 'children': ['27', '32']}; {'id': '27', 'type': 'subscript', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_groups'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'entity'}; {'id': '35', 'type': 'else_clause', 'children': ['36']}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'raise_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'UnmanagedEntityError'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'entity'}
Removes entity from group
def validate_custom_interpreters_list(self): custom_list = self.get_option('custom_interpreters_list') valid_custom_list = [] for value in custom_list: if (osp.isfile(value) and programs.is_python_interpreter(value) and value != get_python_executable()): valid_custom_list.append(value) self.set_option('custom_interpreters_list', valid_custom_list)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_custom_interpreters_list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '19', '52']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'custom_list'}; {'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_option'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'custom_interpreters_list'"}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'valid_custom_list'}; {'id': '18', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '19', 'type': 'for_statement', 'children': ['20', '21', '22']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'custom_list'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'if_statement', 'children': ['24', '44']}; {'id': '24', 'type': '()', 'children': ['25']}; {'id': '25', 'type': 'boolean_operator', 'children': ['26', '39'], 'value': 'and'}; {'id': '26', 'type': 'boolean_operator', 'children': ['27', '33'], 'value': 'and'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'osp'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'programs'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'is_python_interpreter'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '41'], 'value': '!='}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'get_python_executable'}; {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'valid_custom_list'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'set_option'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59']}; {'id': '58', 'type': 'string', 'children': [], 'value': "'custom_interpreters_list'"}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'valid_custom_list'}
Check that the used custom interpreters are still valid.
def _echo_byte(self, byte): if byte == '\n': self.send_buffer += '\r' if self.telnet_echo_password: self.send_buffer += '*' else: self.send_buffer += byte
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_echo_byte'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'byte'}; {'id': '6', 'type': 'block', 'children': ['7', '18']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': '=='}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'byte'}; {'id': '10', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'augmented_assignment', 'children': ['14', '17'], 'value': '+='}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'send_buffer'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'\\r'"}; {'id': '18', 'type': 'if_statement', 'children': ['19', '22', '29']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'telnet_echo_password'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'augmented_assignment', 'children': ['25', '28'], 'value': '+='}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'send_buffer'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'*'"}; {'id': '29', 'type': 'else_clause', 'children': ['30']}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'augmented_assignment', 'children': ['33', '36'], 'value': '+='}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'send_buffer'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'byte'}
Echo a character back to the client and convert LF into CR\LF.
def push_script(self, scriptable, script, callback=None): if script in self.threads: self.threads[script].finish() thread = Thread(self.run_script(scriptable, script), scriptable, callback) self.new_threads[script] = thread return thread
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'push_script'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'scriptable'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'script'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'callback'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '28', '43', '51']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '17']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'in'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'script'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'threads'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '27']}; {'id': '20', 'type': 'attribute', 'children': ['21', '26']}; {'id': '21', 'type': 'subscript', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'threads'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'script'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'finish'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'thread'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'Thread'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '41', '42']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'run_script'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'scriptable'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'script'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'scriptable'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'callback'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '50']}; {'id': '45', 'type': 'subscript', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'new_threads'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'script'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'thread'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'thread'}
Run the script and add it to the list of threads.
def inputfiles(self, inputtemplate=None): if isinstance(inputtemplate, InputTemplate): inputtemplate = inputtemplate.id for inputfile in self.input: if not inputtemplate or inputfile.metadata.inputtemplate == inputtemplate: yield inputfile
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'inputfiles'}; {'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': 'inputtemplate'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '22']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '15']}; {'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': 'inputtemplate'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'InputTemplate'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'inputtemplate'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'inputtemplate'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '22', 'type': 'for_statement', 'children': ['23', '24', '27']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'inputfile'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'input'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'if_statement', 'children': ['29', '39']}; {'id': '29', 'type': 'boolean_operator', 'children': ['30', '32'], 'value': 'or'}; {'id': '30', 'type': 'not_operator', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'inputtemplate'}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '38'], 'value': '=='}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'inputfile'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'inputtemplate'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'inputtemplate'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'yield', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'inputfile'}
Generator yielding all inputfiles for the specified inputtemplate, if ``inputtemplate=None``, inputfiles are returned regardless of inputtemplate.
def __get_ac_tree(self, ac: model.AssetClass, with_stocks: bool): output = [] output.append(self.__get_ac_row(ac)) for child in ac.classes: output += self.__get_ac_tree(child, with_stocks) if with_stocks: for stock in ac.stocks: row = None if isinstance(stock, Stock): row = self.__get_stock_row(stock, ac.depth + 1) elif isinstance(stock, CashBalance): row = self.__get_cash_row(stock, ac.depth + 1) output.append(row) return output
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__get_ac_tree'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'AssetClass'}; {'id': '11', 'type': 'typed_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'with_stocks'}; {'id': '13', 'type': 'type', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '15', 'type': 'block', 'children': ['16', '20', '32', '48', '110']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '19', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'append'}; {'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': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '__get_ac_row'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '32', 'type': 'for_statement', 'children': ['33', '34', '37']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'classes'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'augmented_assignment', 'children': ['40', '41'], 'value': '+='}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '__get_ac_tree'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'with_stocks'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'with_stocks'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'for_statement', 'children': ['52', '53', '56']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'stock'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'stocks'}; {'id': '56', 'type': 'block', 'children': ['57', '61', '103']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '60', 'type': 'None', 'children': []}; {'id': '61', 'type': 'if_statement', 'children': ['62', '67', '82']}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'stock'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'Stock'}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': '__get_stock_row'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'stock'}; {'id': '77', 'type': 'binary_operator', 'children': ['78', '81'], 'value': '+'}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'depth'}; {'id': '81', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '82', 'type': 'elif_clause', 'children': ['83', '88']}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'stock'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'CashBalance'}; {'id': '88', 'type': 'block', 'children': ['89']}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': '__get_cash_row'}; {'id': '96', 'type': 'argument_list', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'stock'}; {'id': '98', 'type': 'binary_operator', 'children': ['99', '102'], 'value': '+'}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'depth'}; {'id': '102', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '110', 'type': 'return_statement', 'children': ['111']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'output'}
formats the ac tree - entity with child elements
def Decode(self, attribute, value): required_type = self._attribute_types.get(attribute, "bytes") if required_type == "integer": return rdf_structs.SignedVarintReader(value, 0)[0] elif required_type == "unsigned_integer": return rdf_structs.VarintReader(value, 0)[0] elif required_type == "string": if isinstance(value, bytes): return value.decode("utf-8") else: return utils.SmartUnicode(value) else: return value
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Decode'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '7', 'type': 'block', 'children': ['8', '20']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'required_type'}; {'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': '_attribute_types'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"bytes"'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '24', '35', '50', '78']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '23'], 'value': '=='}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'required_type'}; {'id': '23', 'type': 'string', 'children': [], 'value': '"integer"'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'subscript', 'children': ['27', '34']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'rdf_structs'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'SignedVarintReader'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '35', 'type': 'elif_clause', 'children': ['36', '39']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': '=='}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'required_type'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"unsigned_integer"'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'subscript', 'children': ['42', '49']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'rdf_structs'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'VarintReader'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '50', 'type': 'elif_clause', 'children': ['51', '54']}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '53'], 'value': '=='}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'required_type'}; {'id': '53', 'type': 'string', 'children': [], 'value': '"string"'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'if_statement', 'children': ['56', '61', '69']}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'return_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'string', 'children': [], 'value': '"utf-8"'}; {'id': '69', 'type': 'else_clause', 'children': ['70']}; {'id': '70', 'type': 'block', 'children': ['71']}; {'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': 'utils'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'SmartUnicode'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '78', 'type': 'else_clause', 'children': ['79']}; {'id': '79', 'type': 'block', 'children': ['80']}; {'id': '80', 'type': 'return_statement', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'value'}
Decode the value to the required type.
def list_bgp_speakers(self, retrieve_all=True, **_params): return self.list('bgp_speakers', self.bgp_speakers_path, retrieve_all, **_params)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_bgp_speakers'}; {'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': 'retrieve_all'}; {'id': '7', 'type': 'True', 'children': []}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_params'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'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': 'list'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18', '21', '22']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'bgp_speakers'"}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'bgp_speakers_path'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'retrieve_all'}; {'id': '22', 'type': 'dictionary_splat', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_params'}
Fetches a list of all BGP speakers for a project.
def start(self): assert not self.interrupted for thread in self.worker_threads: thread.start() WorkerThread.start(self)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '11', '23']}; {'id': '6', 'type': 'assert_statement', 'children': ['7']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'interrupted'}; {'id': '11', 'type': 'for_statement', 'children': ['12', '13', '16']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'thread'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'worker_threads'}; {'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': 'thread'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'WorkerThread'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}
Starts the coordinator thread and all related worker threads.
def _jobs(): response = salt.utils.http.query( "{0}/scheduler/jobs".format(_base_url()), decode_type='json', decode=True, ) jobs = {} for job in response['dict']: jobs[job.pop('name')] = job return jobs
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_jobs'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '31', '35', '52']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '8', 'type': 'call', 'children': ['9', '16']}; {'id': '9', 'type': 'attribute', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'http'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '25', '28']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': '"{0}/scheduler/jobs"'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_base_url'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'decode_type'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'json'"}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '30', 'type': 'True', 'children': []}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'jobs'}; {'id': '34', 'type': 'dictionary', 'children': []}; {'id': '35', 'type': 'for_statement', 'children': ['36', '37', '40']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'dict'"}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '51']}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'jobs'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'jobs'}
Return the currently configured jobs.
def sweHousesLon(jd, lat, lon, hsys): hsys = SWE_HOUSESYS[hsys] hlist, ascmc = swisseph.houses(jd, lat, lon, hsys) angles = [ ascmc[0], ascmc[1], angle.norm(ascmc[0] + 180), angle.norm(ascmc[1] + 180) ] return (hlist, angles)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sweHousesLon'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'lat'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'lon'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'hsys'}; {'id': '8', 'type': 'block', 'children': ['9', '15', '29', '59']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'hsys'}; {'id': '12', 'type': 'subscript', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'SWE_HOUSESYS'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'hsys'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '20']}; {'id': '17', 'type': 'pattern_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'hlist'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ascmc'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'swisseph'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'houses'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26', '27', '28']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'lat'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'lon'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'hsys'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'angles'}; {'id': '32', 'type': 'list', 'children': ['33', '36', '39', '49'], 'value': '[\n ascmc[0],\n ascmc[1],\n angle.norm(ascmc[0] + 180), \n angle.norm(ascmc[1] + 180)\n ]'}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ascmc'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ascmc'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'norm'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '48'], 'value': '+'}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'ascmc'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '180'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'norm'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'binary_operator', 'children': ['55', '58'], 'value': '+'}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'ascmc'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '180'}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'tuple', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'hlist'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'angles'}
Returns lists with house and angle longitudes.
def write(self, fd): print >>fd, self.classHead for t in self.items: print >>fd, t print >>fd, self.classFoot
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fd'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '23']}; {'id': '7', 'type': 'print_statement', 'children': ['8', '10']}; {'id': '8', 'type': 'chevron', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'fd'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'classHead'}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '18']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'print_statement', 'children': ['20', '22']}; {'id': '20', 'type': 'chevron', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'fd'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '23', 'type': 'print_statement', 'children': ['24', '26']}; {'id': '24', 'type': 'chevron', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'fd'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'classFoot'}
write out to file descriptor.
def _to_micros(dur): if hasattr(dur, 'total_seconds'): return int(dur.total_seconds() * 10e5) return dur.microseconds + (dur.seconds + dur.days * 24 * 3600) * 1000000
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_to_micros'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dur'}; {'id': '5', 'type': 'block', 'children': ['6', '24']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'dur'}; {'id': '11', 'type': 'string', 'children': [], 'value': "'total_seconds'"}; {'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': 'int'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'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': 'dur'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'total_seconds'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'float', 'children': [], 'value': '10e5'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '29'], 'value': '+'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dur'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'microseconds'}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '42'], 'value': '*'}; {'id': '30', 'type': '()', 'children': ['31']}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '35'], 'value': '+'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'dur'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '41'], 'value': '*'}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '40'], 'value': '*'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'dur'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '24'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '3600'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '1000000'}
Convert duration 'dur' to microseconds.
def tcp_client(tcp_addr): family = socket.AF_INET6 if ":" in tcp_addr.ip else socket.AF_INET sock = socket.socket(family, socket.SOCK_STREAM, socket.IPPROTO_TCP) for i in range(300): logging.info("Connecting to: %s, attempt %d", tcp_addr, i) try: sock.connect(tcp_addr) break except socket.error: time.sleep(1) else: sock.connect(tcp_addr) logging.info("Connected.") map_data = read_tcp(sock) settings_str = read_tcp(sock) if not settings_str: raise socket.error("Failed to read") settings = json.loads(settings_str.decode()) logging.info("Got settings. map_name: %s.", settings["map_name"]) logging.debug("settings: %s", settings) settings["map_data"] = map_data return sock, settings
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tcp_client'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'tcp_addr'}; {'id': '5', 'type': 'block', 'children': ['6', '21', '36', '83', '90', '97', '104', '115', '128', '138', '146', '152']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'family'}; {'id': '9', 'type': 'conditional_expression', 'children': ['10', '13', '18'], 'value': 'if'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'AF_INET6'}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '15'], 'value': 'in'}; {'id': '14', 'type': 'string', 'children': [], 'value': '":"'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'tcp_addr'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ip'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'AF_INET'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30', '33']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'family'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'SOCK_STREAM'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'IPPROTO_TCP'}; {'id': '36', 'type': 'for_statement', 'children': ['37', '38', '42', '74']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'integer', 'children': [], 'value': '300'}; {'id': '42', 'type': 'block', 'children': ['43', '52']}; {'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': 'logging'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50', '51']}; {'id': '49', 'type': 'string', 'children': [], 'value': '"Connecting to: %s, attempt %d"'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'tcp_addr'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '52', 'type': 'try_statement', 'children': ['53', '62']}; {'id': '53', 'type': 'block', 'children': ['54', '61']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'tcp_addr'}; {'id': '61', 'type': 'break_statement', 'children': []}; {'id': '62', 'type': 'except_clause', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'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': 'time'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '74', 'type': 'else_clause', 'children': ['75']}; {'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': 'sock'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'tcp_addr'}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'string', 'children': [], 'value': '"Connected."'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'map_data'}; {'id': '93', 'type': 'call', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'read_tcp'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'settings_str'}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'read_tcp'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '104', 'type': 'if_statement', 'children': ['105', '107']}; {'id': '105', 'type': 'not_operator', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'settings_str'}; {'id': '107', 'type': 'block', 'children': ['108']}; {'id': '108', 'type': 'raise_statement', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'string', 'children': [], 'value': '"Failed to read"'}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'assignment', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '118', 'type': 'call', 'children': ['119', '122']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'call', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'settings_str'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '127', 'type': 'argument_list', 'children': []}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}; {'id': '129', 'type': 'call', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '133', 'type': 'argument_list', 'children': ['134', '135']}; {'id': '134', 'type': 'string', 'children': [], 'value': '"Got settings. map_name: %s."'}; {'id': '135', 'type': 'subscript', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '137', 'type': 'string', 'children': [], 'value': '"map_name"'}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}; {'id': '139', 'type': 'call', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '143', 'type': 'argument_list', 'children': ['144', '145']}; {'id': '144', 'type': 'string', 'children': [], 'value': '"settings: %s"'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}; {'id': '147', 'type': 'assignment', 'children': ['148', '151']}; {'id': '148', 'type': 'subscript', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '150', 'type': 'string', 'children': [], 'value': '"map_data"'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'map_data'}; {'id': '152', 'type': 'return_statement', 'children': ['153']}; {'id': '153', 'type': 'expression_list', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'settings'}
Connect to the tcp server, and return the settings.
def initialize_vthunder(a10_cfg, device_cfg, client): vth = a10_cfg.get_vthunder_config() initialize_interfaces(vth, device_cfg, client) initialize_dns(vth, device_cfg, client) initialize_licensing(vth, device_cfg, client) initialize_sflow(vth, device_cfg, client)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'initialize_vthunder'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'a10_cfg'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'device_cfg'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '7', 'type': 'block', 'children': ['8', '16', '23', '30', '37']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'vth'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'a10_cfg'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_vthunder_config'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'initialize_interfaces'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21', '22']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'vth'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'device_cfg'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'initialize_dns'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28', '29']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'vth'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'device_cfg'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'initialize_licensing'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35', '36']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'vth'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'device_cfg'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'initialize_sflow'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42', '43']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'vth'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'device_cfg'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'client'}
Perform initialization of system-wide settings
def textalign(text, maxlength, align='left'): if align == 'left': return text elif align == 'centre' or align == 'center': spaces = ' ' * (int((maxlength - len(text)) / 2)) elif align == 'right': spaces = (maxlength - len(text)) else: raise ValueError("Invalid alignment specified.") return spaces + text
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'textalign'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'maxlength'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'align'}; {'id': '8', 'type': 'string', 'children': [], 'value': "'left'"}; {'id': '9', 'type': 'block', 'children': ['10', '66']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '14', '17', '44', '59']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': '=='}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'align'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'left'"}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '17', 'type': 'elif_clause', 'children': ['18', '25']}; {'id': '18', 'type': 'boolean_operator', 'children': ['19', '22'], 'value': 'or'}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': '=='}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'align'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'centre'"}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '24'], 'value': '=='}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'align'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'center'"}; {'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': 'spaces'}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '31'], 'value': '*'}; {'id': '30', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '31', 'type': '()', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '43'], 'value': '/'}; {'id': '36', 'type': '()', 'children': ['37']}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '-'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'maxlength'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '44', 'type': 'elif_clause', 'children': ['45', '48']}; {'id': '45', 'type': 'comparison_operator', 'children': ['46', '47'], 'value': '=='}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'align'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'right'"}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'spaces'}; {'id': '52', 'type': '()', 'children': ['53']}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '55'], 'value': '-'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'maxlength'}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '59', 'type': 'else_clause', 'children': ['60']}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'raise_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'string', 'children': [], 'value': '"Invalid alignment specified."'}; {'id': '66', 'type': 'return_statement', 'children': ['67']}; {'id': '67', 'type': 'binary_operator', 'children': ['68', '69'], 'value': '+'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'spaces'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'text'}
Align Text When Given Full Length
def unpackmar(marfile, destdir): marfile = cygpath(os.path.abspath(marfile)) nullfd = open(os.devnull, "w") try: check_call([MAR, '-x', marfile], cwd=destdir, stdout=nullfd, preexec_fn=_noumask) except Exception: log.exception("Error unpacking mar file %s to %s", marfile, destdir) raise nullfd.close()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unpackmar'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'marfile'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'destdir'}; {'id': '6', 'type': 'block', 'children': ['7', '21', '31', '63']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'marfile'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'cygpath'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'marfile'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'nullfd'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'devnull'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"w"'}; {'id': '31', 'type': 'try_statement', 'children': ['32', '50']}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'check_call'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '41', '44', '47']}; {'id': '37', 'type': 'list', 'children': ['38', '39', '40'], 'value': "[MAR, '-x', marfile]"}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'MAR'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'-x'"}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'marfile'}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'cwd'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'destdir'}; {'id': '44', 'type': 'keyword_argument', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'nullfd'}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'preexec_fn'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_noumask'}; {'id': '50', 'type': 'except_clause', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '52', 'type': 'block', 'children': ['53', '62']}; {'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': 'exception'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60', '61']}; {'id': '59', 'type': 'string', 'children': [], 'value': '"Error unpacking mar file %s to %s"'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'marfile'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'destdir'}; {'id': '62', 'type': 'raise_statement', 'children': []}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'nullfd'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '68', 'type': 'argument_list', 'children': []}
Unpack marfile into destdir
def display(table, limit=0, vrepr=None, index_header=None, caption=None, tr_style=None, td_styles=None, encoding=None, truncate=None, epilogue=None): from IPython.core.display import display_html html = _display_html(table, limit=limit, vrepr=vrepr, index_header=index_header, caption=caption, tr_style=tr_style, td_styles=td_styles, encoding=encoding, truncate=truncate, epilogue=epilogue) display_html(html, raw=True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '32']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'display'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26', '29']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'vrepr'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'index_header'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'caption'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'tr_style'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'td_styles'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'default_parameter', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'default_parameter', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'truncate'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'default_parameter', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'epilogue'}; {'id': '31', 'type': 'None', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33', '40', '74']}; {'id': '33', 'type': 'import_from_statement', 'children': ['34', '38']}; {'id': '34', 'type': 'dotted_name', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'IPython'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'core'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'display'}; {'id': '38', 'type': 'dotted_name', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'display_html'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_display_html'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47', '50', '53', '56', '59', '62', '65', '68', '71']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'vrepr'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'vrepr'}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'index_header'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'index_header'}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'caption'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'caption'}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'tr_style'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'tr_style'}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'td_styles'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'td_styles'}; {'id': '65', 'type': 'keyword_argument', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '68', 'type': 'keyword_argument', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'truncate'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'truncate'}; {'id': '71', 'type': 'keyword_argument', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'epilogue'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'epilogue'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'display_html'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '79', 'type': 'keyword_argument', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'raw'}; {'id': '81', 'type': 'True', 'children': []}
Display a table inline within an IPython notebook.
def manual_argument_parsing(argv): if not argv or argv == ['-h'] or argv == ['--help']: print_help_and_exit() try: dashdash_index = argv.index('--') except ValueError: print_std_err('Must separate command by `--`') print_help_and_exit() patches, cmd = argv[:dashdash_index], argv[dashdash_index + 1:] if '--help' in patches or '-h' in patches: print_help_and_exit() if '--all' in patches: all_patches = True patches.remove('--all') else: all_patches = False unknown_options = [patch for patch in patches if patch.startswith('-')] if unknown_options: print_std_err('Unknown options: {!r}'.format(unknown_options)) print_help_and_exit() if patches and all_patches: print_std_err('--all and patches specified: {!r}'.format(patches)) print_help_and_exit() return Arguments(all=all_patches, patches=tuple(patches), cmd=tuple(cmd))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'manual_argument_parsing'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '5', 'type': 'block', 'children': ['6', '24', '47', '65', '78', '100', '115', '132', '151']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '19']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '15'], 'value': 'or'}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '11'], 'value': 'or'}; {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': '=='}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '13', 'type': 'list', 'children': ['14'], 'value': "['-h']"}; {'id': '14', 'type': 'string', 'children': [], 'value': "'-h'"}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '17'], 'value': '=='}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '17', 'type': 'list', 'children': ['18'], 'value': "['--help']"}; {'id': '18', 'type': 'string', 'children': [], 'value': "'--help'"}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'print_help_and_exit'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'try_statement', 'children': ['25', '35']}; {'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': 'dashdash_index'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'--'"}; {'id': '35', 'type': 'except_clause', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '37', 'type': 'block', 'children': ['38', '43']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'print_std_err'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'string', 'children': [], 'value': "'Must separate command by `--`'"}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'print_help_and_exit'}; {'id': '46', 'type': 'argument_list', 'children': []}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '52']}; {'id': '49', 'type': 'pattern_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'patches'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '52', 'type': 'expression_list', 'children': ['53', '58']}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '55', 'type': 'slice', 'children': ['56', '57']}; {'id': '56', 'type': 'colon', 'children': []}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'dashdash_index'}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '60', 'type': 'slice', 'children': ['61', '64']}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '63'], 'value': '+'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'dashdash_index'}; {'id': '63', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '64', 'type': 'colon', 'children': []}; {'id': '65', 'type': 'if_statement', 'children': ['66', '73']}; {'id': '66', 'type': 'boolean_operator', 'children': ['67', '70'], 'value': 'or'}; {'id': '67', 'type': 'comparison_operator', 'children': ['68', '69'], 'value': 'in'}; {'id': '68', 'type': 'string', 'children': [], 'value': "'--help'"}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'patches'}; {'id': '70', 'type': 'comparison_operator', 'children': ['71', '72'], 'value': 'in'}; {'id': '71', 'type': 'string', 'children': [], 'value': "'-h'"}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'patches'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'print_help_and_exit'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'if_statement', 'children': ['79', '82', '94']}; {'id': '79', 'type': 'comparison_operator', 'children': ['80', '81'], 'value': 'in'}; {'id': '80', 'type': 'string', 'children': [], 'value': "'--all'"}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'patches'}; {'id': '82', 'type': 'block', 'children': ['83', '87']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'all_patches'}; {'id': '86', 'type': 'True', 'children': []}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'patches'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'string', 'children': [], 'value': "'--all'"}; {'id': '94', 'type': 'else_clause', 'children': ['95']}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'all_patches'}; {'id': '99', 'type': 'False', 'children': []}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'unknown_options'}; {'id': '103', 'type': 'list_comprehension', 'children': ['104', '105', '108']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'patch'}; {'id': '105', 'type': 'for_in_clause', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'patch'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'patches'}; {'id': '108', 'type': 'if_clause', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'patch'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '115', 'type': 'if_statement', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'unknown_options'}; {'id': '117', 'type': 'block', 'children': ['118', '128']}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}; {'id': '119', 'type': 'call', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'print_std_err'}; {'id': '121', 'type': 'argument_list', 'children': ['122']}; {'id': '122', 'type': 'call', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'string', 'children': [], 'value': "'Unknown options: {!r}'"}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'unknown_options'}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}; {'id': '129', 'type': 'call', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'print_help_and_exit'}; {'id': '131', 'type': 'argument_list', 'children': []}; {'id': '132', 'type': 'if_statement', 'children': ['133', '136']}; {'id': '133', 'type': 'boolean_operator', 'children': ['134', '135'], 'value': 'and'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'patches'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'all_patches'}; {'id': '136', 'type': 'block', 'children': ['137', '147']}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'print_std_err'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}; {'id': '141', 'type': 'call', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}; {'id': '143', 'type': 'string', 'children': [], 'value': "'--all and patches specified: {!r}'"}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'patches'}; {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'call', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'print_help_and_exit'}; {'id': '150', 'type': 'argument_list', 'children': []}; {'id': '151', 'type': 'return_statement', 'children': ['152']}; {'id': '152', 'type': 'call', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'Arguments'}; {'id': '154', 'type': 'argument_list', 'children': ['155', '158', '164']}; {'id': '155', 'type': 'keyword_argument', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'all_patches'}; {'id': '158', 'type': 'keyword_argument', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'patches'}; {'id': '160', 'type': 'call', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '162', 'type': 'argument_list', 'children': ['163']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'patches'}; {'id': '164', 'type': 'keyword_argument', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '166', 'type': 'call', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '168', 'type': 'argument_list', 'children': ['169']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'cmd'}
sadness because argparse doesn't quite do what we want.
def _integrate_variable_trajectory(self, h, g, tol, step, relax): solution = np.hstack((self.t, self.y)) while self.successful(): self.integrate(self.t + h, step, relax) current_step = np.hstack((self.t, self.y)) solution = np.vstack((solution, current_step)) if g(self.t, self.y, *self.f_params) < tol: break else: continue return solution
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_integrate_variable_trajectory'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'tol'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'relax'}; {'id': '10', 'type': 'block', 'children': ['11', '26', '93']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'solution'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'hstack'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'tuple', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '26', 'type': 'while_statement', 'children': ['27', '32']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'successful'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33', '46', '61', '72']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'integrate'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '44', '45']}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '43'], 'value': '+'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'relax'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'current_step'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'hstack'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'tuple', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'solution'}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'vstack'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'tuple', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'solution'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'current_step'}; {'id': '72', 'type': 'if_statement', 'children': ['73', '88', '90']}; {'id': '73', 'type': 'comparison_operator', 'children': ['74', '87'], 'value': '<'}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '76', 'type': 'argument_list', 'children': ['77', '80', '83']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '83', 'type': 'list_splat', 'children': ['84']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'f_params'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'tol'}; {'id': '88', 'type': 'block', 'children': ['89']}; {'id': '89', 'type': 'break_statement', 'children': []}; {'id': '90', 'type': 'else_clause', 'children': ['91']}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'continue_statement', 'children': []}; {'id': '93', 'type': 'return_statement', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'solution'}
Generates a solution trajectory of variable length.
def get(self, user_id): user = db.User.find_one(User.user_id == user_id) roles = db.Role.all() if not user: return self.make_response('Unable to find the user requested, might have been removed', HTTP.NOT_FOUND) return self.make_response({ 'user': user.to_json(), 'roles': roles }, HTTP.OK)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '6', 'type': 'block', 'children': ['7', '22', '32', '46']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'user'}; {'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': 'db'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'User'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'find_one'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '21'], 'value': '=='}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'User'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'roles'}; {'id': '25', 'type': 'call', 'children': ['26', '31']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'Role'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'if_statement', 'children': ['33', '35']}; {'id': '33', 'type': 'not_operator', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'make_response'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'string', 'children': [], 'value': "'Unable to find the user requested, might have been removed'"}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'HTTP'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'NOT_FOUND'}; {'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': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'make_response'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '63']}; {'id': '52', 'type': 'dictionary', 'children': ['53', '60']}; {'id': '53', 'type': 'pair', 'children': ['54', '55']}; {'id': '54', 'type': 'string', 'children': [], 'value': "'user'"}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'to_json'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'pair', 'children': ['61', '62']}; {'id': '61', 'type': 'string', 'children': [], 'value': "'roles'"}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'roles'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'HTTP'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'OK'}
Returns a specific user
def wait_for_task(service, task, timeout_sec=120): return time_wait(lambda: task_predicate(service, task), timeout_seconds=timeout_sec)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wait_for_task'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'timeout_sec'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '120'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'return_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'time_wait'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '20']}; {'id': '14', 'type': 'lambda', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'task_predicate'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'timeout_seconds'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'timeout_sec'}
Waits for a task which was launched to be launched