code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def devpiserver_cmdline_run(xom): if xom.config.args.theme == 'semantic-ui': xom.config.args.theme = resource_filename('devpi_semantic_ui', '') xom.log.info("Semantic UI Theme loaded")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'devpiserver_cmdline_run'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'xom'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '16']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '15'], 'value': '=='}; {'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': 'xom'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'theme'}; {'id': '15', 'type': 'string', 'children': [], 'value': "'semantic-ui'"}; {'id': '16', 'type': 'block', 'children': ['17', '31']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '26']}; {'id': '19', 'type': 'attribute', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'xom'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'theme'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'resource_filename'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'devpi_semantic_ui'"}; {'id': '30', 'type': 'string', 'children': [], 'value': "''"}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'xom'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"Semantic UI Theme loaded"'}
Load theme when `theme` parameter is 'semantic-ui'.
def optimize_thumbnail(thumbnail): try: optimize_command = settings.THUMBNAIL_OPTIMIZE_COMMAND[ determinetype(thumbnail.path)] if not optimize_command: return except (TypeError, KeyError, NotImplementedError): return storage = thumbnail.storage try: with NamedTemporaryFile() as temp_file: thumbnail.seek(0) temp_file.write(thumbnail.read()) temp_file.flush() optimize_command = optimize_command.format(filename=temp_file.name) output = check_output( optimize_command, stderr=subprocess.STDOUT, shell=True) if output: logger.warning( '{0} returned {1}'.format(optimize_command, output)) else: logger.info('{0} returned nothing'.format(optimize_command)) with open(temp_file.name, 'rb') as f: thumbnail.file = ContentFile(f.read()) storage.delete(thumbnail.path) storage.save(thumbnail.path, thumbnail) except Exception as e: logger.error(e)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'optimize_thumbnail'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'thumbnail'}; {'id': '5', 'type': 'block', 'children': ['6', '33', '39']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '26']}; {'id': '7', 'type': 'block', 'children': ['8', '21']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'optimize_command'}; {'id': '11', 'type': 'subscript', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'THUMBNAIL_OPTIMIZE_COMMAND'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'determinetype'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'thumbnail'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '24']}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'optimize_command'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': []}; {'id': '26', 'type': 'except_clause', 'children': ['27', '31']}; {'id': '27', 'type': 'tuple', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'NotImplementedError'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'return_statement', 'children': []}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'storage'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'thumbnail'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'storage'}; {'id': '39', 'type': 'try_statement', 'children': ['40', '179']}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'with_statement', 'children': ['42', '50']}; {'id': '42', 'type': 'with_clause', 'children': ['43']}; {'id': '43', 'type': 'with_item', 'children': ['44']}; {'id': '44', 'type': 'as_pattern', 'children': ['45', '48']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'NamedTemporaryFile'}; {'id': '47', 'type': 'argument_list', 'children': []}; {'id': '48', 'type': 'as_pattern_target', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'temp_file'}; {'id': '50', 'type': 'block', 'children': ['51', '58', '69', '75', '88', '103', '133']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'thumbnail'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'seek'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'temp_file'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'thumbnail'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '68', 'type': 'argument_list', 'children': []}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'temp_file'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'flush'}; {'id': '74', 'type': 'argument_list', 'children': []}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'optimize_command'}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'optimize_command'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'keyword_argument', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'temp_file'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'check_output'}; {'id': '93', 'type': 'argument_list', 'children': ['94', '95', '100']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'optimize_command'}; {'id': '95', 'type': 'keyword_argument', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'STDOUT'}; {'id': '100', 'type': 'keyword_argument', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'shell'}; {'id': '102', 'type': 'True', 'children': []}; {'id': '103', 'type': 'if_statement', 'children': ['104', '105', '119']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'call', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'call', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'string', 'children': [], 'value': "'{0} returned {1}'"}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '116', 'type': 'argument_list', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'optimize_command'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '119', 'type': 'else_clause', 'children': ['120']}; {'id': '120', 'type': 'block', 'children': ['121']}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'call', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'call', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'string', 'children': [], 'value': "'{0} returned nothing'"}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '131', 'type': 'argument_list', 'children': ['132']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'optimize_command'}; {'id': '133', 'type': 'with_statement', 'children': ['134', '146']}; {'id': '134', 'type': 'with_clause', 'children': ['135']}; {'id': '135', 'type': 'with_item', 'children': ['136']}; {'id': '136', 'type': 'as_pattern', 'children': ['137', '144']}; {'id': '137', 'type': 'call', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '139', 'type': 'argument_list', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'temp_file'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '143', 'type': 'string', 'children': [], 'value': "'rb'"}; {'id': '144', 'type': 'as_pattern_target', 'children': ['145']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '146', 'type': 'block', 'children': ['147', '160', '169']}; {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'assignment', 'children': ['149', '152']}; {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'thumbnail'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '152', 'type': 'call', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'ContentFile'}; {'id': '154', 'type': 'argument_list', 'children': ['155']}; {'id': '155', 'type': 'call', 'children': ['156', '159']}; {'id': '156', 'type': 'attribute', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '159', 'type': 'argument_list', 'children': []}; {'id': '160', 'type': 'expression_statement', 'children': ['161']}; {'id': '161', 'type': 'call', 'children': ['162', '165']}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'storage'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'delete'}; {'id': '165', 'type': 'argument_list', 'children': ['166']}; {'id': '166', 'type': 'attribute', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'thumbnail'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '169', 'type': 'expression_statement', 'children': ['170']}; {'id': '170', 'type': 'call', 'children': ['171', '174']}; {'id': '171', 'type': 'attribute', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'storage'}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '174', 'type': 'argument_list', 'children': ['175', '178']}; {'id': '175', 'type': 'attribute', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'thumbnail'}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'thumbnail'}; {'id': '179', 'type': 'except_clause', 'children': ['180', '184']}; {'id': '180', 'type': 'as_pattern', 'children': ['181', '182']}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '182', 'type': 'as_pattern_target', 'children': ['183']}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '184', 'type': 'block', 'children': ['185']}; {'id': '185', 'type': 'expression_statement', 'children': ['186']}; {'id': '186', 'type': 'call', 'children': ['187', '190']}; {'id': '187', 'type': 'attribute', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '189', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '190', 'type': 'argument_list', 'children': ['191']}; {'id': '191', 'type': 'identifier', 'children': [], 'value': 'e'}
Optimize thumbnail images by removing unnecessary data
def _split_overlays(self): "Splits overlays inside the HoloMap into list of HoloMaps" if not issubclass(self.type, CompositeOverlay): return None, self.clone() item_maps = OrderedDict() for k, overlay in self.data.items(): for key, el in overlay.items(): if key not in item_maps: item_maps[key] = [(k, el)] else: item_maps[key].append((k, el)) maps, keys = [], [] for k, layermap in item_maps.items(): maps.append(self.clone(layermap)) keys.append(k) return keys, maps
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_split_overlays'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '26', '32', '81', '89', '118']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': '"Splits overlays inside the HoloMap into list of HoloMaps"'}; {'id': '8', 'type': 'if_statement', 'children': ['9', '17']}; {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'issubclass'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'CompositeOverlay'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'expression_list', 'children': ['20', '21']}; {'id': '20', 'type': 'None', 'children': []}; {'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': 'clone'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'item_maps'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'for_statement', 'children': ['33', '36', '43']}; {'id': '33', 'type': 'pattern_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'overlay'}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'for_statement', 'children': ['45', '48', '53']}; {'id': '45', 'type': 'pattern_list', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'el'}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'overlay'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '52', 'type': 'argument_list', 'children': []}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'if_statement', 'children': ['55', '58', '68']}; {'id': '55', 'type': 'comparison_operator', 'children': ['56', '57'], 'value': 'not in'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'item_maps'}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '64']}; {'id': '61', 'type': 'subscript', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'item_maps'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '64', 'type': 'list', 'children': ['65'], 'value': '[(k, el)]'}; {'id': '65', 'type': 'tuple', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'el'}; {'id': '68', 'type': 'else_clause', 'children': ['69']}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '77']}; {'id': '72', 'type': 'attribute', 'children': ['73', '76']}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'item_maps'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'tuple', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'el'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '86']}; {'id': '83', 'type': 'pattern_list', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'maps'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '86', 'type': 'expression_list', 'children': ['87', '88']}; {'id': '87', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '88', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '89', 'type': 'for_statement', 'children': ['90', '93', '98']}; {'id': '90', 'type': 'pattern_list', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'layermap'}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'item_maps'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '97', 'type': 'argument_list', 'children': []}; {'id': '98', 'type': 'block', 'children': ['99', '111']}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'call', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'maps'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'clone'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'layermap'}; {'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': 'keys'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '118', 'type': 'return_statement', 'children': ['119']}; {'id': '119', 'type': 'expression_list', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'maps'}
Splits overlays inside the HoloMap into list of HoloMaps
def interval(best,lo=np.nan,hi=np.nan): return [float(best),[float(lo),float(hi)]]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'interval'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'best'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'lo'}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'nan'}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'hi'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'nan'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'list', 'children': ['18', '22'], 'value': '[float(best),[float(lo),float(hi)]]'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'best'}; {'id': '22', 'type': 'list', 'children': ['23', '27'], 'value': '[float(lo),float(hi)]'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'lo'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'hi'}
Pythonized interval for easy output to yaml
def handle_ctrlchan(handler, msg, nick, send): with handler.db.session_scope() as db: parser = init_parser(send, handler, nick, db) try: cmdargs = parser.parse_args(msg) except arguments.ArgumentException as e: err_str = r"invalid choice: .* \(choose from 'quote', 'help', 'chanserv', 'cs', 'disable', 'enable', 'guard', 'unguard', 'show', 'accept', 'reject'\)" if not re.match(err_str, str(e)): send(str(e)) return cmdargs.func(cmdargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_ctrlchan'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'nick'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'with_statement', 'children': ['10', '22']}; {'id': '10', 'type': 'with_clause', 'children': ['11']}; {'id': '11', 'type': 'with_item', 'children': ['12']}; {'id': '12', 'type': 'as_pattern', 'children': ['13', '20']}; {'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': 'handler'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'session_scope'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'as_pattern_target', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '22', 'type': 'block', 'children': ['23', '33', '78']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'init_parser'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30', '31', '32']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'nick'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '33', 'type': 'try_statement', 'children': ['34', '44']}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'cmdargs'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'parse_args'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '44', 'type': 'except_clause', 'children': ['45', '51']}; {'id': '45', 'type': 'as_pattern', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ArgumentException'}; {'id': '49', 'type': 'as_pattern_target', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '51', 'type': 'block', 'children': ['52', '56', '77']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'err_str'}; {'id': '55', 'type': 'string', 'children': [], 'value': 'r"invalid choice: .* \\(choose from \'quote\', \'help\', \'chanserv\', \'cs\', \'disable\', \'enable\', \'guard\', \'unguard\', \'show\', \'accept\', \'reject\'\\)"'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '68']}; {'id': '57', 'type': 'not_operator', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'err_str'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '77', 'type': 'return_statement', 'children': []}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'cmdargs'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'cmdargs'}
Handle the control channel.
def _move_cursor_to_line(self, line): last_line = self._text_edit.document().blockCount() - 1 self._cursor.clearSelection() self._cursor.movePosition(self._cursor.End) to_insert = '' for i in range(line - last_line): to_insert += '\n' if to_insert: self._cursor.insertText(to_insert) self._cursor.movePosition(self._cursor.Start) self._cursor.movePosition(self._cursor.Down, self._cursor.MoveAnchor, line) self._last_cursor_pos = self._cursor.position()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_move_cursor_to_line'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '6', 'type': 'block', 'children': ['7', '23', '31', '44', '48', '61', '73', '86', '105']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'last_line'}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '22'], 'value': '-'}; {'id': '11', 'type': 'call', 'children': ['12', '21']}; {'id': '12', 'type': 'attribute', 'children': ['13', '20']}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_text_edit'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'document'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'blockCount'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_cursor'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'clearSelection'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_cursor'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'movePosition'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '_cursor'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'End'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'to_insert'}; {'id': '47', 'type': 'string', 'children': [], 'value': "''"}; {'id': '48', 'type': 'for_statement', 'children': ['49', '50', '56']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '55'], 'value': '-'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'last_line'}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'augmented_assignment', 'children': ['59', '60'], 'value': '+='}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'to_insert'}; {'id': '60', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '61', 'type': 'if_statement', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'to_insert'}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '71']}; {'id': '66', 'type': 'attribute', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': '_cursor'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'insertText'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'to_insert'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '80']}; {'id': '75', 'type': 'attribute', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': '_cursor'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'movePosition'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'attribute', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': '_cursor'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'Start'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '93']}; {'id': '88', 'type': 'attribute', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': '_cursor'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'movePosition'}; {'id': '93', 'type': 'argument_list', 'children': ['94', '99', '104']}; {'id': '94', 'type': 'attribute', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': '_cursor'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'Down'}; {'id': '99', 'type': 'attribute', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': '_cursor'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'MoveAnchor'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': '_last_cursor_pos'}; {'id': '110', 'type': 'call', 'children': ['111', '116']}; {'id': '111', 'type': 'attribute', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': '_cursor'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '116', 'type': 'argument_list', 'children': []}
Moves the cursor to the specified line, if possible.
def retrieve_keys(bucket, key, prefix='', postfix='', delim='/', directories=False, recursive=False): if key and prefix: assert key.endswith(delim) key += prefix if not key.endswith(delim) and key: if BotoClient.check_prefix(bucket, key + delim, delim=delim): key += delim listdelim = delim if not recursive else None results = bucket.list(prefix=key, delimiter=listdelim) if postfix: func = lambda k_: BotoClient.filter_predicate(k_, postfix, inclusive=True) return filter(func, results) elif not directories: func = lambda k_: BotoClient.filter_predicate(k_, delim, inclusive=False) return filter(func, results) else: return results
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'retrieve_keys'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'bucket'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '8', 'type': 'string', 'children': [], 'value': "''"}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'postfix'}; {'id': '11', 'type': 'string', 'children': [], 'value': "''"}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'delim'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'directories'}; {'id': '17', 'type': 'False', 'children': []}; {'id': '18', 'type': 'default_parameter', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '20', 'type': 'False', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22', '34', '38', '67', '75', '89']}; {'id': '22', 'type': 'if_statement', 'children': ['23', '26']}; {'id': '23', 'type': 'boolean_operator', 'children': ['24', '25'], 'value': 'and'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'assert_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'delim'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'augmented_assignment', 'children': ['36', '37'], 'value': '+='}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '38', 'type': 'if_statement', 'children': ['39', '48']}; {'id': '39', 'type': 'boolean_operator', 'children': ['40', '47'], 'value': 'and'}; {'id': '40', 'type': 'not_operator', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'delim'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'if_statement', 'children': ['50', '62']}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'BotoClient'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'check_prefix'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56', '59']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'bucket'}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '58'], 'value': '+'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'delim'}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'delim'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'delim'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'augmented_assignment', 'children': ['65', '66'], 'value': '+='}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'delim'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'listdelim'}; {'id': '70', 'type': 'conditional_expression', 'children': ['71', '72', '74'], 'value': 'if'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'delim'}; {'id': '72', 'type': 'not_operator', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '74', 'type': 'None', 'children': []}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'bucket'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '82', 'type': 'argument_list', 'children': ['83', '86']}; {'id': '83', 'type': 'keyword_argument', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '86', 'type': 'keyword_argument', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'delimiter'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'listdelim'}; {'id': '89', 'type': 'if_statement', 'children': ['90', '91', '114', '140']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'postfix'}; {'id': '91', 'type': 'block', 'children': ['92', '108']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '95', 'type': 'lambda', 'children': ['96', '98']}; {'id': '96', 'type': 'lambda_parameters', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'k_'}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'BotoClient'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'filter_predicate'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '104', '105']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'k_'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'postfix'}; {'id': '105', 'type': 'keyword_argument', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'inclusive'}; {'id': '107', 'type': 'True', 'children': []}; {'id': '108', 'type': 'return_statement', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '111', 'type': 'argument_list', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '114', 'type': 'elif_clause', 'children': ['115', '117']}; {'id': '115', 'type': 'not_operator', 'children': ['116']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'directories'}; {'id': '117', 'type': 'block', 'children': ['118', '134']}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}; {'id': '119', 'type': 'assignment', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '121', 'type': 'lambda', 'children': ['122', '124']}; {'id': '122', 'type': 'lambda_parameters', 'children': ['123']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'k_'}; {'id': '124', 'type': 'call', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'BotoClient'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'filter_predicate'}; {'id': '128', 'type': 'argument_list', 'children': ['129', '130', '131']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'k_'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'delim'}; {'id': '131', 'type': 'keyword_argument', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'inclusive'}; {'id': '133', 'type': 'False', 'children': []}; {'id': '134', 'type': 'return_statement', 'children': ['135']}; {'id': '135', 'type': 'call', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '137', 'type': 'argument_list', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '140', 'type': 'else_clause', 'children': ['141']}; {'id': '141', 'type': 'block', 'children': ['142']}; {'id': '142', 'type': 'return_statement', 'children': ['143']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'results'}
Retrieve keys from a bucket
def serialize(self, tag): handler = getattr(self, f'serialize_{tag.serializer}', None) if handler is None: raise TypeError(f'Can\'t serialize {type(tag)!r} instance') return handler(tag)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'serialize'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '26']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14', '15']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'string', 'children': [], 'value': "f'serialize_{tag.serializer}'"}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'if_statement', 'children': ['17', '20']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': 'is'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'raise_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "f'Can\\'t serialize {type(tag)!r} instance'"}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'tag'}
Return the literal representation of a tag.
def devices(self): if self._all_devices: return self._all_devices self._all_devices = {} self._all_devices['cameras'] = [] self._all_devices['base_station'] = [] url = DEVICES_ENDPOINT data = self.query(url) for device in data.get('data'): name = device.get('deviceName') if ((device.get('deviceType') == 'camera' or device.get('deviceType') == 'arloq' or device.get('deviceType') == 'arloqs') and device.get('state') == 'provisioned'): camera = ArloCamera(name, device, self) self._all_devices['cameras'].append(camera) if (device.get('state') == 'provisioned' and (device.get('deviceType') == 'basestation' or device.get('modelId') == 'ABC1000')): base = ArloBaseStation(name, device, self.__token, self) self._all_devices['base_station'].append(base) return self._all_devices
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'devices'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '21', '29', '37', '41', '50', '180']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_all_devices'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_all_devices'}; {'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': '_all_devices'}; {'id': '20', 'type': 'dictionary', 'children': []}; {'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': '_all_devices'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'cameras'"}; {'id': '28', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '36']}; {'id': '31', 'type': 'subscript', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_all_devices'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'base_station'"}; {'id': '36', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'DEVICES_ENDPOINT'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '50', 'type': 'for_statement', 'children': ['51', '52', '58']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '58', 'type': 'block', 'children': ['59', '68', '127']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'string', 'children': [], 'value': "'deviceName'"}; {'id': '68', 'type': 'if_statement', 'children': ['69', '106']}; {'id': '69', 'type': '()', 'children': ['70']}; {'id': '70', 'type': 'boolean_operator', 'children': ['71', '98'], 'value': 'and'}; {'id': '71', 'type': '()', 'children': ['72']}; {'id': '72', 'type': 'boolean_operator', 'children': ['73', '90'], 'value': 'or'}; {'id': '73', 'type': 'boolean_operator', 'children': ['74', '82'], 'value': 'or'}; {'id': '74', 'type': 'comparison_operator', 'children': ['75', '81'], 'value': '=='}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'string', 'children': [], 'value': "'deviceType'"}; {'id': '81', 'type': 'string', 'children': [], 'value': "'camera'"}; {'id': '82', 'type': 'comparison_operator', 'children': ['83', '89'], 'value': '=='}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'string', 'children': [], 'value': "'deviceType'"}; {'id': '89', 'type': 'string', 'children': [], 'value': "'arloq'"}; {'id': '90', 'type': 'comparison_operator', 'children': ['91', '97'], 'value': '=='}; {'id': '91', 'type': 'call', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'string', 'children': [], 'value': "'deviceType'"}; {'id': '97', 'type': 'string', 'children': [], 'value': "'arloqs'"}; {'id': '98', 'type': 'comparison_operator', 'children': ['99', '105'], 'value': '=='}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'string', 'children': [], 'value': "'state'"}; {'id': '105', 'type': 'string', 'children': [], 'value': "'provisioned'"}; {'id': '106', 'type': 'block', 'children': ['107', '116']}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'camera'}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'ArloCamera'}; {'id': '112', 'type': 'argument_list', 'children': ['113', '114', '115']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'call', 'children': ['118', '125']}; {'id': '118', 'type': 'attribute', 'children': ['119', '124']}; {'id': '119', 'type': 'subscript', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': '_all_devices'}; {'id': '123', 'type': 'string', 'children': [], 'value': "'cameras'"}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '125', 'type': 'argument_list', 'children': ['126']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'camera'}; {'id': '127', 'type': 'if_statement', 'children': ['128', '156']}; {'id': '128', 'type': '()', 'children': ['129']}; {'id': '129', 'type': 'boolean_operator', 'children': ['130', '138'], 'value': 'and'}; {'id': '130', 'type': 'comparison_operator', 'children': ['131', '137'], 'value': '=='}; {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'string', 'children': [], 'value': "'state'"}; {'id': '137', 'type': 'string', 'children': [], 'value': "'provisioned'"}; {'id': '138', 'type': '()', 'children': ['139']}; {'id': '139', 'type': 'boolean_operator', 'children': ['140', '148'], 'value': 'or'}; {'id': '140', 'type': 'comparison_operator', 'children': ['141', '147'], 'value': '=='}; {'id': '141', 'type': 'call', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': 'string', 'children': [], 'value': "'deviceType'"}; {'id': '147', 'type': 'string', 'children': [], 'value': "'basestation'"}; {'id': '148', 'type': 'comparison_operator', 'children': ['149', '155'], 'value': '=='}; {'id': '149', 'type': 'call', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '153', 'type': 'argument_list', 'children': ['154']}; {'id': '154', 'type': 'string', 'children': [], 'value': "'modelId'"}; {'id': '155', 'type': 'string', 'children': [], 'value': "'ABC1000'"}; {'id': '156', 'type': 'block', 'children': ['157', '169']}; {'id': '157', 'type': 'expression_statement', 'children': ['158']}; {'id': '158', 'type': 'assignment', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '160', 'type': 'call', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'ArloBaseStation'}; {'id': '162', 'type': 'argument_list', 'children': ['163', '164', '165', '168']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '165', 'type': 'attribute', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': '__token'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '169', 'type': 'expression_statement', 'children': ['170']}; {'id': '170', 'type': 'call', 'children': ['171', '178']}; {'id': '171', 'type': 'attribute', 'children': ['172', '177']}; {'id': '172', 'type': 'subscript', 'children': ['173', '176']}; {'id': '173', 'type': 'attribute', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '175', 'type': 'identifier', 'children': [], 'value': '_all_devices'}; {'id': '176', 'type': 'string', 'children': [], 'value': "'base_station'"}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '178', 'type': 'argument_list', 'children': ['179']}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '180', 'type': 'return_statement', 'children': ['181']}; {'id': '181', 'type': 'attribute', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '183', 'type': 'identifier', 'children': [], 'value': '_all_devices'}
Return all devices on Arlo account.
def op_gen(mcode): gen = op_tbl[mcode[0]] ret = gen[0] nargs = len(gen) i = 1 while i < nargs: if i < len(mcode): ret |= (mcode[i]&gen[i][0]) << gen[i][1] i += 1 return ret
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'op_gen'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'mcode'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '20', '27', '31', '67']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'gen'}; {'id': '9', 'type': 'subscript', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'op_tbl'}; {'id': '11', 'type': 'subscript', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'mcode'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '17', 'type': 'subscript', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'gen'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'nargs'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'gen'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '31', 'type': 'while_statement', 'children': ['32', '35']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '34'], 'value': '<'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'nargs'}; {'id': '35', 'type': 'block', 'children': ['36', '63']}; {'id': '36', 'type': 'if_statement', 'children': ['37', '43']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': '<'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'i'}; {'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': 'mcode'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'augmented_assignment', 'children': ['46', '47'], 'value': '|='}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '47', 'type': 'binary_operator', 'children': ['48', '58'], 'value': '<<'}; {'id': '48', 'type': '()', 'children': ['49']}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '53'], 'value': '&'}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'mcode'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '53', 'type': 'subscript', 'children': ['54', '57']}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'gen'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '58', 'type': 'subscript', 'children': ['59', '62']}; {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'gen'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '62', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'augmented_assignment', 'children': ['65', '66'], 'value': '+='}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '66', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '67', 'type': 'return_statement', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'ret'}
Generate a machine instruction using the op gen table.
def uts46_remap(domain, std3_rules=True, transitional=False): from .uts46data import uts46data output = u"" try: for pos, char in enumerate(domain): code_point = ord(char) uts46row = uts46data[code_point if code_point < 256 else bisect.bisect_left(uts46data, (code_point, "Z")) - 1] status = uts46row[1] replacement = uts46row[2] if len(uts46row) == 3 else None if (status == "V" or (status == "D" and not transitional) or (status == "3" and not std3_rules and replacement is None)): output += char elif replacement is not None and (status == "M" or (status == "3" and not std3_rules) or (status == "D" and transitional)): output += replacement elif status != "I": raise IndexError() return unicodedata.normalize("NFC", output) except IndexError: raise InvalidCodepoint( "Codepoint {0} not allowed at position {1} in {2}".format( _unot(code_point), pos + 1, repr(domain)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'uts46_remap'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'std3_rules'}; {'id': '7', 'type': 'True', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'transitional'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '19', '23']}; {'id': '12', 'type': 'import_from_statement', 'children': ['13', '17']}; {'id': '13', 'type': 'relative_import', 'children': ['14', '15']}; {'id': '14', 'type': 'import_prefix', 'children': []}; {'id': '15', 'type': 'dotted_name', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'uts46data'}; {'id': '17', 'type': 'dotted_name', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'uts46data'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '22', 'type': 'string', 'children': [], 'value': 'u""'}; {'id': '23', 'type': 'try_statement', 'children': ['24', '158']}; {'id': '24', 'type': 'block', 'children': ['25', '150']}; {'id': '25', 'type': 'for_statement', 'children': ['26', '29', '33']}; {'id': '26', 'type': 'pattern_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '33', 'type': 'block', 'children': ['34', '41', '62', '68', '82']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'code_point'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'ord'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'uts46row'}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'uts46data'}; {'id': '46', 'type': 'conditional_expression', 'children': ['47', '48', '51'], 'value': 'if'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'code_point'}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': '<'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'code_point'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '256'}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '61'], 'value': '-'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'bisect'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'bisect_left'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'uts46data'}; {'id': '58', 'type': 'tuple', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'code_point'}; {'id': '60', 'type': 'string', 'children': [], 'value': '"Z"'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'uts46row'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'replacement'}; {'id': '71', 'type': 'conditional_expression', 'children': ['72', '75', '81'], 'value': 'if'}; {'id': '72', 'type': 'subscript', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'uts46row'}; {'id': '74', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '75', 'type': 'comparison_operator', 'children': ['76', '80'], 'value': '=='}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'uts46row'}; {'id': '80', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '81', 'type': 'None', 'children': []}; {'id': '82', 'type': 'if_statement', 'children': ['83', '107', '112', '141']}; {'id': '83', 'type': '()', 'children': ['84']}; {'id': '84', 'type': 'boolean_operator', 'children': ['85', '96'], 'value': 'or'}; {'id': '85', 'type': 'boolean_operator', 'children': ['86', '89'], 'value': 'or'}; {'id': '86', 'type': 'comparison_operator', 'children': ['87', '88'], 'value': '=='}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '88', 'type': 'string', 'children': [], 'value': '"V"'}; {'id': '89', 'type': '()', 'children': ['90']}; {'id': '90', 'type': 'boolean_operator', 'children': ['91', '94'], 'value': 'and'}; {'id': '91', 'type': 'comparison_operator', 'children': ['92', '93'], 'value': '=='}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '93', 'type': 'string', 'children': [], 'value': '"D"'}; {'id': '94', 'type': 'not_operator', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'transitional'}; {'id': '96', 'type': '()', 'children': ['97']}; {'id': '97', 'type': 'boolean_operator', 'children': ['98', '104'], 'value': 'and'}; {'id': '98', 'type': 'boolean_operator', 'children': ['99', '102'], 'value': 'and'}; {'id': '99', 'type': 'comparison_operator', 'children': ['100', '101'], 'value': '=='}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '101', 'type': 'string', 'children': [], 'value': '"3"'}; {'id': '102', 'type': 'not_operator', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'std3_rules'}; {'id': '104', 'type': 'comparison_operator', 'children': ['105', '106'], 'value': 'is'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'replacement'}; {'id': '106', 'type': 'None', 'children': []}; {'id': '107', 'type': 'block', 'children': ['108']}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'augmented_assignment', 'children': ['110', '111'], 'value': '+='}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '112', 'type': 'elif_clause', 'children': ['113', '136']}; {'id': '113', 'type': 'boolean_operator', 'children': ['114', '117'], 'value': 'and'}; {'id': '114', 'type': 'comparison_operator', 'children': ['115', '116'], 'value': 'is not'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'replacement'}; {'id': '116', 'type': 'None', 'children': []}; {'id': '117', 'type': '()', 'children': ['118']}; {'id': '118', 'type': 'boolean_operator', 'children': ['119', '130'], 'value': 'or'}; {'id': '119', 'type': 'boolean_operator', 'children': ['120', '123'], 'value': 'or'}; {'id': '120', 'type': 'comparison_operator', 'children': ['121', '122'], 'value': '=='}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '122', 'type': 'string', 'children': [], 'value': '"M"'}; {'id': '123', 'type': '()', 'children': ['124']}; {'id': '124', 'type': 'boolean_operator', 'children': ['125', '128'], 'value': 'and'}; {'id': '125', 'type': 'comparison_operator', 'children': ['126', '127'], 'value': '=='}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '127', 'type': 'string', 'children': [], 'value': '"3"'}; {'id': '128', 'type': 'not_operator', 'children': ['129']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'std3_rules'}; {'id': '130', 'type': '()', 'children': ['131']}; {'id': '131', 'type': 'boolean_operator', 'children': ['132', '135'], 'value': 'and'}; {'id': '132', 'type': 'comparison_operator', 'children': ['133', '134'], 'value': '=='}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '134', 'type': 'string', 'children': [], 'value': '"D"'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'transitional'}; {'id': '136', 'type': 'block', 'children': ['137']}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'augmented_assignment', 'children': ['139', '140'], 'value': '+='}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'replacement'}; {'id': '141', 'type': 'elif_clause', 'children': ['142', '145']}; {'id': '142', 'type': 'comparison_operator', 'children': ['143', '144'], 'value': '!='}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '144', 'type': 'string', 'children': [], 'value': '"I"'}; {'id': '145', 'type': 'block', 'children': ['146']}; {'id': '146', 'type': 'raise_statement', 'children': ['147']}; {'id': '147', 'type': 'call', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'IndexError'}; {'id': '149', 'type': 'argument_list', 'children': []}; {'id': '150', 'type': 'return_statement', 'children': ['151']}; {'id': '151', 'type': 'call', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'unicodedata'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'normalize'}; {'id': '155', 'type': 'argument_list', 'children': ['156', '157']}; {'id': '156', 'type': 'string', 'children': [], 'value': '"NFC"'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '158', 'type': 'except_clause', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'IndexError'}; {'id': '160', 'type': 'block', 'children': ['161']}; {'id': '161', 'type': 'raise_statement', 'children': ['162']}; {'id': '162', 'type': 'call', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'InvalidCodepoint'}; {'id': '164', 'type': 'argument_list', 'children': ['165']}; {'id': '165', 'type': 'call', 'children': ['166', '169']}; {'id': '166', 'type': 'attribute', 'children': ['167', '168']}; {'id': '167', 'type': 'string', 'children': [], 'value': '"Codepoint {0} not allowed at position {1} in {2}"'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '169', 'type': 'argument_list', 'children': ['170', '174', '177']}; {'id': '170', 'type': 'call', 'children': ['171', '172']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': '_unot'}; {'id': '172', 'type': 'argument_list', 'children': ['173']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'code_point'}; {'id': '174', 'type': 'binary_operator', 'children': ['175', '176'], 'value': '+'}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '176', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '177', 'type': 'call', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '179', 'type': 'argument_list', 'children': ['180']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'domain'}
Re-map the characters in the string according to UTS46 processing.
def balance(self, account: Address): return self.web3.eth.getBalance(to_checksum_address(account), 'pending')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'balance'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'account'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Address'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'return_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '19']}; {'id': '12', 'type': 'attribute', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'web3'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'eth'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'getBalance'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '24']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'to_checksum_address'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'account'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'pending'"}
Return the balance of the account of the given address.
def maybe_start_recording(tokens, index): if _is_really_comment(tokens, index): return _CommentedLineRecorder(index, tokens[index].line) return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'maybe_start_recording'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '6', 'type': 'block', 'children': ['7', '24']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_is_really_comment'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'index'}; {'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': '_CommentedLineRecorder'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'None', 'children': []}
Return a new _CommentedLineRecorder when it is time to record.
def move_backward(self): self.at(ardrone.at.pcmd, True, 0, self.speed, 0, 0)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'move_backward'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'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': 'at'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '17', '18', '19', '22', '23']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ardrone'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'at'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'pcmd'}; {'id': '17', 'type': 'True', 'children': []}; {'id': '18', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'speed'}; {'id': '22', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0'}
Make the drone move backwards.
def perform_get_or_create(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) process = serializer.validated_data.get('process') process_input = request.data.get('input', {}) fill_with_defaults(process_input, process.input_schema) checksum = get_data_checksum(process_input, process.slug, process.version) data_qs = Data.objects.filter( checksum=checksum, process__persistence__in=[Process.PERSISTENCE_CACHED, Process.PERSISTENCE_TEMP], ) data_qs = get_objects_for_user(request.user, 'view_data', data_qs) if data_qs.exists(): data = data_qs.order_by('created').last() serializer = self.get_serializer(data) return Response(serializer.data)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'perform_get_or_create'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'list_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11', '24', '33', '44', '56', '64', '77', '99', '110']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'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': 'get_serializer'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'data'}; {'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': 'serializer'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'is_valid'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'raise_exception'}; {'id': '32', 'type': 'True', 'children': []}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'process'}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'validated_data'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'process'"}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'process_input'}; {'id': '47', 'type': 'call', 'children': ['48', '53']}; {'id': '48', 'type': 'attribute', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'string', 'children': [], 'value': "'input'"}; {'id': '55', 'type': 'dictionary', 'children': []}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'fill_with_defaults'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'process_input'}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'process'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'input_schema'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'checksum'}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'get_data_checksum'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '71', '74']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'process_input'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'process'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'slug'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'process'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'data_qs'}; {'id': '80', 'type': 'call', 'children': ['81', '86']}; {'id': '81', 'type': 'attribute', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'Data'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '90']}; {'id': '87', 'type': 'keyword_argument', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'checksum'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'checksum'}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'process__persistence__in'}; {'id': '92', 'type': 'list', 'children': ['93', '96'], 'value': '[Process.PERSISTENCE_CACHED, Process.PERSISTENCE_TEMP]'}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'Process'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'PERSISTENCE_CACHED'}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'Process'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'PERSISTENCE_TEMP'}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'data_qs'}; {'id': '102', 'type': 'call', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'get_objects_for_user'}; {'id': '104', 'type': 'argument_list', 'children': ['105', '108', '109']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '108', 'type': 'string', 'children': [], 'value': "'view_data'"}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'data_qs'}; {'id': '110', 'type': 'if_statement', 'children': ['111', '116']}; {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'data_qs'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '115', 'type': 'argument_list', 'children': []}; {'id': '116', 'type': 'block', 'children': ['117', '130', '139']}; {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'assignment', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '120', 'type': 'call', 'children': ['121', '129']}; {'id': '121', 'type': 'attribute', 'children': ['122', '128']}; {'id': '122', 'type': 'call', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'data_qs'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'order_by'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'string', 'children': [], 'value': "'created'"}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'last'}; {'id': '129', 'type': 'argument_list', 'children': []}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'assignment', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '133', 'type': 'call', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'get_serializer'}; {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '139', 'type': 'return_statement', 'children': ['140']}; {'id': '140', 'type': 'call', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'Response'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'data'}
Perform "get_or_create" - return existing object if found.
def _update_asset_content_url_to_match_id(self, ac): mgr = self._provider_session._get_provider_manager('REPOSITORY') aas = mgr.get_asset_admin_session_for_repository(self._provider_session._catalog_id, proxy=self._provider_session._proxy) form = aas.get_asset_content_form_for_update(ac.ident) url = ac._my_map['url'] old_url = os.path.splitext(os.path.basename(url))[0] new_url = url.replace(old_url, ac.ident.identifier) form.set_url(new_url) return aas.update_asset_content(form)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_asset_content_url_to_match_id'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '6', 'type': 'block', 'children': ['7', '18', '38', '49', '57', '77', '91', '98']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'mgr'}; {'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': '_provider_session'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_get_provider_manager'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'REPOSITORY'"}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'aas'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'mgr'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'get_asset_admin_session_for_repository'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '31']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_provider_session'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_catalog_id'}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_provider_session'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_proxy'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'aas'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'get_asset_content_form_for_update'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ident'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '52', 'type': 'subscript', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_my_map'}; {'id': '56', 'type': 'string', 'children': [], 'value': "'url'"}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'old_url'}; {'id': '60', 'type': 'subscript', 'children': ['61', '76']}; {'id': '61', 'type': 'call', 'children': ['62', '67']}; {'id': '62', 'type': 'attribute', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'splitext'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '74']}; {'id': '69', 'type': 'attribute', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'new_url'}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'old_url'}; {'id': '86', 'type': 'attribute', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'ident'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'set_url'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'new_url'}; {'id': '98', 'type': 'return_statement', 'children': ['99']}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'aas'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'update_asset_content'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'form'}
update the ac URL value to match the ident
def bind_blueprint(pale_api_module, flask_blueprint): if not isinstance(flask_blueprint, Blueprint): raise TypeError(("pale.flask_adapter.bind_blueprint expected the " "passed in flask_blueprint to be an instance of " "Blueprint, but it was an instance of %s instead.") % (type(flask_blueprint),)) if not pale.is_pale_module(pale_api_module): raise TypeError(("pale.flask_adapter.bind_blueprint expected the " "passed in pale_api_module to be a module, and to " "have a _module_type defined to equal " "pale.ImplementationModule, but it was an instance of " "%s instead.") % (type(pale_api_module),)) endpoints = pale.extract_endpoints(pale_api_module) for endpoint in endpoints: endpoint._set_response_class(RESPONSE_CLASS) method = [endpoint._http_method] name = endpoint._route_name handler = endpoint._execute flask_blueprint.add_url_rule( endpoint._uri, name, view_func=ContextualizedHandler(handler), methods=method)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bind_blueprint'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pale_api_module'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'flask_blueprint'}; {'id': '6', 'type': 'block', 'children': ['7', '30', '56', '65']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'flask_blueprint'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'Blueprint'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'raise_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '25'], 'value': '%'}; {'id': '20', 'type': '()', 'children': ['21']}; {'id': '21', 'type': 'concatenated_string', 'children': ['22', '23', '24']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"pale.flask_adapter.bind_blueprint expected the "'}; {'id': '23', 'type': 'string', 'children': [], 'value': '"passed in flask_blueprint to be an instance of "'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"Blueprint, but it was an instance of %s instead."'}; {'id': '25', 'type': 'tuple', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'flask_blueprint'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '38']}; {'id': '31', 'type': 'not_operator', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'pale'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'is_pale_module'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'pale_api_module'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'raise_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '51'], 'value': '%'}; {'id': '44', 'type': '()', 'children': ['45']}; {'id': '45', 'type': 'concatenated_string', 'children': ['46', '47', '48', '49', '50']}; {'id': '46', 'type': 'string', 'children': [], 'value': '"pale.flask_adapter.bind_blueprint expected the "'}; {'id': '47', 'type': 'string', 'children': [], 'value': '"passed in pale_api_module to be a module, and to "'}; {'id': '48', 'type': 'string', 'children': [], 'value': '"have a _module_type defined to equal "'}; {'id': '49', 'type': 'string', 'children': [], 'value': '"pale.ImplementationModule, but it was an instance of "'}; {'id': '50', 'type': 'string', 'children': [], 'value': '"%s instead."'}; {'id': '51', 'type': 'tuple', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'pale_api_module'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'endpoints'}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'pale'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'extract_endpoints'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'pale_api_module'}; {'id': '65', 'type': 'for_statement', 'children': ['66', '67', '68']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'endpoint'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'endpoints'}; {'id': '68', 'type': 'block', 'children': ['69', '76', '83', '89', '95']}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'endpoint'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': '_set_response_class'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'RESPONSE_CLASS'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '79', 'type': 'list', 'children': ['80'], 'value': '[endpoint._http_method]'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'endpoint'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': '_http_method'}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'endpoint'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': '_route_name'}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'endpoint'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': '_execute'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'flask_blueprint'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'add_url_rule'}; {'id': '100', 'type': 'argument_list', 'children': ['101', '104', '105', '111']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'endpoint'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': '_uri'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '105', 'type': 'keyword_argument', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'view_func'}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'ContextualizedHandler'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '111', 'type': 'keyword_argument', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'methods'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'method'}
Binds an implemented pale API module to a Flask Blueprint.
def command_line_runner(): filename = sys.argv[-1] if not filename.endswith(".rst"): print("ERROR! Please enter a ReStructuredText filename!") sys.exit() print(rst_to_json(file_opener(filename)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'command_line_runner'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '14', '34']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '8', 'type': 'subscript', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '12', 'type': 'unary_operator', 'children': ['13'], 'value': '-'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '14', 'type': 'if_statement', 'children': ['15', '22']}; {'id': '15', 'type': 'not_operator', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'string', 'children': [], 'value': '".rst"'}; {'id': '22', 'type': 'block', 'children': ['23', '28']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"ERROR! Please enter a ReStructuredText filename!"'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'rst_to_json'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'file_opener'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'filename'}
I run functions from the command-line!
def _read_indexlist(self, name): setattr(self, '_' + name, [self._timeline[int(i)] for i in self.db.lrange('site:{0}'.format(name), 0, -1)])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_read_indexlist'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12', '15']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '14'], 'value': '+'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'_'"}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '15', 'type': 'list_comprehension', 'children': ['16', '24']}; {'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': '_timeline'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '24', 'type': 'for_in_clause', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '26', 'type': 'call', 'children': ['27', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'lrange'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '39', '40']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'site:{0}'"}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '40', 'type': 'unary_operator', 'children': ['41'], 'value': '-'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '1'}
Read a list of indexes.
def get(self, x, y): for piece in self.pieces: if (piece.x, piece.y) == (x, y): return piece
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'for_statement', 'children': ['9', '10', '13']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'piece'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'pieces'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '26']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '23'], 'value': '=='}; {'id': '16', 'type': 'tuple', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'piece'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'piece'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '23', 'type': 'tuple', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'piece'}
Return piece placed at the provided coordinates.
def web_hook_receiver(sender, **kwargs): deployment = Deployment.objects.get(pk=kwargs.get('deployment_id')) hooks = deployment.web_hooks if not hooks: return for hook in hooks: data = payload_generator(deployment) deliver_hook(deployment, hook.url, data)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'web_hook_receiver'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sender'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '26', '32', '37']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'deployment'}; {'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': 'Deployment'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'deployment_id'"}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'hooks'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'deployment'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'web_hooks'}; {'id': '32', 'type': 'if_statement', 'children': ['33', '35']}; {'id': '33', 'type': 'not_operator', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'hooks'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'return_statement', 'children': []}; {'id': '37', 'type': 'for_statement', 'children': ['38', '39', '40']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'hook'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'hooks'}; {'id': '40', 'type': 'block', 'children': ['41', '48']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'payload_generator'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'deployment'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'deliver_hook'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53', '56']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'deployment'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'hook'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'data'}
Generic receiver for the web hook firing piece.
def _erase_in_line(self, type_of=0): row = self.display[self.y] attrs = self.attributes[self.y] if type_of == 0: row = row[:self.x] + u" " * (self.size[1] - self.x) attrs = attrs[:self.x] + [self.default_attributes] * (self.size[1] - self.x) elif type_of == 1: row = u" " * (self.x+1) + row[self.x+1:] attrs = [self.default_attributes] * (self.x+1) + attrs[self.x+1:] elif type_of == 2: row = u" " * self.size[1] attrs = [self.default_attributes] * self.size[1] self.display[self.y] = row self.attributes[self.y] = attrs
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_erase_in_line'}; {'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': 'type_of'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '8', 'type': 'block', 'children': ['9', '19', '29', '161', '171']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '12', 'type': 'subscript', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'display'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '22', 'type': 'subscript', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '29', 'type': 'if_statement', 'children': ['30', '33', '83', '133']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': '=='}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'type_of'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '33', 'type': 'block', 'children': ['34', '57']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '45'], 'value': '+'}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '40', 'type': 'slice', 'children': ['41', '42']}; {'id': '41', 'type': 'colon', 'children': []}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '47'], 'value': '*'}; {'id': '46', 'type': 'string', 'children': [], 'value': 'u" "'}; {'id': '47', 'type': '()', 'children': ['48']}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '54'], 'value': '-'}; {'id': '49', 'type': 'subscript', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '68'], 'value': '+'}; {'id': '61', 'type': 'subscript', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '63', 'type': 'slice', 'children': ['64', '65']}; {'id': '64', 'type': 'colon', 'children': []}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '68', 'type': 'binary_operator', 'children': ['69', '73'], 'value': '*'}; {'id': '69', 'type': 'list', 'children': ['70'], 'value': '[self.default_attributes]'}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'default_attributes'}; {'id': '73', 'type': '()', 'children': ['74']}; {'id': '74', 'type': 'binary_operator', 'children': ['75', '80'], 'value': '-'}; {'id': '75', 'type': 'subscript', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '79', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '83', 'type': 'elif_clause', 'children': ['84', '87']}; {'id': '84', 'type': 'comparison_operator', 'children': ['85', '86'], 'value': '=='}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'type_of'}; {'id': '86', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '87', 'type': 'block', 'children': ['88', '109']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '91', 'type': 'binary_operator', 'children': ['92', '100'], 'value': '+'}; {'id': '92', 'type': 'binary_operator', 'children': ['93', '94'], 'value': '*'}; {'id': '93', 'type': 'string', 'children': [], 'value': 'u" "'}; {'id': '94', 'type': '()', 'children': ['95']}; {'id': '95', 'type': 'binary_operator', 'children': ['96', '99'], 'value': '+'}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '99', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '100', 'type': 'subscript', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '102', 'type': 'slice', 'children': ['103', '108']}; {'id': '103', 'type': 'binary_operator', 'children': ['104', '107'], 'value': '+'}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '107', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '108', 'type': 'colon', 'children': []}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '112', 'type': 'binary_operator', 'children': ['113', '124'], 'value': '+'}; {'id': '113', 'type': 'binary_operator', 'children': ['114', '118'], 'value': '*'}; {'id': '114', 'type': 'list', 'children': ['115'], 'value': '[self.default_attributes]'}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'default_attributes'}; {'id': '118', 'type': '()', 'children': ['119']}; {'id': '119', 'type': 'binary_operator', 'children': ['120', '123'], 'value': '+'}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '123', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '124', 'type': 'subscript', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '126', 'type': 'slice', 'children': ['127', '132']}; {'id': '127', 'type': 'binary_operator', 'children': ['128', '131'], 'value': '+'}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '131', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '132', 'type': 'colon', 'children': []}; {'id': '133', 'type': 'elif_clause', 'children': ['134', '137']}; {'id': '134', 'type': 'comparison_operator', 'children': ['135', '136'], 'value': '=='}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'type_of'}; {'id': '136', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '137', 'type': 'block', 'children': ['138', '148']}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}; {'id': '139', 'type': 'assignment', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '141', 'type': 'binary_operator', 'children': ['142', '143'], 'value': '*'}; {'id': '142', 'type': 'string', 'children': [], 'value': 'u" "'}; {'id': '143', 'type': 'subscript', 'children': ['144', '147']}; {'id': '144', 'type': 'attribute', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '147', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '148', 'type': 'expression_statement', 'children': ['149']}; {'id': '149', 'type': 'assignment', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '151', 'type': 'binary_operator', 'children': ['152', '156'], 'value': '*'}; {'id': '152', 'type': 'list', 'children': ['153'], 'value': '[self.default_attributes]'}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'default_attributes'}; {'id': '156', 'type': 'subscript', 'children': ['157', '160']}; {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '160', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '161', 'type': 'expression_statement', 'children': ['162']}; {'id': '162', 'type': 'assignment', 'children': ['163', '170']}; {'id': '163', 'type': 'subscript', 'children': ['164', '167']}; {'id': '164', 'type': 'attribute', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'display'}; {'id': '167', 'type': 'attribute', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '171', 'type': 'expression_statement', 'children': ['172']}; {'id': '172', 'type': 'assignment', 'children': ['173', '180']}; {'id': '173', 'type': 'subscript', 'children': ['174', '177']}; {'id': '174', 'type': 'attribute', 'children': ['175', '176']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '177', 'type': 'attribute', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'attrs'}
Erases the row in a specific way, depending on the type_of.
def inject_experiment(): exp = Experiment(session) return dict(experiment=exp, env=os.environ)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'inject_experiment'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '12']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'exp'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'Experiment'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '19']}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'experiment'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'exp'}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'environ'}
Inject experiment and enviroment variables into the template context.
def locate_run(output, target, no_newline): from .config import ConfigStore cfstore = ConfigStore() path = getattr(cfstore, "{0}_path".format(target)) output.write(path) if not no_newline: output.write("\n")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'locate_run'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'no_newline'}; {'id': '7', 'type': 'block', 'children': ['8', '15', '21', '34', '41']}; {'id': '8', 'type': 'import_from_statement', 'children': ['9', '13']}; {'id': '9', 'type': 'relative_import', 'children': ['10', '11']}; {'id': '10', 'type': 'import_prefix', 'children': []}; {'id': '11', 'type': 'dotted_name', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '13', 'type': 'dotted_name', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ConfigStore'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'cfstore'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ConfigStore'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'cfstore'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"{0}_path"'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '41', 'type': 'if_statement', 'children': ['42', '44']}; {'id': '42', 'type': 'not_operator', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'no_newline'}; {'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': 'output'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'string', 'children': [], 'value': '"\\n"'}
Print location of RASH related file.
def DocbookSlidesPdf(env, target, source=None, *args, **kw): target, source = __extend_targets_sources(target, source) __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_SLIDESPDF', ['slides','fo','plain.xsl']) __builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder) result = [] for t,s in zip(target,source): t, stem = __ensure_suffix_stem(t, '.pdf') xsl = __builder.__call__(env, stem+'.fo', s, **kw) env.Depends(xsl, kw['DOCBOOK_XSL']) result.extend(xsl) result.extend(__fop_builder.__call__(env, t, xsl, **kw)) return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'DocbookSlidesPdf'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'list_splat_pattern', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '11', 'type': 'dictionary_splat_pattern', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '13', 'type': 'block', 'children': ['14', '24', '35', '44', '48', '116']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '19']}; {'id': '16', 'type': 'pattern_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '__extend_targets_sources'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '__init_xsl_stylesheet'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29', '30', '31']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'$DOCBOOK_DEFAULT_XSL_SLIDESPDF'"}; {'id': '31', 'type': 'list', 'children': ['32', '33', '34'], 'value': "['slides','fo','plain.xsl']"}; {'id': '32', 'type': 'string', 'children': [], 'value': "'slides'"}; {'id': '33', 'type': 'string', 'children': [], 'value': "'fo'"}; {'id': '34', 'type': 'string', 'children': [], 'value': "'plain.xsl'"}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '__builder'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '__select_builder'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42', '43']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '__lxml_builder'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '__libxml2_builder'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '__xsltproc_builder'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '47', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '48', 'type': 'for_statement', 'children': ['49', '52', '57']}; {'id': '49', 'type': 'pattern_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '57', 'type': 'block', 'children': ['58', '68', '83', '93', '100']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '63']}; {'id': '60', 'type': 'pattern_list', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'stem'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '__ensure_suffix_stem'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'.pdf'"}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'xsl'}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': '__builder'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': '__call__'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '77', '80', '81']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '77', 'type': 'binary_operator', 'children': ['78', '79'], 'value': '+'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'stem'}; {'id': '79', 'type': 'string', 'children': [], 'value': "'.fo'"}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '81', 'type': 'dictionary_splat', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'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': 'env'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'Depends'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'xsl'}; {'id': '90', 'type': 'subscript', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '92', 'type': 'string', 'children': [], 'value': "'DOCBOOK_XSL'"}; {'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': 'result'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'xsl'}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'call', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': '__fop_builder'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': '__call__'}; {'id': '110', 'type': 'argument_list', 'children': ['111', '112', '113', '114']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'xsl'}; {'id': '114', 'type': 'dictionary_splat', 'children': ['115']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '116', 'type': 'return_statement', 'children': ['117']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'result'}
A pseudo-Builder, providing a Docbook toolchain for PDF slides output.
def pretty_print_table(headers, rows): table = make_table(headers=headers, rows=rows) pretty_print_table_instance(table)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pretty_print_table'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '6', 'type': 'block', 'children': ['7', '19']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'make_table'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '16']}; {'id': '13', 'type': 'keyword_argument', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'pretty_print_table_instance'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'table'}
Pretty print a table from headers and rows.
def bounds_window(bounds, affine): w, s, e, n = bounds row_start, col_start = rowcol(w, n, affine) row_stop, col_stop = rowcol(e, s, affine, op=math.ceil) return (row_start, row_stop), (col_start, col_stop)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bounds_window'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'affine'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '26', '42']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '14']}; {'id': '9', 'type': 'pattern_list', 'children': ['10', '11', '12', '13']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'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': 'row_start'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'col_start'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'rowcol'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'affine'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '31']}; {'id': '28', 'type': 'pattern_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'row_stop'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'col_stop'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'rowcol'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35', '36', '37']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'affine'}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'ceil'}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'expression_list', 'children': ['44', '47']}; {'id': '44', 'type': 'tuple', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'row_start'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'row_stop'}; {'id': '47', 'type': 'tuple', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'col_start'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'col_stop'}
Create a full cover rasterio-style window
def from_dir(cwd): "Context manager to ensure in the cwd directory." import os curdir = os.getcwd() try: os.chdir(cwd) yield finally: os.chdir(curdir)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_dir'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cwd'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '11', '19']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': '"Context manager to ensure in the cwd directory."'}; {'id': '8', 'type': 'import_statement', 'children': ['9']}; {'id': '9', 'type': 'dotted_name', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'curdir'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'getcwd'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'try_statement', 'children': ['20', '30']}; {'id': '20', 'type': 'block', 'children': ['21', '28']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'chdir'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'cwd'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'yield', 'children': []}; {'id': '30', 'type': 'finally_clause', 'children': ['31']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'chdir'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'curdir'}
Context manager to ensure in the cwd directory.
def entries_in_tree_oid(self, prefix, tree_oid): try: tree = self.git.get_object(tree_oid) except KeyError: log.warning("Couldn't find object {0}".format(tree_oid)) return empty else: return frozenset(self.entries_in_tree(prefix, tree))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'entries_in_tree_oid'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'tree_oid'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'try_statement', 'children': ['9', '21', '38']}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'git'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get_object'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'tree_oid'}; {'id': '21', 'type': 'except_clause', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '23', 'type': 'block', 'children': ['24', '36']}; {'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': 'log'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': '"Couldn\'t find object {0}"'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'tree_oid'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'empty'}; {'id': '38', 'type': 'else_clause', 'children': ['39']}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'frozenset'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'entries_in_tree'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'tree'}
Find the tree at this oid and return entries prefixed with ``prefix``
def upload(ctx): settings.add_cli_options(ctx.cli_options, settings.TransferAction.Upload) ctx.initialize(settings.TransferAction.Upload) specs = settings.create_upload_specifications( ctx.cli_options, ctx.config) del ctx.cli_options for spec in specs: blobxfer.api.Uploader( ctx.general_options, ctx.credentials, spec ).start()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'upload'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '31', '45', '49']}; {'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': 'settings'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'add_cli_options'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'cli_options'}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'TransferAction'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'Upload'}; {'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': 'ctx'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'initialize'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'TransferAction'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'Upload'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'specs'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'create_upload_specifications'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'cli_options'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '45', 'type': 'delete_statement', 'children': ['46']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'cli_options'}; {'id': '49', 'type': 'for_statement', 'children': ['50', '51', '52']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'specs'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '71']}; {'id': '55', 'type': 'attribute', 'children': ['56', '70']}; {'id': '56', 'type': 'call', 'children': ['57', '62']}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'blobxfer'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'Uploader'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '66', '69']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'general_options'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '71', 'type': 'argument_list', 'children': []}
Upload files to Azure Storage
def next_weekday(weekday): ix = WEEKDAYS.index(weekday) if ix == len(WEEKDAYS)-1: return WEEKDAYS[0] return WEEKDAYS[ix+1]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'next_weekday'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'weekday'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '29']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ix'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'WEEKDAYS'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'weekday'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '24']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': '=='}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ix'}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '23'], 'value': '-'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'WEEKDAYS'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'WEEKDAYS'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'WEEKDAYS'}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '34'], 'value': '+'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ix'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '1'}
Returns the name of the weekday after the given weekday name.
def delete(self): response = self.hv.delete_request('people/' + str(self.id)) return response
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '24']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'hv'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'delete_request'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '18'], 'value': '+'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'people/'"}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'response'}
Deletes the person immediately.
def convert_svg(svgstr, size, filepath, target): "convert to PDF or PNG" if target == "PDF": img = cairo.PDFSurface(filepath, size, size) elif target == "PNG": img = cairo.ImageSurface(cairo.FORMAT_ARGB32, size, size) else: system.exit("unknown file type conversion") ctx = cairo.Context(img) handler= rsvg.Handle(None, svgstr) iw,ih, fw,fh = handler.get_dimension_data() ctx.translate(0,0) ctx.scale(size/fw, size/fh) handler.render_cairo(ctx) if target == "PNG": img.write_to_png(filepath)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_svg'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'svgstr'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '8', 'type': 'block', 'children': ['9', '11', '54', '63', '73', '85', '93', '105', '112']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'string', 'children': [], 'value': '"convert to PDF or PNG"'}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15', '27', '45']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': '=='}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '14', 'type': 'string', 'children': [], 'value': '"PDF"'}; {'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': 'img'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cairo'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'PDFSurface'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25', '26']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '27', 'type': 'elif_clause', 'children': ['28', '31']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '30'], 'value': '=='}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"PNG"'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'img'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'cairo'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'ImageSurface'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '43', '44']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'cairo'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'FORMAT_ARGB32'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '45', 'type': 'else_clause', 'children': ['46']}; {'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': 'system'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'string', 'children': [], 'value': '"unknown file type conversion"'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'cairo'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'Context'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'img'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'rsvg'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'Handle'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72']}; {'id': '71', 'type': 'None', 'children': []}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'svgstr'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '80']}; {'id': '75', 'type': 'pattern_list', 'children': ['76', '77', '78', '79']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'iw'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'ih'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'fw'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'get_dimension_data'}; {'id': '84', 'type': 'argument_list', 'children': []}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'translate'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92']}; {'id': '91', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '92', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'scale'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '102']}; {'id': '99', 'type': 'binary_operator', 'children': ['100', '101'], 'value': '/'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'fw'}; {'id': '102', 'type': 'binary_operator', 'children': ['103', '104'], 'value': '/'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'call', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'render_cairo'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '112', 'type': 'if_statement', 'children': ['113', '116']}; {'id': '113', 'type': 'comparison_operator', 'children': ['114', '115'], 'value': '=='}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '115', 'type': 'string', 'children': [], 'value': '"PNG"'}; {'id': '116', 'type': 'block', 'children': ['117']}; {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'call', 'children': ['119', '122']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'img'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'write_to_png'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'filepath'}
convert to PDF or PNG
def prt_line_detail(self, prt, line): values = line.split('\t') self._prt_line_detail(prt, values)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prt_line_detail'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'prt'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '7', 'type': 'block', 'children': ['8', '17']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'\\t'"}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_prt_line_detail'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'prt'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'values'}
Print line header and values in a readable format.
def getBinding(self): wsdl = self.getService().getWSDL() return wsdl.bindings[self.binding]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getBinding'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '18']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'wsdl'}; {'id': '9', 'type': 'call', 'children': ['10', '17']}; {'id': '10', 'type': 'attribute', 'children': ['11', '16']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'getService'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'getWSDL'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'subscript', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'wsdl'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'bindings'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'binding'}
Return the Binding object that is referenced by this port.
def construct_wishart(self,v,X): self.adjust_prior(list(range(int((len(self.latent_variables.z_list)-self.ylen-(self.ylen**2-self.ylen)/2)), int(len(self.latent_variables.z_list)))), fam.InverseWishart(v,X))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'construct_wishart'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'adjust_prior'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '60']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '49']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': '()', 'children': ['24']}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '37'], 'value': '-'}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '34'], 'value': '-'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'latent_variables'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'z_list'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'ylen'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '48'], 'value': '/'}; {'id': '38', 'type': '()', 'children': ['39']}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '45'], 'value': '-'}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '44'], 'value': '**'}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'ylen'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'ylen'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'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', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'latent_variables'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'z_list'}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'fam'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'InverseWishart'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'X'}
Constructs a Wishart prior for the covariance matrix
def countNeighbours(self, cell): count = 0 y, x = cell y = y % self.y_grid x = x % self.x_grid y1 = (y - 1) % self.y_grid y2 = (y + 1) % self.y_grid x1 = (x - 1) % self.x_grid x2 = (x + 1) % self.x_grid cell = y, x for neighbour in product([y1, y, y2], [x1, x, x2]): if neighbour != cell and self.grid.get(neighbour): count += 1 return count
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'countNeighbours'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '17', '25', '33', '44', '55', '66', '77', '83', '115']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '16']}; {'id': '13', 'type': 'pattern_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '22'], 'value': '%'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'y_grid'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '30'], 'value': '%'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'x_grid'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'y1'}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '41'], 'value': '%'}; {'id': '37', 'type': '()', 'children': ['38']}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '40'], 'value': '-'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'y_grid'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'y2'}; {'id': '47', 'type': 'binary_operator', 'children': ['48', '52'], 'value': '%'}; {'id': '48', 'type': '()', 'children': ['49']}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '51'], 'value': '+'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'y_grid'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'x1'}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '63'], 'value': '%'}; {'id': '59', 'type': '()', 'children': ['60']}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '62'], 'value': '-'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '62', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'x_grid'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'x2'}; {'id': '69', 'type': 'binary_operator', 'children': ['70', '74'], 'value': '%'}; {'id': '70', 'type': '()', 'children': ['71']}; {'id': '71', 'type': 'binary_operator', 'children': ['72', '73'], 'value': '+'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '73', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'x_grid'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '80', 'type': 'expression_list', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '83', 'type': 'for_statement', 'children': ['84', '85', '96']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'neighbour'}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'product'}; {'id': '87', 'type': 'argument_list', 'children': ['88', '92']}; {'id': '88', 'type': 'list', 'children': ['89', '90', '91'], 'value': '[y1, y, y2]'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'y1'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'y2'}; {'id': '92', 'type': 'list', 'children': ['93', '94', '95'], 'value': '[x1, x, x2]'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'x1'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'x2'}; {'id': '96', 'type': 'block', 'children': ['97']}; {'id': '97', 'type': 'if_statement', 'children': ['98', '110']}; {'id': '98', 'type': 'boolean_operator', 'children': ['99', '102'], 'value': 'and'}; {'id': '99', 'type': 'comparison_operator', 'children': ['100', '101'], 'value': '!='}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'neighbour'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '102', 'type': 'call', 'children': ['103', '108']}; {'id': '103', 'type': 'attribute', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'grid'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'neighbour'}; {'id': '110', 'type': 'block', 'children': ['111']}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'augmented_assignment', 'children': ['113', '114'], 'value': '+='}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '114', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '115', 'type': 'return_statement', 'children': ['116']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'count'}
Return the number active neighbours within one positions away from cell
def cublasDtrmv(handle, uplo, trans, diag, n, A, lda, x, inx): status = _libcublas.cublasDtrmv_v2(handle, _CUBLAS_FILL_MODE[uplo], _CUBLAS_OP[trans], _CUBLAS_DIAG[diag], n, int(A), lda, int(x), inx) cublasCheckStatus(status)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cublasDtrmv'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'uplo'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'trans'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'diag'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'A'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'lda'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'inx'}; {'id': '13', 'type': 'block', 'children': ['14', '43']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_libcublas'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'cublasDtrmv_v2'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23', '26', '29', '32', '33', '37', '38', '42']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_CUBLAS_FILL_MODE'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'uplo'}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_CUBLAS_OP'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'trans'}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_CUBLAS_DIAG'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'diag'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'A'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'lda'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'inx'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'cublasCheckStatus'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'status'}
Matrix-vector product for real triangular matrix.
def encode(obj): if hasattr(obj, '__id__'): return msgpack.ExtType(ExtType.REF, msgpack.packb(obj.__id__)) return obj
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encode'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '5', 'type': 'block', 'children': ['6', '30']}; {'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': 'obj'}; {'id': '11', 'type': 'string', 'children': [], 'value': "'__id__'"}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'msgpack'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ExtType'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ExtType'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'REF'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'msgpack'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'packb'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '__id__'}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'obj'}
Encode an object for proper decoding by Java or ObjC
def check(projects): log = logging.getLogger('ciu') log.info('{0} top-level projects to check'.format(len(projects))) print('Finding and checking dependencies ...') blockers = dependencies.blockers(projects) print('') for line in message(blockers): print(line) print('') for line in pprint_blockers(blockers): print(' ', line) return len(blockers) == 0
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'projects'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '30', '35', '44', '49', '61', '66', '79']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'getLogger'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'ciu'"}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'{0} top-level projects to check'"}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'projects'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'Finding and checking dependencies ...'"}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'blockers'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'dependencies'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'blockers'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'projects'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'string', 'children': [], 'value': "''"}; {'id': '49', 'type': 'for_statement', 'children': ['50', '51', '55']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'blockers'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'string', 'children': [], 'value': "''"}; {'id': '66', 'type': 'for_statement', 'children': ['67', '68', '72']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'pprint_blockers'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'blockers'}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '76', 'type': 'argument_list', 'children': ['77', '78']}; {'id': '77', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '79', 'type': 'return_statement', 'children': ['80']}; {'id': '80', 'type': 'comparison_operator', 'children': ['81', '85'], 'value': '=='}; {'id': '81', 'type': 'call', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'blockers'}; {'id': '85', 'type': 'integer', 'children': [], 'value': '0'}
Check the specified projects for Python 3 compatibility.
def __insert_wrapper(func): def check_func(self, key, new_item, instance=0): if key not in self.keys(): raise KeyError("%s not a key in label" % (key)) if not isinstance(new_item, (list, OrderedMultiDict)): raise TypeError("The new item must be a list or PVLModule") if isinstance(new_item, OrderedMultiDict): new_item = list(new_item) return func(self, key, new_item, instance) return check_func
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__insert_wrapper'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '5', 'type': 'block', 'children': ['6', '70']}; {'id': '6', 'type': 'function_definition', 'children': ['7', '8', '15']}; {'id': '7', 'type': 'function_name', 'children': [], 'value': 'check_func'}; {'id': '8', 'type': 'parameters', 'children': ['9', '10', '11', '12']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'new_item'}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '14', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '15', 'type': 'block', 'children': ['16', '33', '48', '62']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '24']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': 'not in'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'key'}; {'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': 'keys'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'raise_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '31'], 'value': '%'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"%s not a key in label"'}; {'id': '31', 'type': '()', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '42']}; {'id': '34', 'type': 'not_operator', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'new_item'}; {'id': '39', 'type': 'tuple', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'OrderedMultiDict'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'raise_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'string', 'children': [], 'value': '"The new item must be a list or PVLModule"'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '54']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'new_item'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'OrderedMultiDict'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'new_item'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'new_item'}; {'id': '62', 'type': 'return_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67', '68', '69']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'new_item'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '70', 'type': 'return_statement', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'check_func'}
Make sure the arguments given to the insert methods are correct
def weed(self): _ext = [k for k in self._dict.keys() if k not in self.c_param] for k in _ext: del self._dict[k]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'weed'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '26']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': '_ext'}; {'id': '9', 'type': 'list_comprehension', 'children': ['10', '11', '20']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '11', 'type': 'for_in_clause', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'if_clause', 'children': ['21']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '23'], 'value': 'not in'}; {'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': 'c_param'}; {'id': '26', 'type': 'for_statement', 'children': ['27', '28', '29']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_ext'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'delete_statement', 'children': ['31']}; {'id': '31', 'type': 'subscript', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'k'}
Get rid of key value pairs that are not standard
def read_data(fo, writer_schema, reader_schema=None): record_type = extract_record_type(writer_schema) logical_type = extract_logical_type(writer_schema) if reader_schema and record_type in AVRO_TYPES: if writer_schema == reader_schema: reader_schema = None else: match_schemas(writer_schema, reader_schema) reader_fn = READERS.get(record_type) if reader_fn: try: data = reader_fn(fo, writer_schema, reader_schema) except StructError: raise EOFError('cannot read %s from %s' % (record_type, fo)) if 'logicalType' in writer_schema: fn = LOGICAL_READERS.get(logical_type) if fn: return fn(data, writer_schema, reader_schema) if reader_schema is not None: return maybe_promote( data, record_type, extract_record_type(reader_schema) ) else: return data else: return read_data( fo, SCHEMA_DEFS[record_type], SCHEMA_DEFS.get(reader_schema) )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fo'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'writer_schema'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'reader_schema'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '17', '24', '48', '57']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'record_type'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'extract_record_type'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'writer_schema'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'logical_type'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'extract_logical_type'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'writer_schema'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '30']}; {'id': '25', 'type': 'boolean_operator', 'children': ['26', '27'], 'value': 'and'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'reader_schema'}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'in'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'record_type'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'AVRO_TYPES'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'if_statement', 'children': ['32', '35', '40']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '34'], 'value': '=='}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'writer_schema'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'reader_schema'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'reader_schema'}; {'id': '39', 'type': 'None', 'children': []}; {'id': '40', 'type': 'else_clause', 'children': ['41']}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'match_schemas'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'writer_schema'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'reader_schema'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'reader_fn'}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'READERS'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'record_type'}; {'id': '57', 'type': 'if_statement', 'children': ['58', '59', '126']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'reader_fn'}; {'id': '59', 'type': 'block', 'children': ['60', '83', '107']}; {'id': '60', 'type': 'try_statement', 'children': ['61', '71']}; {'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': 'data'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'reader_fn'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69', '70']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'fo'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'writer_schema'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'reader_schema'}; {'id': '71', 'type': 'except_clause', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'StructError'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'raise_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'EOFError'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'binary_operator', 'children': ['79', '80'], 'value': '%'}; {'id': '79', 'type': 'string', 'children': [], 'value': "'cannot read %s from %s'"}; {'id': '80', 'type': 'tuple', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'record_type'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'fo'}; {'id': '83', 'type': 'if_statement', 'children': ['84', '87']}; {'id': '84', 'type': 'comparison_operator', 'children': ['85', '86'], 'value': 'in'}; {'id': '85', 'type': 'string', 'children': [], 'value': "'logicalType'"}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'writer_schema'}; {'id': '87', 'type': 'block', 'children': ['88', '97']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '91', 'type': 'call', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'LOGICAL_READERS'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'logical_type'}; {'id': '97', 'type': 'if_statement', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'return_statement', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '103', 'type': 'argument_list', 'children': ['104', '105', '106']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'writer_schema'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'reader_schema'}; {'id': '107', 'type': 'if_statement', 'children': ['108', '111', '122']}; {'id': '108', 'type': 'comparison_operator', 'children': ['109', '110'], 'value': 'is not'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'reader_schema'}; {'id': '110', 'type': 'None', 'children': []}; {'id': '111', 'type': 'block', 'children': ['112']}; {'id': '112', 'type': 'return_statement', 'children': ['113']}; {'id': '113', 'type': 'call', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'maybe_promote'}; {'id': '115', 'type': 'argument_list', 'children': ['116', '117', '118']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'record_type'}; {'id': '118', 'type': 'call', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'extract_record_type'}; {'id': '120', 'type': 'argument_list', 'children': ['121']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'reader_schema'}; {'id': '122', 'type': 'else_clause', 'children': ['123']}; {'id': '123', 'type': 'block', 'children': ['124']}; {'id': '124', 'type': 'return_statement', 'children': ['125']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '126', 'type': 'else_clause', 'children': ['127']}; {'id': '127', 'type': 'block', 'children': ['128']}; {'id': '128', 'type': 'return_statement', 'children': ['129']}; {'id': '129', 'type': 'call', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'read_data'}; {'id': '131', 'type': 'argument_list', 'children': ['132', '133', '136']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'fo'}; {'id': '133', 'type': 'subscript', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'SCHEMA_DEFS'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'record_type'}; {'id': '136', 'type': 'call', 'children': ['137', '140']}; {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'SCHEMA_DEFS'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'reader_schema'}
Read data from file object according to schema.
def run_script(self, requires, script_name): ns = sys._getframe(1).f_globals name = ns['__name__'] ns.clear() ns['__name__'] = name self.require(requires)[0].run_script(script_name, ns)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_script'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'requires'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'script_name'}; {'id': '7', 'type': 'block', 'children': ['8', '19', '25', '31', '37']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '11', 'type': 'attribute', 'children': ['12', '18']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_getframe'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'f_globals'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'__name__'"}; {'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': 'ns'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'clear'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'__name__'"}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '49']}; {'id': '39', 'type': 'attribute', 'children': ['40', '48']}; {'id': '40', 'type': 'subscript', 'children': ['41', '47']}; {'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': 'require'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'requires'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'run_script'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'script_name'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'ns'}
Locate distribution for `requires` and run `script_name` script
def class_name_str(obj, skip_parent=False): rt = str(type(obj)).split(" ")[1][1:-2] if skip_parent: rt = rt.split(".")[-1] return rt
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'class_name_str'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'skip_parent'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '32', '47']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'rt'}; {'id': '12', 'type': 'subscript', 'children': ['13', '27']}; {'id': '13', 'type': 'subscript', 'children': ['14', '26']}; {'id': '14', 'type': 'call', 'children': ['15', '24']}; {'id': '15', 'type': 'attribute', 'children': ['16', '23']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': '" "'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '27', 'type': 'slice', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '29', 'type': 'colon', 'children': []}; {'id': '30', 'type': 'unary_operator', 'children': ['31'], 'value': '-'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '32', 'type': 'if_statement', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'skip_parent'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'rt'}; {'id': '38', 'type': 'subscript', 'children': ['39', '45']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'rt'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'string', 'children': [], 'value': '"."'}; {'id': '45', 'type': 'unary_operator', 'children': ['46'], 'value': '-'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'rt'}
return's object's class name as string
def reject(self, func): return self._wrap(list(filter(lambda val: not func(val), self.obj)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reject'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_wrap'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '27']}; {'id': '19', 'type': 'lambda', 'children': ['20', '22']}; {'id': '20', 'type': 'lambda_parameters', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'obj'}
Return all the elements for which a truth test fails.
def handle_simple_sequencing(func): from .assessment import assessment_utilities def wrapper(*args, **kwargs): if 'create_assessment_part' in func.__name__: result = func(*args, **kwargs) assessment_utilities.update_parent_sequence_map(result) elif func.__name__ == 'delete_assessment_part': assessment_utilities.remove_from_parent_sequence_map(*args) result = func(*args, **kwargs) else: result = func(*args, **kwargs) return result return wrapper
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_simple_sequencing'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '84']}; {'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': 'assessment'}; {'id': '11', 'type': 'dotted_name', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'assessment_utilities'}; {'id': '13', 'type': 'function_definition', 'children': ['14', '15', '20']}; {'id': '14', 'type': 'function_name', 'children': [], 'value': 'wrapper'}; {'id': '15', 'type': 'parameters', 'children': ['16', '18']}; {'id': '16', 'type': 'list_splat_pattern', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '18', 'type': 'dictionary_splat_pattern', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '20', 'type': 'block', 'children': ['21', '82']}; {'id': '21', 'type': 'if_statement', 'children': ['22', '27', '45', '70']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '24'], 'value': 'in'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'create_assessment_part'"}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '27', 'type': 'block', 'children': ['28', '38']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '36']}; {'id': '34', 'type': 'list_splat', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '36', 'type': 'dictionary_splat', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'assessment_utilities'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'update_parent_sequence_map'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '45', 'type': 'elif_clause', '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': 'func'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '50', 'type': 'string', 'children': [], 'value': "'delete_assessment_part'"}; {'id': '51', 'type': 'block', 'children': ['52', '60']}; {'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': 'assessment_utilities'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'remove_from_parent_sequence_map'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'list_splat', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '68']}; {'id': '66', 'type': 'list_splat', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '68', 'type': 'dictionary_splat', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '70', 'type': 'else_clause', 'children': ['71']}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '80']}; {'id': '78', 'type': 'list_splat', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '80', 'type': 'dictionary_splat', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '82', 'type': 'return_statement', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '84', 'type': 'return_statement', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'wrapper'}
decorator, deal with simple sequencing cases
def dump(self, directory): payload = '{}:{}'.format(self.fingerprint, self.serialized_bytes_length) safe_file_dump(self._path(directory), payload=payload)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dump'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '6', 'type': 'block', 'children': ['7', '21']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'string', 'children': [], 'value': "'{}:{}'"}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'fingerprint'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'serialized_bytes_length'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'safe_file_dump'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '31']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_path'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'payload'}
Dump this Digest object adjacent to the given directory.
def follow_logs(instance_log_id, sleep_duration=1): cur_idx = 0 job_terminated = False while not job_terminated: log_file_contents = ResourceClient().get_content(instance_log_id) print_output = log_file_contents[cur_idx:] job_terminated = any(terminal_output in print_output for terminal_output in TERMINATION_OUTPUT_LIST) cur_idx += len(print_output) sys.stdout.write(print_output) sleep(sleep_duration)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'follow_logs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'instance_log_id'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'sleep_duration'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '8', 'type': 'block', 'children': ['9', '13', '17']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'cur_idx'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'job_terminated'}; {'id': '16', 'type': 'False', 'children': []}; {'id': '17', 'type': 'while_statement', 'children': ['18', '20']}; {'id': '18', 'type': 'not_operator', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'job_terminated'}; {'id': '20', 'type': 'block', 'children': ['21', '32', '40', '52', '59', '68']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'log_file_contents'}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ResourceClient'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'get_content'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'instance_log_id'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'print_output'}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'log_file_contents'}; {'id': '37', 'type': 'slice', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'cur_idx'}; {'id': '39', 'type': 'colon', 'children': []}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'job_terminated'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '45', 'type': 'generator_expression', 'children': ['46', '49']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': 'in'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'terminal_output'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'print_output'}; {'id': '49', 'type': 'for_in_clause', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'terminal_output'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'TERMINATION_OUTPUT_LIST'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'augmented_assignment', 'children': ['54', '55'], 'value': '+='}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'cur_idx'}; {'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': 'print_output'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '66']}; {'id': '61', 'type': 'attribute', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'print_output'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'sleep_duration'}
Follow the logs until Job termination.
def _encode_query(query): if query == '': return query query_args = [] for query_kv in query.split('&'): k, v = query_kv.split('=') query_args.append(k + "=" + quote(v.encode('utf-8'))) return '&'.join(query_args)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_encode_query'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '17', '56']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '9'], 'value': '=='}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '9', 'type': 'string', 'children': [], 'value': "''"}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'query_args'}; {'id': '16', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '17', 'type': 'for_statement', 'children': ['18', '19', '25']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'query_kv'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'&'"}; {'id': '25', 'type': 'block', 'children': ['26', '37']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '31']}; {'id': '28', 'type': 'pattern_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'query_kv'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'='"}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'query_args'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '47'], 'value': '+'}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '46'], 'value': '+'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"="'}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'quote'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'string', 'children': [], 'value': "'&'"}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'query_args'}
Quote all values of a query string.
def pkey_get(clas,pool_or_cursor,*vals): "lookup by primary keys in order" pkey = clas.PKEY.split(',') if len(vals)!=len(pkey): raise ValueError("%i args != %i-len primary key for %s"%(len(vals),len(pkey),clas.TABLE)) rows = list(clas.select(pool_or_cursor,**dict(zip(pkey,vals)))) if not rows: raise Missing return set_options(pool_or_cursor,clas(*rows[0]))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pkey_get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'clas'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'pool_or_cursor'}; {'id': '6', 'type': 'list_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '8', 'type': 'block', 'children': ['9', '11', '22', '51', '72', '78']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'string', 'children': [], 'value': '"lookup by primary keys in order"'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'pkey'}; {'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': 'clas'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'PKEY'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'string', 'children': [], 'value': "','"}; {'id': '22', 'type': 'if_statement', 'children': ['23', '32']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '28'], 'value': '!='}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'pkey'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'raise_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '%'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"%i args != %i-len primary key for %s"'}; {'id': '39', 'type': 'tuple', 'children': ['40', '44', '48']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'pkey'}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'clas'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'TABLE'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'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', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'clas'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'pool_or_cursor'}; {'id': '63', 'type': 'dictionary_splat', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'pkey'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '72', 'type': 'if_statement', 'children': ['73', '75']}; {'id': '73', 'type': 'not_operator', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'raise_statement', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'Missing'}; {'id': '78', 'type': 'return_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'set_options'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'pool_or_cursor'}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'clas'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'list_splat', 'children': ['87']}; {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '89', 'type': 'integer', 'children': [], 'value': '0'}
lookup by primary keys in order
def GetMetricMetadata(): return [ stats_utils.CreateCounterMetadata("grr_client_unknown"), stats_utils.CreateCounterMetadata("grr_decoding_error"), stats_utils.CreateCounterMetadata("grr_decryption_error"), stats_utils.CreateCounterMetadata("grr_authenticated_messages"), stats_utils.CreateCounterMetadata("grr_unauthenticated_messages"), stats_utils.CreateCounterMetadata("grr_rsa_operations"), stats_utils.CreateCounterMetadata( "grr_encrypted_cipher_cache", fields=[("type", str)]), ]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetMetricMetadata'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5']}; {'id': '5', 'type': 'return_statement', 'children': ['6']}; {'id': '6', 'type': 'list', 'children': ['7', '13', '19', '25', '31', '37', '43'], 'value': '[\n stats_utils.CreateCounterMetadata("grr_client_unknown"),\n stats_utils.CreateCounterMetadata("grr_decoding_error"),\n stats_utils.CreateCounterMetadata("grr_decryption_error"),\n stats_utils.CreateCounterMetadata("grr_authenticated_messages"),\n stats_utils.CreateCounterMetadata("grr_unauthenticated_messages"),\n stats_utils.CreateCounterMetadata("grr_rsa_operations"),\n stats_utils.CreateCounterMetadata(\n "grr_encrypted_cipher_cache", fields=[("type", str)]),\n ]'}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'stats_utils'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'CreateCounterMetadata'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'string', 'children': [], 'value': '"grr_client_unknown"'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'stats_utils'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'CreateCounterMetadata'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"grr_decoding_error"'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'stats_utils'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'CreateCounterMetadata'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': '"grr_decryption_error"'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'stats_utils'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'CreateCounterMetadata'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"grr_authenticated_messages"'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'stats_utils'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'CreateCounterMetadata'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': '"grr_unauthenticated_messages"'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'stats_utils'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'CreateCounterMetadata'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'string', 'children': [], 'value': '"grr_rsa_operations"'}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'stats_utils'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'CreateCounterMetadata'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49']}; {'id': '48', 'type': 'string', 'children': [], 'value': '"grr_encrypted_cipher_cache"'}; {'id': '49', 'type': 'keyword_argument', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '51', 'type': 'list', 'children': ['52'], 'value': '[("type", str)]'}; {'id': '52', 'type': 'tuple', 'children': ['53', '54']}; {'id': '53', 'type': 'string', 'children': [], 'value': '"type"'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'str'}
Returns a list of MetricMetadata for communicator-related metrics.
def _handle_token(self, token): try: return _HANDLERS[type(token)](self, token) except KeyError: err = "_handle_token() got unexpected {0}" raise ParserError(err.format(type(token).__name__))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_handle_token'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'try_statement', 'children': ['8', '20']}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'return_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '17']}; {'id': '11', 'type': 'subscript', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_HANDLERS'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '20', 'type': 'except_clause', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '22', 'type': 'block', 'children': ['23', '27']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '26', 'type': 'string', 'children': [], 'value': '"_handle_token() got unexpected {0}"'}; {'id': '27', 'type': 'raise_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ParserError'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'attribute', 'children': ['37', '41']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '__name__'}
Handle a single token.
def tree(): session = AppAggregate().open_session() classes = session.query(AssetClass).all() root = [] for ac in classes: if ac.parentid is None: root.append(ac) print_row("id", "asset class", "allocation", "level") print(f"-------------------------------") for ac in root: print_item_with_children(ac, classes, 0)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tree'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '15', '28', '32', '50', '58', '63']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'AppAggregate'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'open_session'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'classes'}; {'id': '18', 'type': 'call', 'children': ['19', '27']}; {'id': '19', 'type': 'attribute', 'children': ['20', '26']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'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': 'AssetClass'}; {'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', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '31', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '32', 'type': 'for_statement', 'children': ['33', '34', '35']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'classes'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'if_statement', 'children': ['37', '42']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '41'], 'value': 'is'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'parentid'}; {'id': '41', 'type': 'None', 'children': []}; {'id': '42', 'type': 'block', 'children': ['43']}; {'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': 'root'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'print_row'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55', '56', '57']}; {'id': '54', 'type': 'string', 'children': [], 'value': '"id"'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"asset class"'}; {'id': '56', 'type': 'string', 'children': [], 'value': '"allocation"'}; {'id': '57', 'type': 'string', 'children': [], 'value': '"level"'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'string', 'children': [], 'value': 'f"-------------------------------"'}; {'id': '63', 'type': 'for_statement', 'children': ['64', '65', '66']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'print_item_with_children'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72', '73']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'classes'}; {'id': '73', 'type': 'integer', 'children': [], 'value': '0'}
Display a tree of asset classes
def nx_all_nodes_between(graph, source, target, data=False): import utool as ut if source is None: sources = list(ut.nx_source_nodes(graph)) assert len(sources) == 1, ( 'specify source if there is not only one') source = sources[0] if target is None: sinks = list(ut.nx_sink_nodes(graph)) assert len(sinks) == 1, ( 'specify sink if there is not only one') target = sinks[0] all_simple_paths = list(nx.all_simple_paths(graph, source, target)) nodes = sorted(set.union(*map(set, all_simple_paths))) return nodes
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'nx_all_nodes_between'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'graph'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '9', 'type': 'False', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '16', '48', '80', '94', '111']}; {'id': '11', 'type': 'import_statement', 'children': ['12']}; {'id': '12', 'type': 'aliased_import', 'children': ['13', '15']}; {'id': '13', 'type': 'dotted_name', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'utool'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ut'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '20']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': 'is'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21', '33', '42']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sources'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ut'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'nx_source_nodes'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'graph'}; {'id': '33', 'type': 'assert_statement', 'children': ['34', '40']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '39'], 'value': '=='}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'sources'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '40', 'type': '()', 'children': ['41']}; {'id': '41', 'type': 'string', 'children': [], 'value': "'specify source if there is not only one'"}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'sources'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '52']}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '51'], 'value': 'is'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '51', 'type': 'None', 'children': []}; {'id': '52', 'type': 'block', 'children': ['53', '65', '74']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'sinks'}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'ut'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'nx_sink_nodes'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'graph'}; {'id': '65', 'type': 'assert_statement', 'children': ['66', '72']}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '71'], 'value': '=='}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'sinks'}; {'id': '71', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '72', 'type': '()', 'children': ['73']}; {'id': '73', 'type': 'string', 'children': [], 'value': "'specify sink if there is not only one'"}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'sinks'}; {'id': '79', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'all_simple_paths'}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'nx'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'all_simple_paths'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92', '93']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'graph'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '97', 'type': 'call', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'call', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'union'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'list_splat', 'children': ['106']}; {'id': '106', 'type': 'call', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '108', 'type': 'argument_list', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'all_simple_paths'}; {'id': '111', 'type': 'return_statement', 'children': ['112']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'nodes'}
Find all nodes with on paths between source and target.
def save_load(jid, load, minions=None): conn, mdb = _get_conn(ret=None) to_save = _safe_copy(load) if PYMONGO_VERSION > _LooseVersion('2.3'): mdb.jobs.insert_one(to_save) else: mdb.jobs.insert(to_save)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save_load'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'jid'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'minions'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '21', '28']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '15']}; {'id': '12', 'type': 'pattern_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'mdb'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_get_conn'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'to_save'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_safe_copy'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '35', '45']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': '>'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'PYMONGO_VERSION'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_LooseVersion'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'2.3'"}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '43']}; {'id': '38', 'type': 'attribute', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'mdb'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'jobs'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'insert_one'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'to_save'}; {'id': '45', 'type': 'else_clause', 'children': ['46']}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '54']}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'mdb'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'jobs'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'to_save'}
Save the load for a given job id
def parse_safari (url_data): from ..bookmarks.safari import parse_bookmark_data for url, name in parse_bookmark_data(url_data.get_content()): url_data.add_url(url, name=name)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_safari'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'url_data'}; {'id': '5', 'type': 'block', 'children': ['6', '14']}; {'id': '6', 'type': 'import_from_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'relative_import', 'children': ['8', '9']}; {'id': '8', 'type': 'import_prefix', 'children': []}; {'id': '9', 'type': 'dotted_name', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'bookmarks'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'safari'}; {'id': '12', 'type': 'dotted_name', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'parse_bookmark_data'}; {'id': '14', 'type': 'for_statement', 'children': ['15', '18', '26']}; {'id': '15', 'type': 'pattern_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'parse_bookmark_data'}; {'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': 'url_data'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'get_content'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'url_data'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'add_url'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'name'}
Parse a Safari bookmark file.
def prepend(self, *nodes: Union[str, AbstractNode]) -> None: node = _to_node_list(nodes) if self.firstChild: self.insertBefore(node, self.firstChild) else: self.appendChild(node)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prepend'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '8']}; {'id': '6', 'type': 'list_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '8', 'type': 'type', 'children': ['9']}; {'id': '9', 'type': 'generic_type', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Union'}; {'id': '11', 'type': 'type_parameter', 'children': ['12', '14']}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'AbstractNode'}; {'id': '16', 'type': 'type', 'children': ['17']}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19', '26']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_to_node_list'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '30', '41']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'firstChild'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'insertBefore'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'firstChild'}; {'id': '41', 'type': 'else_clause', 'children': ['42']}; {'id': '42', 'type': 'block', 'children': ['43']}; {'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': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'appendChild'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'node'}
Insert new nodes before first child node.
def nullval(cls): d = dict(cls.__dict__.items()) for k in d: d[k] = 0 d['sl'] = cls.sl d[cls.level] = 0 return cls(**d)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'nullval'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '29', '37', '45']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '__dict__'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'for_statement', 'children': ['20', '21', '22']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '28']}; {'id': '25', 'type': 'subscript', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '34']}; {'id': '31', 'type': 'subscript', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'sl'"}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'sl'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '44']}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'dictionary_splat', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'd'}
Create a new instance where all of the values are 0
def add_child(self, child, modify=False): SceneGraph.add_child(self, child) self.notify() if modify: child._model_matrix_transform[:] = trans.inverse_matrix(self.model_matrix_global) child._normal_matrix_transform[:] = trans.inverse_matrix(self.normal_matrix_global)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_child'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'modify'}; {'id': '8', 'type': 'False', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '18', '24']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'SceneGraph'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'add_child'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'child'}; {'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': 'notify'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'if_statement', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'modify'}; {'id': '26', 'type': 'block', 'children': ['27', '43']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '35']}; {'id': '29', 'type': 'subscript', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_model_matrix_transform'}; {'id': '33', 'type': 'slice', 'children': ['34']}; {'id': '34', 'type': 'colon', 'children': []}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'trans'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'inverse_matrix'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'model_matrix_global'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '51']}; {'id': '45', 'type': 'subscript', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_normal_matrix_transform'}; {'id': '49', 'type': 'slice', 'children': ['50']}; {'id': '50', 'type': 'colon', 'children': []}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'trans'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'inverse_matrix'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'normal_matrix_global'}
Adds an object as a child in the scene graph. With modify=True, model_matrix_transform gets change from identity and prevents the changes of the coordinates of the child
def _collect_external_resources(self, resource_attr): external_resources = [] for _, cls in sorted(Model.model_class_reverse_map.items(), key=lambda arg: arg[0]): external = getattr(cls, resource_attr, None) if isinstance(external, string_types): if external not in external_resources: external_resources.append(external) elif isinstance(external, list): for e in external: if e not in external_resources: external_resources.append(e) return external_resources
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_collect_external_resources'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'resource_attr'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '85']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'external_resources'}; {'id': '10', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '11', 'type': 'for_statement', 'children': ['12', '15', '33']}; {'id': '12', 'type': 'pattern_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '25']}; {'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': 'Model'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'model_class_reverse_map'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '27', 'type': 'lambda', 'children': ['28', '30']}; {'id': '28', 'type': 'lambda_parameters', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '33', 'type': 'block', 'children': ['34', '43']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'external'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41', '42']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'resource_attr'}; {'id': '42', 'type': 'None', 'children': []}; {'id': '43', 'type': 'if_statement', 'children': ['44', '49', '62']}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'external'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'string_types'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'if_statement', 'children': ['51', '54']}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '53'], 'value': 'not in'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'external'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'external_resources'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'external_resources'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'external'}; {'id': '62', 'type': 'elif_clause', 'children': ['63', '68']}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'external'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'for_statement', 'children': ['70', '71', '72']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'external'}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'if_statement', 'children': ['74', '77']}; {'id': '74', 'type': 'comparison_operator', 'children': ['75', '76'], 'value': 'not in'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'external_resources'}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'external_resources'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '85', 'type': 'return_statement', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'external_resources'}
Collect external resources set on resource_attr attribute of all models.
def PrintRanges(type, name, ranges): print "static const %s %s[] = {" % (type, name,) for lo, hi in ranges: print "\t{ %d, %d }," % (lo, hi) print "};"
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'PrintRanges'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ranges'}; {'id': '7', 'type': 'block', 'children': ['8', '14', '26']}; {'id': '8', 'type': 'print_statement', 'children': ['9']}; {'id': '9', 'type': 'binary_operator', 'children': ['10', '11'], 'value': '%'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"static const %s %s[] = {"'}; {'id': '11', 'type': 'tuple', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '14', 'type': 'for_statement', 'children': ['15', '18', '19']}; {'id': '15', 'type': 'pattern_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'lo'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'hi'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ranges'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'print_statement', 'children': ['21']}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '23'], 'value': '%'}; {'id': '22', 'type': 'string', 'children': [], 'value': '"\\t{ %d, %d },"'}; {'id': '23', 'type': 'tuple', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'lo'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'hi'}; {'id': '26', 'type': 'print_statement', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"};"'}
Print the ranges as an array of type named name.
def _parse_user_flags(): try: idx = list(sys.argv).index('--user-flags') user_flags_file = sys.argv[idx + 1] except (ValueError, IndexError): user_flags_file = '' if user_flags_file and os.path.isfile(user_flags_file): from ryu.utils import _import_module_file _import_module_file(user_flags_file)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_user_flags'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '40']}; {'id': '5', 'type': 'try_statement', 'children': ['6', '31']}; {'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': 'idx'}; {'id': '10', 'type': 'call', 'children': ['11', '19']}; {'id': '11', 'type': 'attribute', 'children': ['12', '18']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'--user-flags'"}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'user_flags_file'}; {'id': '24', 'type': 'subscript', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '30'], 'value': '+'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '31', 'type': 'except_clause', 'children': ['32', '35']}; {'id': '32', 'type': 'tuple', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'IndexError'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'user_flags_file'}; {'id': '39', 'type': 'string', 'children': [], 'value': "''"}; {'id': '40', 'type': 'if_statement', 'children': ['41', '51']}; {'id': '41', 'type': 'boolean_operator', 'children': ['42', '43'], 'value': 'and'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'user_flags_file'}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'user_flags_file'}; {'id': '51', 'type': 'block', 'children': ['52', '58']}; {'id': '52', 'type': 'import_from_statement', 'children': ['53', '56']}; {'id': '53', 'type': 'dotted_name', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'ryu'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '56', 'type': 'dotted_name', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '_import_module_file'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '_import_module_file'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'user_flags_file'}
Parses user-flags file and loads it to register user defined options.
def find_conda(): USER_HOME = os.path.expanduser('~') CONDA_HOME = os.environ.get('CONDA_HOME', '') PROGRAMDATA = os.environ.get('PROGRAMDATA', '') search_paths = [ join(PROGRAMDATA, 'miniconda2', 'scripts'), join(PROGRAMDATA, 'miniconda3', 'scripts'), join(USER_HOME, 'miniconda2', 'scripts'), join(USER_HOME, 'miniconda3', 'scripts'), join(CONDA_HOME, 'scripts'), join(USER_HOME, 'miniconda2', 'bin'), join(USER_HOME, 'miniconda3', 'bin'), join(CONDA_HOME, 'bin'), ] + os.environ.get("PATH", "").split(";" if 'win' in sys.path else ":") cmd = 'conda.exe' if IS_WIN else 'conda' for conda_path in search_paths: conda = join(conda_path, cmd) if exists(conda): return sh.Command(conda) return sh.conda
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_conda'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '16', '28', '40', '112', '119', '144']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'USER_HOME'}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'expanduser'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'~'"}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'CONDA_HOME'}; {'id': '19', 'type': 'call', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'CONDA_HOME'"}; {'id': '27', 'type': 'string', 'children': [], 'value': "''"}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'PROGRAMDATA'}; {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'PROGRAMDATA'"}; {'id': '39', 'type': 'string', 'children': [], 'value': "''"}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'search_paths'}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '91'], 'value': '+'}; {'id': '44', 'type': 'list', 'children': ['45', '51', '57', '63', '69', '74', '80', '86'], 'value': "[\n join(PROGRAMDATA, 'miniconda2', 'scripts'),\n join(PROGRAMDATA, 'miniconda3', 'scripts'),\n join(USER_HOME, 'miniconda2', 'scripts'),\n join(USER_HOME, 'miniconda3', 'scripts'),\n join(CONDA_HOME, 'scripts'),\n join(USER_HOME, 'miniconda2', 'bin'),\n join(USER_HOME, 'miniconda3', 'bin'),\n join(CONDA_HOME, 'bin'),\n ]"}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49', '50']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'PROGRAMDATA'}; {'id': '49', 'type': 'string', 'children': [], 'value': "'miniconda2'"}; {'id': '50', 'type': 'string', 'children': [], 'value': "'scripts'"}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55', '56']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'PROGRAMDATA'}; {'id': '55', 'type': 'string', 'children': [], 'value': "'miniconda3'"}; {'id': '56', 'type': 'string', 'children': [], 'value': "'scripts'"}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61', '62']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'USER_HOME'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'miniconda2'"}; {'id': '62', 'type': 'string', 'children': [], 'value': "'scripts'"}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67', '68']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'USER_HOME'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'miniconda3'"}; {'id': '68', 'type': 'string', 'children': [], 'value': "'scripts'"}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'CONDA_HOME'}; {'id': '73', 'type': 'string', 'children': [], 'value': "'scripts'"}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '76', 'type': 'argument_list', 'children': ['77', '78', '79']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'USER_HOME'}; {'id': '78', 'type': 'string', 'children': [], 'value': "'miniconda2'"}; {'id': '79', 'type': 'string', 'children': [], 'value': "'bin'"}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '82', 'type': 'argument_list', 'children': ['83', '84', '85']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'USER_HOME'}; {'id': '84', 'type': 'string', 'children': [], 'value': "'miniconda3'"}; {'id': '85', 'type': 'string', 'children': [], 'value': "'bin'"}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'CONDA_HOME'}; {'id': '90', 'type': 'string', 'children': [], 'value': "'bin'"}; {'id': '91', 'type': 'call', 'children': ['92', '103']}; {'id': '92', 'type': 'attribute', 'children': ['93', '102']}; {'id': '93', 'type': 'call', 'children': ['94', '99']}; {'id': '94', 'type': 'attribute', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '99', 'type': 'argument_list', 'children': ['100', '101']}; {'id': '100', 'type': 'string', 'children': [], 'value': '"PATH"'}; {'id': '101', 'type': 'string', 'children': [], 'value': '""'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'conditional_expression', 'children': ['105', '106', '111'], 'value': 'if'}; {'id': '105', 'type': 'string', 'children': [], 'value': '";"'}; {'id': '106', 'type': 'comparison_operator', 'children': ['107', '108'], 'value': 'in'}; {'id': '107', 'type': 'string', 'children': [], 'value': "'win'"}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '111', 'type': 'string', 'children': [], 'value': '":"'}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'assignment', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '115', 'type': 'conditional_expression', 'children': ['116', '117', '118'], 'value': 'if'}; {'id': '116', 'type': 'string', 'children': [], 'value': "'conda.exe'"}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'IS_WIN'}; {'id': '118', 'type': 'string', 'children': [], 'value': "'conda'"}; {'id': '119', 'type': 'for_statement', 'children': ['120', '121', '122']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'conda_path'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'search_paths'}; {'id': '122', 'type': 'block', 'children': ['123', '131']}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'conda'}; {'id': '126', 'type': 'call', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '128', 'type': 'argument_list', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'conda_path'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '131', 'type': 'if_statement', 'children': ['132', '136']}; {'id': '132', 'type': 'call', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'conda'}; {'id': '136', 'type': 'block', 'children': ['137']}; {'id': '137', 'type': 'return_statement', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '142']}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'sh'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'Command'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'conda'}; {'id': '144', 'type': 'return_statement', 'children': ['145']}; {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'sh'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'conda'}
Try to find conda on the system
def save(self): with open(self.store_file_path, 'w') as fh: fh.write(json.dumps(self.store, indent=4))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'with_statement', 'children': ['7', '19']}; {'id': '7', 'type': 'with_clause', 'children': ['8']}; {'id': '8', 'type': 'with_item', 'children': ['9']}; {'id': '9', 'type': 'as_pattern', 'children': ['10', '17']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'store_file_path'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '17', 'type': 'as_pattern_target', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'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': 'fh'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'write'}; {'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': 'json'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'indent'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '4'}
Write the store dict to a file specified by store_file_path
def connect_socket(self, sock: socket.socket) -> None: try: sock.connect((self._tunnel_host, self._tunnel_port)) except socket.timeout as e: raise ProxyError(self.ERR_PROXY_OFFLINE.format(str(e))) except socket.error as e: raise ProxyError(self.ERR_PROXY_OFFLINE.format(str(e))) if self._tunnel_basic_auth_token is None: sock.send(self.HTTP_CONNECT_REQ.format(self._server_host, self._server_port).encode('utf-8')) else: sock.send(self.HTTP_CONNECT_REQ_PROXY_AUTH_BASIC.format( self._server_host, self._server_port, self._tunnel_basic_auth_token ).encode('utf-8')) http_response = HttpResponseParser.parse_from_socket(sock) if http_response.status != 200: raise ProxyError(self.ERR_CONNECT_REJECTED)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connect_socket'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14', '75', '135', '144']}; {'id': '14', 'type': 'try_statement', 'children': ['15', '29', '52']}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'tuple', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_tunnel_host'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_tunnel_port'}; {'id': '29', 'type': 'except_clause', 'children': ['30', '36']}; {'id': '30', 'type': 'as_pattern', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '34', 'type': 'as_pattern_target', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'e'}; {'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': 'ProxyError'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'ERR_PROXY_OFFLINE'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '52', 'type': 'except_clause', 'children': ['53', '59']}; {'id': '53', 'type': 'as_pattern', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '57', 'type': 'as_pattern_target', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'raise_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'ProxyError'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '70']}; {'id': '65', 'type': 'attribute', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'ERR_PROXY_OFFLINE'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '75', 'type': 'if_statement', 'children': ['76', '81', '106']}; {'id': '76', 'type': 'comparison_operator', 'children': ['77', '80'], 'value': 'is'}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': '_tunnel_basic_auth_token'}; {'id': '80', 'type': 'None', 'children': []}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '104']}; {'id': '89', 'type': 'attribute', 'children': ['90', '103']}; {'id': '90', 'type': 'call', 'children': ['91', '96']}; {'id': '91', 'type': 'attribute', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'HTTP_CONNECT_REQ'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '96', 'type': 'argument_list', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': '_server_host'}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': '_server_port'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '106', 'type': 'else_clause', 'children': ['107']}; {'id': '107', 'type': 'block', 'children': ['108']}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'call', 'children': ['115', '133']}; {'id': '115', 'type': 'attribute', 'children': ['116', '132']}; {'id': '116', 'type': 'call', 'children': ['117', '122']}; {'id': '117', 'type': 'attribute', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'HTTP_CONNECT_REQ_PROXY_AUTH_BASIC'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '122', 'type': 'argument_list', 'children': ['123', '126', '129']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': '_server_host'}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': '_server_port'}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': '_tunnel_basic_auth_token'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '133', 'type': 'argument_list', 'children': ['134']}; {'id': '134', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'assignment', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'http_response'}; {'id': '138', 'type': 'call', 'children': ['139', '142']}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'HttpResponseParser'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'parse_from_socket'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '144', 'type': 'if_statement', 'children': ['145', '150']}; {'id': '145', 'type': 'comparison_operator', 'children': ['146', '149'], 'value': '!='}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'http_response'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '149', 'type': 'integer', 'children': [], 'value': '200'}; {'id': '150', 'type': 'block', 'children': ['151']}; {'id': '151', 'type': 'raise_statement', 'children': ['152']}; {'id': '152', 'type': 'call', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'ProxyError'}; {'id': '154', 'type': 'argument_list', 'children': ['155']}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'ERR_CONNECT_REJECTED'}
Setup HTTP tunneling with the configured proxy.
def _create_optimizer_node(self): self.lr_var = tf.Variable(0.0, trainable=False) tvars = tf.trainable_variables() grads, _ = tf.clip_by_global_norm(tf.gradients(self.cost, tvars), self.max_grad_norm) optimizer = tf.train.GradientDescentOptimizer(self.lr_var) self._train_op = optimizer.apply_gradients(zip(grads, tvars))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_optimizer_node'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '28', '50', '63']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'lr_var'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Variable'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'trainable'}; {'id': '19', 'type': 'False', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'tvars'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'trainable_variables'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '33']}; {'id': '30', 'type': 'pattern_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'grads'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'clip_by_global_norm'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '47']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'gradients'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'cost'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'tvars'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'max_grad_norm'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'optimizer'}; {'id': '53', 'type': 'call', 'children': ['54', '59']}; {'id': '54', 'type': 'attribute', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'train'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'GradientDescentOptimizer'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'lr_var'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': '_train_op'}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'optimizer'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'apply_gradients'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'grads'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'tvars'}
Create the optimizer node of the graph.
def _pack(self): data = ByteBuffer() if not hasattr(self, '__fields__'): return data.array for field in self.__fields__: field.encode(self, data) return data.array
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_pack'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '24', '38']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'ByteBuffer'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'if_statement', 'children': ['13', '19']}; {'id': '13', 'type': 'not_operator', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'__fields__'"}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '24', 'type': 'for_statement', 'children': ['25', '26', '29']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '__fields__'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'array'}
Pack the message and return an array.
def close(self, suppress_logging=False): pool_names = list(self.pools) for name in pool_names: self._close(name, suppress_logging)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close'}; {'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': 'suppress_logging'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '18']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'pool_names'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'pools'}; {'id': '18', 'type': 'for_statement', 'children': ['19', '20', '21']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'pool_names'}; {'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': '_close'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'suppress_logging'}
iterates thru all publisher pools and closes them
def _call(self, x, out=None): wrapped_x = self.prod_op.domain.element([x], cast=False) return self.prod_op(wrapped_x, out=out)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_call'}; {'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': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '27']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'wrapped_x'}; {'id': '13', 'type': 'call', 'children': ['14', '21']}; {'id': '14', 'type': 'attribute', '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': 'prod_op'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '24']}; {'id': '22', 'type': 'list', 'children': ['23'], 'value': '[x]'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'cast'}; {'id': '26', 'type': 'False', 'children': []}; {'id': '27', 'type': 'return_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': 'prod_op'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'wrapped_x'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'out'}
Evaluate all operators in ``x`` and broadcast.
def list_lbaas_l7policies(self, retrieve_all=True, **_params): return self.list('l7policies', self.lbaas_l7policies_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_lbaas_l7policies'}; {'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': "'l7policies'"}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'lbaas_l7policies_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 L7 policies for a listener.
def sanitize_word(word): if type(word) == str: try: word = word.decode() except AttributeError: pass word = word.strip() word = re.sub(r'\([^)]*\)', '', word) word = re.sub(r'[ "\'-;.]+', '', unidecode(word)) return word.lower()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sanitize_word'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '5', 'type': 'block', 'children': ['6', '28', '36', '47', '61']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '13']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '12'], 'value': '=='}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'try_statement', 'children': ['15', '24']}; {'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': 'word'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'except_clause', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'pass_statement', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45', '46']}; {'id': '44', 'type': 'string', 'children': [], 'value': "r'\\([^)]*\\)'"}; {'id': '45', 'type': 'string', 'children': [], 'value': "''"}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56', '57']}; {'id': '55', 'type': 'string', 'children': [], 'value': 'r\'[ "\\\'-;.]+\''}; {'id': '56', 'type': 'string', 'children': [], 'value': "''"}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'unidecode'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '61', 'type': 'return_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '66', 'type': 'argument_list', 'children': []}
sanitize a word by removing its accents, special characters, etc
def signup(self, project_name, email): uri = 'openstack/sign-up' data = { "project_name": project_name, "email": email, } post_body = json.dumps(data) resp, body = self.post(uri, body=post_body) self.expected_success(200, resp.status) body = json.loads(body) return rest_client.ResponseBody(resp, body)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'signup'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'project_name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '7', 'type': 'block', 'children': ['8', '12', '22', '31', '45', '55', '64']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'uri'}; {'id': '11', 'type': 'string', 'children': [], 'value': "'openstack/sign-up'"}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '15', 'type': 'dictionary', 'children': ['16', '19']}; {'id': '16', 'type': 'pair', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"project_name"'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'project_name'}; {'id': '19', 'type': 'pair', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"email"'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'post_body'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'pattern_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'resp'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'post'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'uri'}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'post_body'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'expected_success'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'integer', 'children': [], 'value': '200'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'resp'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '64', 'type': 'return_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'rest_client'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'ResponseBody'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'resp'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'body'}
Signup for a new project.
def _update_checksum(self): source_list = [int(octet) for octet in self.source.split(".")] destination_list = [int(octet) for octet in self.destination.split(".")] source_upper = (source_list[0] << 8) + source_list[1] source_lower = (source_list[2] << 8) + source_list[3] destination_upper = (destination_list[0] << 8) + destination_list[1] destination_lower = (destination_list[2] << 8) + destination_list[3] block_sum = ((self._version_ihl << 8 | self._dscp_ecn) + self.length + self.identification + self._flags_offset + (self.ttl << 8 | self.protocol) + source_upper + source_lower + destination_upper + destination_lower) while block_sum > 65535: carry = block_sum >> 16 block_sum = (block_sum & 65535) + carry self.checksum = ~block_sum & 65535
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_checksum'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '24', '42', '55', '68', '81', '94', '139', '159']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'source_list'}; {'id': '9', 'type': 'list_comprehension', 'children': ['10', '14']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'octet'}; {'id': '14', 'type': 'for_in_clause', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'octet'}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'string', 'children': [], 'value': '"."'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'destination_list'}; {'id': '27', 'type': 'list_comprehension', 'children': ['28', '32']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'octet'}; {'id': '32', 'type': 'for_in_clause', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'octet'}; {'id': '34', 'type': 'call', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'destination'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'string', 'children': [], 'value': '"."'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'source_upper'}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '52'], 'value': '+'}; {'id': '46', 'type': '()', 'children': ['47']}; {'id': '47', 'type': 'binary_operator', 'children': ['48', '51'], 'value': '<<'}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'source_list'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'source_list'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'source_lower'}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '65'], 'value': '+'}; {'id': '59', 'type': '()', 'children': ['60']}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '64'], 'value': '<<'}; {'id': '61', 'type': 'subscript', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'source_list'}; {'id': '63', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '64', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'source_list'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'destination_upper'}; {'id': '71', 'type': 'binary_operator', 'children': ['72', '78'], 'value': '+'}; {'id': '72', 'type': '()', 'children': ['73']}; {'id': '73', 'type': 'binary_operator', 'children': ['74', '77'], 'value': '<<'}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'destination_list'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '77', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '78', 'type': 'subscript', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'destination_list'}; {'id': '80', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'destination_lower'}; {'id': '84', 'type': 'binary_operator', 'children': ['85', '91'], 'value': '+'}; {'id': '85', 'type': '()', 'children': ['86']}; {'id': '86', 'type': 'binary_operator', 'children': ['87', '90'], 'value': '<<'}; {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'destination_list'}; {'id': '89', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '90', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '91', 'type': 'subscript', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'destination_list'}; {'id': '93', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'block_sum'}; {'id': '97', 'type': '()', 'children': ['98']}; {'id': '98', 'type': 'binary_operator', 'children': ['99', '138'], 'value': '+'}; {'id': '99', 'type': 'binary_operator', 'children': ['100', '137'], 'value': '+'}; {'id': '100', 'type': 'binary_operator', 'children': ['101', '136'], 'value': '+'}; {'id': '101', 'type': 'binary_operator', 'children': ['102', '135'], 'value': '+'}; {'id': '102', 'type': 'binary_operator', 'children': ['103', '125'], 'value': '+'}; {'id': '103', 'type': 'binary_operator', 'children': ['104', '122'], 'value': '+'}; {'id': '104', 'type': 'binary_operator', 'children': ['105', '119'], 'value': '+'}; {'id': '105', 'type': 'binary_operator', 'children': ['106', '116'], 'value': '+'}; {'id': '106', 'type': '()', 'children': ['107']}; {'id': '107', 'type': 'binary_operator', 'children': ['108', '113'], 'value': '|'}; {'id': '108', 'type': 'binary_operator', 'children': ['109', '112'], 'value': '<<'}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': '_version_ihl'}; {'id': '112', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': '_dscp_ecn'}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'identification'}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': '_flags_offset'}; {'id': '125', 'type': '()', 'children': ['126']}; {'id': '126', 'type': 'binary_operator', 'children': ['127', '132'], 'value': '|'}; {'id': '127', 'type': 'binary_operator', 'children': ['128', '131'], 'value': '<<'}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'ttl'}; {'id': '131', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'protocol'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'source_upper'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'source_lower'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'destination_upper'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'destination_lower'}; {'id': '139', 'type': 'while_statement', 'children': ['140', '143']}; {'id': '140', 'type': 'comparison_operator', 'children': ['141', '142'], 'value': '>'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'block_sum'}; {'id': '142', 'type': 'integer', 'children': [], 'value': '65535'}; {'id': '143', 'type': 'block', 'children': ['144', '150']}; {'id': '144', 'type': 'expression_statement', 'children': ['145']}; {'id': '145', 'type': 'assignment', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'carry'}; {'id': '147', 'type': 'binary_operator', 'children': ['148', '149'], 'value': '>>'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'block_sum'}; {'id': '149', 'type': 'integer', 'children': [], 'value': '16'}; {'id': '150', 'type': 'expression_statement', 'children': ['151']}; {'id': '151', 'type': 'assignment', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'block_sum'}; {'id': '153', 'type': 'binary_operator', 'children': ['154', '158'], 'value': '+'}; {'id': '154', 'type': '()', 'children': ['155']}; {'id': '155', 'type': 'binary_operator', 'children': ['156', '157'], 'value': '&'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'block_sum'}; {'id': '157', 'type': 'integer', 'children': [], 'value': '65535'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'carry'}; {'id': '159', 'type': 'expression_statement', 'children': ['160']}; {'id': '160', 'type': 'assignment', 'children': ['161', '164']}; {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'checksum'}; {'id': '164', 'type': 'binary_operator', 'children': ['165', '167'], 'value': '&'}; {'id': '165', 'type': 'unary_operator', 'children': ['166'], 'value': '~'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'block_sum'}; {'id': '167', 'type': 'integer', 'children': [], 'value': '65535'}
Update the packet checksum to enable integrity check.
def check_address(self, address): if address is None: self.raise_error(InvalidAddress, details='address is None') if all(letter == address[0] for letter in address) or len(address) < self.minFundingAddressLength or ' ' in address: self.raise_error(InvalidAddress, details='address is invalid or has less than ' + str(self.minFundingAddressLength) + ' characters: "' + str(address) + '"') return address
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_address'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '6', 'type': 'block', 'children': ['7', '22', '74']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'is'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'raise_error'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'InvalidAddress'}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'details'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'address is None'"}; {'id': '22', 'type': 'if_statement', 'children': ['23', '47']}; {'id': '23', 'type': 'boolean_operator', 'children': ['24', '44'], 'value': 'or'}; {'id': '24', 'type': 'boolean_operator', 'children': ['25', '36'], 'value': 'or'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '27', 'type': 'generator_expression', 'children': ['28', '33']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '30'], 'value': '=='}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'letter'}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '33', 'type': 'for_in_clause', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'letter'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '41'], 'value': '<'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'minFundingAddressLength'}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '46'], 'value': 'in'}; {'id': '45', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'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': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'raise_error'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'InvalidAddress'}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'details'}; {'id': '57', 'type': 'binary_operator', 'children': ['58', '73'], 'value': '+'}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '69'], 'value': '+'}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '68'], 'value': '+'}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '62'], 'value': '+'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'address is invalid or has less than '"}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'minFundingAddressLength'}; {'id': '68', 'type': 'string', 'children': [], 'value': '\' characters: "\''}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '73', 'type': 'string', 'children': [], 'value': '\'"\''}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'address'}
Checks an address is not the same character repeated or an empty sequence
def inasafe_sub_analysis_summary_field_value( exposure_key, field, feature, parent): _ = feature, parent project_context_scope = QgsExpressionContextUtils.projectScope( QgsProject.instance()) project = QgsProject.instance() key = ('{provenance}__{exposure}').format( provenance=provenance_multi_exposure_analysis_summary_layers_id[ 'provenance_key'], exposure=exposure_key) if not project_context_scope.hasVariable(key): return None analysis_summary_layer = project.mapLayer( project_context_scope.variable(key)) if not analysis_summary_layer: return None index = analysis_summary_layer.fields().lookupField(field) if index < 0: return None feature = next(analysis_summary_layer.getFeatures()) return feature[index]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'inasafe_sub_analysis_summary_field_value'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'exposure_key'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '8', 'type': 'block', 'children': ['9', '15', '28', '36', '53', '64', '78', '84', '97', '104', '115']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '12', 'type': 'expression_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'project_context_scope'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'QgsExpressionContextUtils'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'projectScope'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'QgsProject'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'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': 'project'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'QgsProject'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '39', 'type': 'call', 'children': ['40', '44']}; {'id': '40', 'type': 'attribute', 'children': ['41', '43']}; {'id': '41', 'type': '()', 'children': ['42']}; {'id': '42', 'type': 'string', 'children': [], 'value': "'{provenance}__{exposure}'"}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '50']}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'provenance'}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'provenance_multi_exposure_analysis_summary_layers_id'}; {'id': '49', 'type': 'string', 'children': [], 'value': "'provenance_key'"}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'exposure'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'exposure_key'}; {'id': '53', 'type': 'if_statement', 'children': ['54', '61']}; {'id': '54', 'type': 'not_operator', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'project_context_scope'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'hasVariable'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'return_statement', 'children': ['63']}; {'id': '63', 'type': 'None', 'children': []}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'analysis_summary_layer'}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'mapLayer'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'project_context_scope'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '78', 'type': 'if_statement', 'children': ['79', '81']}; {'id': '79', 'type': 'not_operator', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'analysis_summary_layer'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'return_statement', 'children': ['83']}; {'id': '83', 'type': 'None', 'children': []}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '87', 'type': 'call', 'children': ['88', '95']}; {'id': '88', 'type': 'attribute', 'children': ['89', '94']}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'analysis_summary_layer'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '93', 'type': 'argument_list', 'children': []}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'lookupField'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '97', 'type': 'if_statement', 'children': ['98', '101']}; {'id': '98', 'type': 'comparison_operator', 'children': ['99', '100'], 'value': '<'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '100', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'return_statement', 'children': ['103']}; {'id': '103', 'type': 'None', 'children': []}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'assignment', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'next'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'analysis_summary_layer'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'getFeatures'}; {'id': '114', 'type': 'argument_list', 'children': []}; {'id': '115', 'type': 'return_statement', 'children': ['116']}; {'id': '116', 'type': 'subscript', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'index'}
Retrieve a value from field in the specified exposure analysis layer.
def _get_ids_from_hostname(self, hostname): results = self.list_instances(hostname=hostname, mask="id") return [result['id'] for result in results]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_ids_from_hostname'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'hostname'}; {'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': 'results'}; {'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': 'list_instances'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '18']}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'hostname'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'hostname'}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '20', 'type': 'string', 'children': [], 'value': '"id"'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'list_comprehension', 'children': ['23', '26']}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '26', 'type': 'for_in_clause', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'results'}
List VS ids which match the given hostname.
def _concat(self, first_data, second_data): assert len(first_data) == len( second_data), 'data source should contain the same size' if first_data and second_data: return [ concat( first_data[x], second_data[x], dim=0 ) for x in range(len(first_data)) ] elif (not first_data) and (not second_data): return [] else: return [ first_data[0] if first_data else second_data[0] for x in range(len(first_data)) ]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_concat'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'first_data'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'second_data'}; {'id': '7', 'type': 'block', 'children': ['8', '19']}; {'id': '8', 'type': 'assert_statement', 'children': ['9', '18']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '14'], 'value': '=='}; {'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': 'first_data'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'second_data'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'data source should contain the same size'"}; {'id': '19', 'type': 'if_statement', 'children': ['20', '23', '47', '58']}; {'id': '20', 'type': 'boolean_operator', 'children': ['21', '22'], 'value': 'and'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'first_data'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'second_data'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'list_comprehension', 'children': ['26', '38']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'concat'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '32', '35']}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'first_data'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'second_data'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'dim'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '38', 'type': 'for_in_clause', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'first_data'}; {'id': '47', 'type': 'elif_clause', 'children': ['48', '55']}; {'id': '48', 'type': 'boolean_operator', 'children': ['49', '52'], 'value': 'and'}; {'id': '49', 'type': '()', 'children': ['50']}; {'id': '50', 'type': 'not_operator', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'first_data'}; {'id': '52', 'type': '()', 'children': ['53']}; {'id': '53', 'type': 'not_operator', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'second_data'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '58', 'type': 'else_clause', 'children': ['59']}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'list_comprehension', 'children': ['62', '70']}; {'id': '62', 'type': 'conditional_expression', 'children': ['63', '66', '67'], 'value': 'if'}; {'id': '63', 'type': 'subscript', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'first_data'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'first_data'}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'second_data'}; {'id': '69', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '70', 'type': 'for_in_clause', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'first_data'}
Helper function to concat two NDArrays.
def _get_dirs(user_dir, startup_dir): try: users = os.listdir(user_dir) except WindowsError: users = [] full_dirs = [] for user in users: full_dir = os.path.join(user_dir, user, startup_dir) if os.path.exists(full_dir): full_dirs.append(full_dir) return full_dirs
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_dirs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'user_dir'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'startup_dir'}; {'id': '6', 'type': 'block', 'children': ['7', '25', '29', '63']}; {'id': '7', 'type': 'try_statement', 'children': ['8', '18']}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'users'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'listdir'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'user_dir'}; {'id': '18', 'type': 'except_clause', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'WindowsError'}; {'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': 'users'}; {'id': '24', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'full_dirs'}; {'id': '28', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '29', 'type': 'for_statement', 'children': ['30', '31', '32']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'users'}; {'id': '32', 'type': 'block', 'children': ['33', '46']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'full_dir'}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44', '45']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'user_dir'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'startup_dir'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '55']}; {'id': '47', 'type': 'call', 'children': ['48', '53']}; {'id': '48', 'type': 'attribute', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'full_dir'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'full_dirs'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'full_dir'}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'full_dirs'}
Return a list of startup dirs
def _handle_tag_jpegtables(self): obj = _make_object("JPEGTables") assert self._src.read(2) == b'\xFF\xD8' eoimark1 = eoimark2 = None allbytes = [b'\xFF\xD8'] while not (eoimark1 == b'\xFF' and eoimark2 == b'\xD9'): newbyte = self._src.read(1) allbytes.append(newbyte) eoimark1 = eoimark2 eoimark2 = newbyte obj.JPEGData = b"".join(allbytes[:-2]) return obj
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_handle_tag_jpegtables'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '24', '30', '35', '72', '88']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_make_object'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'string', 'children': [], 'value': '"JPEGTables"'}; {'id': '13', 'type': 'assert_statement', 'children': ['14']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '23'], 'value': '=='}; {'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': '_src'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '23', 'type': 'string', 'children': [], 'value': "b'\\xFF\\xD8'"}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'eoimark1'}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'eoimark2'}; {'id': '29', 'type': 'None', 'children': []}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'allbytes'}; {'id': '33', 'type': 'list', 'children': ['34'], 'value': "[b'\\xFF\\xD8']"}; {'id': '34', 'type': 'string', 'children': [], 'value': "b'\\xFF\\xD8'"}; {'id': '35', 'type': 'while_statement', 'children': ['36', '45']}; {'id': '36', 'type': 'not_operator', 'children': ['37']}; {'id': '37', 'type': '()', 'children': ['38']}; {'id': '38', 'type': 'boolean_operator', 'children': ['39', '42'], 'value': 'and'}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '41'], 'value': '=='}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'eoimark1'}; {'id': '41', 'type': 'string', 'children': [], 'value': "b'\\xFF'"}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': '=='}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'eoimark2'}; {'id': '44', 'type': 'string', 'children': [], 'value': "b'\\xD9'"}; {'id': '45', 'type': 'block', 'children': ['46', '57', '64', '68']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'newbyte'}; {'id': '49', 'type': 'call', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': '_src'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'allbytes'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'newbyte'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'eoimark1'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'eoimark2'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'eoimark2'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'newbyte'}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'JPEGData'}; {'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': 'subscript', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'allbytes'}; {'id': '84', 'type': 'slice', 'children': ['85', '86']}; {'id': '85', 'type': 'colon', 'children': []}; {'id': '86', 'type': 'unary_operator', 'children': ['87'], 'value': '-'}; {'id': '87', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '88', 'type': 'return_statement', 'children': ['89']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'obj'}
Handle the JPEGTables tag.
def remove_all_nexusport_bindings(): LOG.debug("remove_all_nexusport_bindings() called") session = bc.get_writer_session() session.query(nexus_models_v2.NexusPortBinding).delete() session.flush()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_all_nexusport_bindings'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '12', '20', '33']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'call', 'children': ['7', '10']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'LOG'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'string', 'children': [], 'value': '"remove_all_nexusport_bindings() called"'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'bc'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get_writer_session'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '32']}; {'id': '22', 'type': 'attribute', 'children': ['23', '31']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'nexus_models_v2'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'NexusPortBinding'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'delete'}; {'id': '32', 'type': 'argument_list', 'children': []}; {'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': 'session'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'flush'}; {'id': '38', 'type': 'argument_list', 'children': []}
Removes all nexusport bindings.
def _load_rsp(rsp): first = rsp.find('(') + 1 last = rsp.rfind(')') return json.loads(rsp[first:last])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_load_rsp'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'rsp'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '26']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '9', 'type': 'binary_operator', 'children': ['10', '16'], 'value': '+'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'rsp'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'('"}; {'id': '16', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'last'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'rsp'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'rfind'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "')'"}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'rsp'}; {'id': '34', 'type': 'slice', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '36', 'type': 'colon', 'children': []}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'last'}
Converts raw Flickr string response to Python dict
def transformer_wikitext103_l16k_memory_v0(): hparams = transformer_wikitext103_l4k_memory_v0() hparams.max_length = 16384 hparams.split_targets_chunk_length = 64 hparams.split_targets_max_chunks = int( hparams.max_length / hparams.split_targets_chunk_length) target_tokens_per_batch = 4096 hparams.batch_size = int(target_tokens_per_batch * ( hparams.max_length / hparams.split_targets_chunk_length)) hparams.max_relative_position = 2 * hparams.split_targets_chunk_length return hparams
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'transformer_wikitext103_l16k_memory_v0'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '17', '23', '38', '42', '60', '70']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'transformer_wikitext103_l4k_memory_v0'}; {'id': '10', 'type': 'argument_list', 'children': []}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'max_length'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '16384'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'split_targets_chunk_length'}; {'id': '22', 'type': 'integer', 'children': [], 'value': '64'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'split_targets_max_chunks'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '35'], 'value': '/'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'max_length'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'split_targets_chunk_length'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'target_tokens_per_batch'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '4096'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'batch_size'}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '52'], 'value': '*'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'target_tokens_per_batch'}; {'id': '52', 'type': '()', 'children': ['53']}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '57'], 'value': '/'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'max_length'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'split_targets_chunk_length'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'max_relative_position'}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '67'], 'value': '*'}; {'id': '66', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'split_targets_chunk_length'}; {'id': '70', 'type': 'return_statement', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'hparams'}
HParams for training languagemodel_wikitext103_l16k with memory.
def extract_images_jbig2(pike, root, log, options): jbig2_groups = defaultdict(list) for pageno, xref, ext in extract_images( pike, root, log, options, extract_image_jbig2 ): group = pageno // options.jbig2_page_group_size jbig2_groups[group].append((xref, ext)) jbig2_groups = { group: xrefs for group, xrefs in jbig2_groups.items() if len(xrefs) > 0 } log.debug("Optimizable images: JBIG2 groups: %s", (len(jbig2_groups),)) return jbig2_groups
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_images_jbig2'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pike'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '8', 'type': 'block', 'children': ['9', '16', '49', '72', '84']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'jbig2_groups'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'defaultdict'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '16', 'type': 'for_statement', 'children': ['17', '21', '29']}; {'id': '17', 'type': 'pattern_list', 'children': ['18', '19', '20']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'pageno'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'xref'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'extract_images'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25', '26', '27', '28']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'pike'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'extract_image_jbig2'}; {'id': '29', 'type': 'block', 'children': ['30', '38']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '35'], 'value': '//'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'pageno'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'jbig2_page_group_size'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'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': 'jbig2_groups'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'tuple', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'xref'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'jbig2_groups'}; {'id': '52', 'type': 'dictionary_comprehension', 'children': ['53', '56', '65']}; {'id': '53', 'type': 'pair', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'xrefs'}; {'id': '56', 'type': 'for_in_clause', 'children': ['57', '60']}; {'id': '57', 'type': 'pattern_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'xrefs'}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'jbig2_groups'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '64', 'type': 'argument_list', 'children': []}; {'id': '65', 'type': 'if_clause', 'children': ['66']}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '71'], 'value': '>'}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'xrefs'}; {'id': '71', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'log'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79']}; {'id': '78', 'type': 'string', 'children': [], 'value': '"Optimizable images: JBIG2 groups: %s"'}; {'id': '79', 'type': 'tuple', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'jbig2_groups'}; {'id': '84', 'type': 'return_statement', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'jbig2_groups'}
Extract any bitonal image that we think we can improve as JBIG2
def _cmd_up(self): revision = self._get_revision() if not self._rev: self._log(0, "upgrading current revision") else: self._log(0, "upgrading from revision %s" % revision) for rev in self._revisions[int(revision) - 1:]: sql_files = glob.glob(os.path.join(self._migration_path, rev, "*.up.sql")) sql_files.sort() self._exec(sql_files, rev) self._log(0, "done: upgraded revision to %s\n" % rev)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_cmd_up'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '40', '89']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'revision'}; {'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_revision'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'if_statement', 'children': ['15', '19', '28']}; {'id': '15', 'type': 'not_operator', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_rev'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'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': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_log'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"upgrading current revision"'}; {'id': '28', 'type': 'else_clause', 'children': ['29']}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_log'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '%'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"upgrading from revision %s"'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'revision'}; {'id': '40', 'type': 'for_statement', 'children': ['41', '42', '54']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'rev'}; {'id': '42', 'type': 'subscript', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': '_revisions'}; {'id': '46', 'type': 'slice', 'children': ['47', '53']}; {'id': '47', 'type': 'binary_operator', 'children': ['48', '52'], 'value': '-'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'revision'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '53', 'type': 'colon', 'children': []}; {'id': '54', 'type': 'block', 'children': ['55', '75', '81']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'sql_files'}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '69']}; {'id': '64', 'type': 'attribute', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '73', '74']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': '_migration_path'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'rev'}; {'id': '74', 'type': 'string', 'children': [], 'value': '"*.up.sql"'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'sql_files'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '80', 'type': 'argument_list', 'children': []}; {'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': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': '_exec'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'sql_files'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'rev'}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': '_log'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '96']}; {'id': '95', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '96', 'type': 'binary_operator', 'children': ['97', '98'], 'value': '%'}; {'id': '97', 'type': 'string', 'children': [], 'value': '"done: upgraded revision to %s\\n"'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'rev'}
Upgrade to a revision
def url(self): "Returns the URL that can be visited to obtain a verifier code" query_string = {'oauth_token': self.oauth_token} if self.scope: query_string['scope'] = self.scope url = XERO_BASE_URL + AUTHORIZE_URL + '?' + \ urlencode(query_string) return url
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'url'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '17', '30', '44']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': '"Returns the URL that can be visited to obtain a verifier code"'}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'query_string'}; {'id': '11', 'type': 'dictionary', 'children': ['12']}; {'id': '12', 'type': 'pair', 'children': ['13', '14']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'oauth_token'"}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'oauth_token'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '27']}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'query_string'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'scope'"}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '39', '40'], 'value': '+'}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '38'], 'value': '+'}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '37'], 'value': '+'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'XERO_BASE_URL'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'AUTHORIZE_URL'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'?'"}; {'id': '39', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'urlencode'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'query_string'}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'url'}
Returns the URL that can be visited to obtain a verifier code
def fprint(self, file, indent): return lib.zdir_fprint(self._as_parameter_, coerce_py_file(file), indent)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fprint'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'indent'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'lib'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'zdir_fprint'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '17', '21']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_as_parameter_'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'coerce_py_file'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'indent'}
Print contents of directory to open stream
def skimage_sinogram_space(geometry, volume_space, sinogram_space): padded_size = int(np.ceil(volume_space.shape[0] * np.sqrt(2))) det_width = volume_space.domain.extent[0] * np.sqrt(2) skimage_detector_part = uniform_partition(-det_width / 2.0, det_width / 2.0, padded_size) skimage_range_part = geometry.motion_partition.insert( 1, skimage_detector_part) skimage_range = uniform_discr_frompartition(skimage_range_part, interp=sinogram_space.interp, dtype=sinogram_space.dtype) return skimage_range
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'skimage_sinogram_space'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'geometry'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'volume_space'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'sinogram_space'}; {'id': '7', 'type': 'block', 'children': ['8', '31', '48', '62', '74', '91']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'padded_size'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'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': 'ceil'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '25'], 'value': '*'}; {'id': '20', 'type': 'subscript', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'volume_space'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'sqrt'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'det_width'}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '42'], 'value': '*'}; {'id': '35', 'type': 'subscript', 'children': ['36', '41']}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'volume_space'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'extent'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'sqrt'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'skimage_detector_part'}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'uniform_partition'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '58', '61']}; {'id': '54', 'type': 'binary_operator', 'children': ['55', '57'], 'value': '/'}; {'id': '55', 'type': 'unary_operator', 'children': ['56'], 'value': '-'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'det_width'}; {'id': '57', 'type': 'float', 'children': [], 'value': '2.0'}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '60'], 'value': '/'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'det_width'}; {'id': '60', 'type': 'float', 'children': [], 'value': '2.0'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'padded_size'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'skimage_range_part'}; {'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': 'geometry'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'motion_partition'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'skimage_detector_part'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'skimage_range'}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'uniform_discr_frompartition'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '81', '86']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'skimage_range_part'}; {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'interp'}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'sinogram_space'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'interp'}; {'id': '86', 'type': 'keyword_argument', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'sinogram_space'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '91', 'type': 'return_statement', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'skimage_range'}
Create a range adapted to the skimage radon geometry.
def handle_input(self, input_str, place=True, check=False): user = self.get_player() pos = self.validate_input(input_str) if pos[0] == 'u': self.undo(pos[1]) return pos if place: result = self.set_pos(pos, check) return result else: return pos
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_input'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'input_str'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'place'}; {'id': '8', 'type': 'True', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'check'}; {'id': '11', 'type': 'False', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '21', '30', '48']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'get_player'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'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': 'validate_input'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'input_str'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '36']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '35'], 'value': '=='}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'u'"}; {'id': '36', 'type': 'block', 'children': ['37', '46']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'undo'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '50', '63']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'place'}; {'id': '50', 'type': 'block', 'children': ['51', '61']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'set_pos'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'check'}; {'id': '61', 'type': 'return_statement', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '63', 'type': 'else_clause', 'children': ['64']}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'return_statement', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'pos'}
Transfer user input to valid chess position
def close_files(self): for name in self: if getattr(self, '_%s_diskflag' % name): file_ = getattr(self, '_%s_file' % name) file_.close()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close_files'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '9']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '18']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '17'], 'value': '%'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'_%s_diskflag'"}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '18', 'type': 'block', 'children': ['19', '29']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'file_'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '28'], 'value': '%'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'_%s_file'"}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'file_'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '34', 'type': 'argument_list', 'children': []}
Close all files with an activated disk flag.
def make_transparent(image): data = image.copy().getdata() modified = [] for item in data: if _check_pixel(item) is True: modified.append((255, 255, 255, 255)) continue modified.append(item) image.putdata(modified) return image
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_transparent'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '22', '53', '60']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '9', 'type': 'call', 'children': ['10', '17']}; {'id': '10', 'type': 'attribute', 'children': ['11', '16']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'getdata'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'modified'}; {'id': '21', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '22', 'type': 'for_statement', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '25', 'type': 'block', 'children': ['26', '46']}; {'id': '26', 'type': 'if_statement', 'children': ['27', '33']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '32'], 'value': 'is'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_check_pixel'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '32', 'type': 'True', 'children': []}; {'id': '33', 'type': 'block', 'children': ['34', '45']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'modified'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'tuple', 'children': ['41', '42', '43', '44']}; {'id': '41', 'type': 'integer', 'children': [], 'value': '255'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '255'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '255'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '255'}; {'id': '45', 'type': 'continue_statement', 'children': []}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'modified'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'item'}; {'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': 'image'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'putdata'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'modified'}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'image'}
Turn all black pixels in an image into transparent ones
def _get_datetimes(self, timestep=1): start_moy = DateTime(self._month, self._day_of_month).moy if timestep == 1: start_moy = start_moy + 30 num_moys = 24 * timestep return tuple( DateTime.from_moy(start_moy + (i * (1 / timestep) * 60)) for i in xrange(num_moys) )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_datetimes'}; {'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': 'timestep'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '8', 'type': 'block', 'children': ['9', '23', '34', '40']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'start_moy'}; {'id': '12', 'type': 'attribute', 'children': ['13', '22']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'DateTime'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_month'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_day_of_month'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'moy'}; {'id': '23', 'type': 'if_statement', 'children': ['24', '27']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': '=='}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'timestep'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'start_moy'}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '33'], 'value': '+'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'start_moy'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '30'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'num_moys'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '*'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '24'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'timestep'}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '43', 'type': 'generator_expression', 'children': ['44', '60']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'DateTime'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'from_moy'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '51'], 'value': '+'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'start_moy'}; {'id': '51', 'type': '()', 'children': ['52']}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '59'], 'value': '*'}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '55'], 'value': '*'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '55', 'type': '()', 'children': ['56']}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '58'], 'value': '/'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'timestep'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '60'}; {'id': '60', 'type': 'for_in_clause', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'xrange'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'num_moys'}
List of datetimes based on design day date and timestep.
async def addSignalHandlers(self): def sigint(): self.printf('<ctrl-c>') if self.cmdtask is not None: self.cmdtask.cancel() self.loop.add_signal_handler(signal.SIGINT, sigint)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'addSignalHandlers'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '32']}; {'id': '6', 'type': 'function_definition', 'children': ['7', '8', '9']}; {'id': '7', 'type': 'function_name', 'children': [], 'value': 'sigint'}; {'id': '8', 'type': 'parameters', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '17']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'printf'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'<ctrl-c>'"}; {'id': '17', 'type': 'if_statement', 'children': ['18', '23']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '22'], 'value': 'is not'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cmdtask'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'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': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'cmdtask'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'cancel'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '39']}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'add_signal_handler'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'signal'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'SIGINT'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'sigint'}
Register SIGINT signal handler with the ioloop to cancel the currently running cmdloop task.
def set(self, key, value, extend=False, **kwargs): self.__setitem__(key, value, extend, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'set'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '9', 'type': 'False', 'children': []}; {'id': '10', 'type': 'dictionary_splat_pattern', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'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': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '__setitem__'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20', '21', '22']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '22', 'type': 'dictionary_splat', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Extended standard set function.
def remove(self, (s, p, o), context=None): named_graph = _get_named_graph(context) query_sets = _get_query_sets_for_object(o) filter_parameters = dict() if named_graph is not None: filter_parameters['context_id'] = named_graph.id if s: filter_parameters['subject'] = s if p: filter_parameters['predicate'] = p if o: filter_parameters['object'] = o query_sets = [qs.filter(**filter_parameters) for qs in query_sets] for qs in query_sets: qs.delete()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'tuple_pattern', 'children': ['6', '7', '8']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '20', '27', '33', '46', '55', '64', '73', '87']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'named_graph'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_get_named_graph'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'query_sets'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_get_query_sets_for_object'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'filter_parameters'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '32', 'type': 'argument_list', 'children': []}; {'id': '33', 'type': 'if_statement', 'children': ['34', '37']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '36'], 'value': 'is not'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'named_graph'}; {'id': '36', 'type': 'None', 'children': []}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '43']}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'filter_parameters'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'context_id'"}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'named_graph'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '54']}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'filter_parameters'}; {'id': '53', 'type': 'string', 'children': [], 'value': "'subject'"}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '55', 'type': 'if_statement', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '63']}; {'id': '60', 'type': 'subscript', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'filter_parameters'}; {'id': '62', 'type': 'string', 'children': [], 'value': "'predicate'"}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '64', 'type': 'if_statement', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '72']}; {'id': '69', 'type': 'subscript', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'filter_parameters'}; {'id': '71', 'type': 'string', 'children': [], 'value': "'object'"}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'query_sets'}; {'id': '76', 'type': 'list_comprehension', 'children': ['77', '84']}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'qs'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'dictionary_splat', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'filter_parameters'}; {'id': '84', 'type': 'for_in_clause', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'qs'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'query_sets'}; {'id': '87', 'type': 'for_statement', 'children': ['88', '89', '90']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'qs'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'query_sets'}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'qs'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'delete'}; {'id': '96', 'type': 'argument_list', 'children': []}
Removes a triple from the store.
def multiCall(*commands, dependent=True, bundle=False, print_result=False, print_commands=False): results = [] dependent_failed = False for command in commands: if not dependent_failed: response = call(command, print_result=print_result, print_commands=print_commands) if (response.returncode == 1) and dependent: dependent_failed = True else: response = None results.append(response) if bundle: result = Result() for response in results: if not response: continue elif response.returncode == 1: result.returncode = 1 result.extendInformation(response) processed_response = result else: processed_response = results return processed_response
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'multiCall'}; {'id': '3', 'type': 'parameters', 'children': ['4', '6', '9', '12', '15']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'dependent'}; {'id': '8', 'type': 'True', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'bundle'}; {'id': '11', 'type': 'False', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'print_result'}; {'id': '14', 'type': 'False', 'children': []}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'print_commands'}; {'id': '17', 'type': 'False', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19', '23', '27', '75', '123']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '22', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'dependent_failed'}; {'id': '26', 'type': 'False', 'children': []}; {'id': '27', 'type': 'for_statement', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '30', 'type': 'block', 'children': ['31', '68']}; {'id': '31', 'type': 'if_statement', 'children': ['32', '34', '62']}; {'id': '32', 'type': 'not_operator', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'dependent_failed'}; {'id': '34', 'type': 'block', 'children': ['35', '48']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'call'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42', '45']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'print_result'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'print_result'}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'print_commands'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'print_commands'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '57']}; {'id': '49', 'type': 'boolean_operator', 'children': ['50', '56'], 'value': 'and'}; {'id': '50', 'type': '()', 'children': ['51']}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '55'], 'value': '=='}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'returncode'}; {'id': '55', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'dependent'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'dependent_failed'}; {'id': '61', 'type': 'True', 'children': []}; {'id': '62', 'type': 'else_clause', 'children': ['63']}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '67', 'type': 'None', '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': 'results'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '75', 'type': 'if_statement', 'children': ['76', '77', '117']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'bundle'}; {'id': '77', 'type': 'block', 'children': ['78', '84', '113']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '81', 'type': 'call', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'Result'}; {'id': '83', 'type': 'argument_list', 'children': []}; {'id': '84', 'type': 'for_statement', 'children': ['85', '86', '87']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '87', 'type': 'block', 'children': ['88', '106']}; {'id': '88', 'type': 'if_statement', 'children': ['89', '91', '93']}; {'id': '89', 'type': 'not_operator', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'continue_statement', 'children': []}; {'id': '93', 'type': 'elif_clause', 'children': ['94', '99']}; {'id': '94', 'type': 'comparison_operator', 'children': ['95', '98'], 'value': '=='}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'returncode'}; {'id': '98', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'returncode'}; {'id': '105', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'call', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'extendInformation'}; {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'assignment', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'processed_response'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '117', 'type': 'else_clause', 'children': ['118']}; {'id': '118', 'type': 'block', 'children': ['119']}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'assignment', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'processed_response'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '123', 'type': 'return_statement', 'children': ['124']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'processed_response'}
Calls the function 'call' multiple times, given sets of commands
def recordset(method): def wrapper(self, *args, **kwargs): if self.__records__ is None: raise ValidationError( 'There are no records in the set.', ) return method(self, *args, **kwargs) return Api.model(wrapper)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'recordset'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '5', 'type': 'block', 'children': ['6', '36']}; {'id': '6', 'type': 'function_definition', 'children': ['7', '8', '14']}; {'id': '7', 'type': 'function_name', 'children': [], 'value': 'wrapper'}; {'id': '8', 'type': 'parameters', 'children': ['9', '10', '12']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'list_splat_pattern', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '12', 'type': 'dictionary_splat_pattern', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '14', 'type': 'block', 'children': ['15', '27']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '21']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '20'], 'value': 'is'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '__records__'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'raise_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ValidationError'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'There are no records in the set.'"}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32', '34']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'list_splat', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '34', 'type': 'dictionary_splat', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'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': 'Api'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'wrapper'}
Use this to decorate methods that expect a record set.
def add(self, item): if item in self._set: self._fifo.remove(item) elif len(self._set) == self.max_items: self._set.remove(self._fifo.pop(0)) self._fifo.append(item) self._set.add(item)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '6', 'type': 'block', 'children': ['7', '51', '60']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13', '23']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'in'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_set'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'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': '_fifo'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '23', 'type': 'elif_clause', 'children': ['24', '34']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '31'], 'value': '=='}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_set'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'max_items'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_set'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_fifo'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '58']}; {'id': '53', 'type': 'attribute', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_fifo'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '67']}; {'id': '62', 'type': 'attribute', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': '_set'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'item'}
Add an item to the set discarding the oldest item if necessary.
def update_gradients_diag(self, dL_dKdiag, X): self.variance.gradient = np.sum(dL_dKdiag) self.period.gradient = 0 self.lengthscale.gradient = 0
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_gradients_diag'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'dL_dKdiag'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '7', 'type': 'block', 'children': ['8', '21', '29']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'variance'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'gradient'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'dL_dKdiag'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'period'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'gradient'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '36']}; {'id': '31', 'type': 'attribute', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'lengthscale'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'gradient'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '0'}
derivative of the diagonal of the covariance matrix with respect to the parameters.
def delete_node(self, node_id): node = self.get_node(node_id) for e in node['edges']: self.delete_edge_by_id(e) edges = [edge_id for edge_id, edge in list(self.edges.items()) if edge['vertices'][1] == node_id] for e in edges: self.delete_edge_by_id(e) del self.nodes[node_id] self._num_nodes -= 1
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete_node'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'node_id'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '29', '56', '67', '73']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get_node'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'node_id'}; {'id': '16', 'type': 'for_statement', 'children': ['17', '18', '21']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'edges'"}; {'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': 'delete_edge_by_id'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'edges'}; {'id': '32', 'type': 'list_comprehension', 'children': ['33', '34', '48']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'edge_id'}; {'id': '34', 'type': 'for_in_clause', 'children': ['35', '38']}; {'id': '35', 'type': 'pattern_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'edge_id'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'edge'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'edges'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '47', 'type': 'argument_list', 'children': []}; {'id': '48', 'type': 'if_clause', 'children': ['49']}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '55'], 'value': '=='}; {'id': '50', 'type': 'subscript', 'children': ['51', '54']}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'edge'}; {'id': '53', 'type': 'string', 'children': [], 'value': "'vertices'"}; {'id': '54', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'node_id'}; {'id': '56', 'type': 'for_statement', 'children': ['57', '58', '59']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'edges'}; {'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': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'delete_edge_by_id'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '67', 'type': 'delete_statement', 'children': ['68']}; {'id': '68', 'type': 'subscript', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'node_id'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'augmented_assignment', 'children': ['75', '78'], 'value': '-='}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': '_num_nodes'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '1'}
Removes the node identified by node_id from the graph.