def prefix_attr_add(arg, opts, shell_opts):
spec = { '<STR_LIT>': arg }<EOL>v = get_vrf(opts.get('<STR_LIT>'), abort=True)<EOL>spec['<STR_LIT>'] = v.rt<EOL>res = Prefix.list(spec)<EOL>if len(res) == <NUM_LIT:0>:<EOL><INDENT>print("<STR_LIT>" % (arg, vrf_format(v)), file=sys.stderr)<EOL>return<EOL><DEDENT>p = res[<NUM_LIT:0>]<EOL>for avp in opts.get('<STR_LIT>', []):<EOL><INDENT>try:<EOL><INDENT>key, value = avp.split('<STR_LIT:=>', <NUM_LIT:1>)<EOL><DEDENT>except ValueError:<EOL><INDENT>print("<STR_LIT>" % avp, file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>if key in p.avps:<EOL><INDENT>print("<STR_LIT>" % key, file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>p.avps[key] = value<EOL><DEDENT>try:<EOL><INDENT>p.save()<EOL><DEDENT>except NipapError as exc:<EOL><INDENT>print("<STR_LIT>" % str(exc), file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>print("<STR_LIT>" % (p.display_prefix, vrf_format(p.vrf)))<EOL>
Add attributes to a prefix