def harvest_subscript_dicts(ast_list): """ Needs Tests! """ subscript_lists = [] if isinstance(ast_list, list): found,data = match(indexed_array_pattern,ast_list) # data is a dict with 'var' = variable name # and 'subscript_list' = to the ast_seq for the subscript list if found: subscript_lists.append(data) for item in ast_list: if isinstance(item, list): subscript_lists.extend(harvest_subscript_dicts(item)) return subscript_lists
def harvest_subscript_dicts(ast_list): """ Needs Tests! """ subscript_lists = [] if isinstance(ast_list, list): found, data = match(indexed_array_pattern, ast_list) # data is a dict with 'var' = variable name # and 'subscript_list' = to the ast_seq for the subscript list if found: subscript_lists.append(data) for item in ast_list: if isinstance(item, list): subscript_lists.extend(harvest_subscript_dicts(item)) return subscript_lists
def slice_ast_to_dict(ast_seq): sl_vars = {} if isinstance(ast_seq, (list, tuple)): for pattern in slice_patterns: found,data = match(pattern,ast_seq) if found: sl_vars = {'begin':'_beg', 'end':'_end', 'step':'_stp', 'single_index':'_index'} for key in data.keys(): data[key] = ast_to_string(data[key]) sl_vars.update(data) break; return sl_vars
def slice_ast_to_dict(ast_seq): sl_vars = {} if isinstance(ast_seq, (list, tuple)): for pattern in slice_patterns: found, data = match(pattern, ast_seq) if found: sl_vars = { 'begin': '_beg', 'end': '_end', 'step': '_stp', 'single_index': '_index' } for key in data.keys(): data[key] = ast_to_string(data[key]) sl_vars.update(data) break return sl_vars