def list_prefix(arg, opts, shell_opts):
search_string = '<STR_LIT>'<EOL>if type(arg) == list or type(arg) == tuple:<EOL><INDENT>search_string = '<STR_LIT:U+0020>'.join(arg)<EOL><DEDENT>v = get_vrf(opts.get('<STR_LIT>'), default_var='<STR_LIT>', abort=True)<EOL>if v.rt == '<STR_LIT:all>':<EOL><INDENT>vrf_text = '<STR_LIT>'<EOL>vrf_q = None<EOL><DEDENT>else:<EOL><INDENT>vrf_text = vrf_format(v)<EOL>vrf_q = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': v.rt<EOL>}<EOL><DEDENT>print("<STR_LIT>" % vrf_text)<EOL>col_def = {<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT:description>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT:status>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT:#>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT:type>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>'<STR_LIT>': { '<STR_LIT:title>': '<STR_LIT>' },<EOL>}<EOL>columns = [ '<STR_LIT>', '<STR_LIT>', '<STR_LIT:type>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:description>' ]<EOL>custom_columns = None<EOL>if shell_opts.columns and len(shell_opts.columns) > <NUM_LIT:0>:<EOL><INDENT>custom_columns = shell_opts.columns<EOL><DEDENT>elif cfg.get('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>custom_columns = cfg.get('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>if custom_columns:<EOL><INDENT>if custom_columns[<NUM_LIT:0>] != '<STR_LIT:+>':<EOL><INDENT>columns = []<EOL><DEDENT>for col in list(csv.reader([custom_columns.lstrip('<STR_LIT:+>') or '<STR_LIT>'], escapechar='<STR_LIT:\\>'))[<NUM_LIT:0>]:<EOL><INDENT>col = col.strip()<EOL>if col not in col_def:<EOL><INDENT>print("<STR_LIT>", col, file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>columns.append(col)<EOL><DEDENT><DEDENT>offset = <NUM_LIT:0><EOL>limit = <NUM_LIT:50><EOL>prefix_str = "<STR_LIT>"<EOL>while True:<EOL><INDENT>res = Prefix.smart_search(search_string, { '<STR_LIT>': -<NUM_LIT:1>,<EOL>'<STR_LIT>': True, '<STR_LIT>': offset, '<STR_LIT>': limit },<EOL>vrf_q)<EOL>if offset == <NUM_LIT:0>: <EOL><INDENT>if shell_opts.show_interpretation:<EOL><INDENT>print("<STR_LIT>")<EOL>_parse_interp_prefix(res['<STR_LIT>'])<EOL><DEDENT>if res['<STR_LIT:error>']:<EOL><INDENT>print("<STR_LIT>" % res['<STR_LIT>'])<EOL>return<EOL><DEDENT>if len(res['<STR_LIT:result>']) == <NUM_LIT:0>:<EOL><INDENT>print("<STR_LIT>" % search_string)<EOL>return<EOL><DEDENT>for p in res['<STR_LIT:result>']:<EOL><INDENT>for colname, col in col_def.items():<EOL><INDENT>val = getattr(p, colname, '<STR_LIT>')<EOL>col['<STR_LIT:width>'] = max(len(colname), col.get('<STR_LIT:width>', <NUM_LIT:0>),<EOL>len(str(val)))<EOL><DEDENT>col_def['<STR_LIT>']['<STR_LIT:width>'] = max(col_def['<STR_LIT>'].get('<STR_LIT:width>', <NUM_LIT:8>),<EOL>len(str(p.vrf.rt)))<EOL>col_def['<STR_LIT>']['<STR_LIT:width>'] = max(col_def['<STR_LIT>'].get('<STR_LIT:width>', <NUM_LIT:0>)-<NUM_LIT:12>,<EOL>p.indent * <NUM_LIT:2> + len(p.prefix)) + <NUM_LIT:12><EOL>try:<EOL><INDENT>col_def['<STR_LIT>']['<STR_LIT:width>'] = max(col_def['<STR_LIT>'].get('<STR_LIT:width>', <NUM_LIT:8>),<EOL>len(str(p.pool.name)))<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>col_def['<STR_LIT:type>']['<STR_LIT:width>'] = <NUM_LIT:1><EOL>col_def['<STR_LIT>']['<STR_LIT:width>'] = <NUM_LIT:2><EOL>col_header_data = {}<EOL>for colname, col in [(k, col_def[k]) for k in columns]:<EOL><INDENT>prefix_str += "<STR_LIT>" % (colname, col['<STR_LIT:width>'])<EOL>col_header_data[colname] = col['<STR_LIT:title>']<EOL><DEDENT>column_header = prefix_str.format(**col_header_data)<EOL>print(column_header)<EOL>print("<STR_LIT>".join("<STR_LIT:=>" for i in range(len(column_header))))<EOL><DEDENT>for p in res['<STR_LIT:result>']:<EOL><INDENT>if p.display == False:<EOL><INDENT>continue<EOL><DEDENT>col_data = {}<EOL>try:<EOL><INDENT>for colname, col in col_def.items():<EOL><INDENT>col_data[colname] = str(getattr(p, colname, None))<EOL><DEDENT>col_data['<STR_LIT>'] = '<STR_LIT:->'<EOL>if len(p.tags) > <NUM_LIT:0>:<EOL><INDENT>col_data['<STR_LIT>'] = '<STR_LIT>' % len(p.tags)<EOL><DEDENT>try: <EOL><INDENT>col_data['<STR_LIT>'] = p.pool.name<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>col_data['<STR_LIT>'] = "<STR_LIT>".join("<STR_LIT:U+0020>" for i in range(p.indent)) + p.display_prefix<EOL>col_data['<STR_LIT:type>'] = p.type[<NUM_LIT:0>].upper()<EOL>col_data['<STR_LIT>'] = p.vrf.rt or '<STR_LIT:->'<EOL>print(prefix_str.format(**col_data))<EOL><DEDENT>except UnicodeEncodeError as e:<EOL><INDENT>print("<STR_LIT>" % p.prefix, file=sys.stderr)<EOL><DEDENT><DEDENT>if len(res['<STR_LIT:result>']) < limit:<EOL><INDENT>break<EOL><DEDENT>offset += limit<EOL>limit = <NUM_LIT:200><EOL><DEDENT>
List prefixes matching 'arg'