def remove_prefix(arg, opts, shell_opts):
<EOL>remove_confirmed = shell_opts.force<EOL>auth_src = set()<EOL>recursive = False<EOL>if opts.get('<STR_LIT>') is True:<EOL><INDENT>recursive = True<EOL><DEDENT>spec = { '<STR_LIT>': arg }<EOL>v = get_vrf(opts.get('<STR_LIT>'), abort=True)<EOL>if v.rt != '<STR_LIT:all>':<EOL><INDENT>spec['<STR_LIT>'] = v.rt<EOL><DEDENT>res = Prefix.list(spec)<EOL>if len(res) < <NUM_LIT:1>:<EOL><INDENT>vrf_text = '<STR_LIT>'<EOL>if v.rt != '<STR_LIT:all>':<EOL><INDENT>vrf_text = vrf_format(v)<EOL><DEDENT>print("<STR_LIT>" % (arg, vrf_text), file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>p = res[<NUM_LIT:0>]<EOL>if p.authoritative_source != '<STR_LIT>':<EOL><INDENT>auth_src.add(p.authoritative_source)<EOL><DEDENT>if recursive is True or p.type == '<STR_LIT>':<EOL><INDENT>query = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': p.prefix<EOL>}<EOL>if '<STR_LIT>' in spec:<EOL><INDENT>vrf_q = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': spec['<STR_LIT>']<EOL>}<EOL>query = {<EOL>'<STR_LIT>': query,<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': vrf_q<EOL>}<EOL><DEDENT>pres = Prefix.search(query, { '<STR_LIT>': <NUM_LIT:0>, '<STR_LIT>': <NUM_LIT> })<EOL><DEDENT>if not remove_confirmed:<EOL><INDENT>if p.type == '<STR_LIT>':<EOL><INDENT>if len(pres['<STR_LIT:result>']) > <NUM_LIT:1>:<EOL><INDENT>print("<STR_LIT>" % (p.prefix, vrf_format(p.vrf), len(pres['<STR_LIT:result>'])))<EOL>res = input("<STR_LIT>" % (p.prefix))<EOL>if res.lower() in [ '<STR_LIT:y>', '<STR_LIT:yes>' ]:<EOL><INDENT>recursive = True<EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT>" % (p.prefix, vrf_format(p.vrf)), file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT><DEDENT>if recursive is True:<EOL><INDENT>if len(pres['<STR_LIT:result>']) <= <NUM_LIT:1>:<EOL><INDENT>res = input("<STR_LIT>" % (p.prefix, vrf_format(p.vrf)))<EOL>if res.lower() in [ '<STR_LIT:y>', '<STR_LIT:yes>' ]:<EOL><INDENT>remove_confirmed = True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>print("<STR_LIT>" % (p.prefix, vrf_format(p.vrf)))<EOL>i = <NUM_LIT:0><EOL>for rp in pres['<STR_LIT:result>']:<EOL><INDENT>if i <= <NUM_LIT:10>:<EOL><INDENT>print("<STR_LIT>" % ("<STR_LIT>".join("<STR_LIT:U+0020>" for i in<EOL>range(rp.indent)) + rp.display_prefix,<EOL>rp.type[<NUM_LIT:0>].upper(), rp.node, rp.order_id,<EOL>rp.customer_id, rp.description))<EOL><DEDENT>if i == <NUM_LIT:10>:<EOL><INDENT>print("<STR_LIT>" % (len(pres['<STR_LIT:result>']) - <NUM_LIT:10>))<EOL><DEDENT>if rp.authoritative_source != '<STR_LIT>':<EOL><INDENT>auth_src.add(rp.authoritative_source)<EOL><DEDENT>i += <NUM_LIT:1><EOL><DEDENT>if len(auth_src) == <NUM_LIT:0>:<EOL><INDENT>res = input("<STR_LIT>" % (len(pres['<STR_LIT:result>']),<EOL>vrf_format(vrf)))<EOL>if res.lower() in [ '<STR_LIT:y>', '<STR_LIT:yes>' ]:<EOL><INDENT>remove_confirmed = True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>auth_src = list(auth_src)<EOL>plural = "<STR_LIT>"<EOL>if len(auth_src) == <NUM_LIT:1>:<EOL><INDENT>systems = "<STR_LIT>" % auth_src[<NUM_LIT:0>]<EOL>prompt = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>systems = "<STR_LIT:U+002CU+0020>".join("<STR_LIT>" % x for x in auth_src[<NUM_LIT:1>:]) + "<STR_LIT>" % auth_src[<NUM_LIT:0>]<EOL>plural = "<STR_LIT:s>"<EOL>prompt = "<STR_LIT>"<EOL><DEDENT>print(("<STR_LIT>" +<EOL>"<STR_LIT>") % (p.prefix,<EOL>vrf_format(p.vrf), plural, systems))<EOL>res = input(prompt)<EOL>if res.lower() == auth_src[<NUM_LIT:0>].lower():<EOL><INDENT>remove_confirmed = True<EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT>", file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if len(auth_src) > <NUM_LIT:0>:<EOL><INDENT>auth_src = list(auth_src)<EOL>print(("<STR_LIT>" +<EOL>"<STR_LIT>") % (p.prefix,<EOL>vrf_format(p.vrf), auth_src[<NUM_LIT:0>]))<EOL>res = input("<STR_LIT>")<EOL>if res.lower() == auth_src[<NUM_LIT:0>].lower():<EOL><INDENT>remove_confirmed = True<EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT>", file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>res = input("<STR_LIT>" % (p.prefix, vrf_format(p.vrf)))<EOL>if res.lower() in [ '<STR_LIT:y>', '<STR_LIT:yes>' ]:<EOL><INDENT>remove_confirmed = True<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if remove_confirmed is True:<EOL><INDENT>p.remove(recursive = recursive)<EOL>if recursive is True:<EOL><INDENT>print("<STR_LIT>" % (p.prefix,<EOL>(len(pres['<STR_LIT:result>']) - <NUM_LIT:1>), vrf_format(p.vrf)))<EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT>" % (p.prefix, vrf_format(p.vrf)))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>
Remove prefix