Modify the prefix 'arg' with the options 'opts'

def modify_prefix(arg, opts, shell_opts):
    """ Modify the prefix 'arg' with the options 'opts'
    """

    modify_confirmed = shell_opts.force

    spec = { 'prefix': arg }
    v = get_vrf(opts.get('vrf_rt'), abort=True)
    spec['vrf_rt'] = v.rt

    res = Prefix.list(spec)
    if len(res) == 0:
        print("Prefix %s not found in %s." % (arg, vrf_format(v)), file=sys.stderr)
        return

    p = res[0]

    if 'prefix' in opts:
        p.prefix = opts['prefix']
    if 'description' in opts:
        p.description = opts['description']
    if 'comment' in opts:
        p.comment = opts['comment']
    if 'tags' in opts:
        tags = list(csv.reader([opts.get('tags', '')], escapechar='\\'))[0]
        p.tags = {}
        for tag_name in tags:
            tag = Tag()
            tag.name = tag_name
            p.tags[tag_name] = tag
    if 'node' in opts:
        p.node = opts['node']
    if 'type' in opts:
        p.type = opts['type']
    if 'status' in opts:
        p.status = opts['status']
    if 'country' in opts:
        p.country = opts['country']
    if 'order_id' in opts:
        p.order_id = opts['order_id']
    if 'customer_id' in opts:
        p.customer_id = opts['customer_id']
    if 'vlan' in opts:
        p.vlan = opts['vlan']
    if 'alarm_priority' in opts:
        p.alarm_priority = opts['alarm_priority']
    if 'monitor' in opts:
        p.monitor = _str_to_bool(opts['monitor'])
    if 'expires' in opts:
        p.expires = opts['expires']

    for avp in opts.get('extra-attribute', []):
        try:
            key, value = avp.split('=', 1)
        except ValueError:
            print("ERROR: Incorrect extra-attribute: %s. Accepted form: 'key=value'\n" % avp, file=sys.stderr)
            return
        p.avps[key] = value


    # Promt user if prefix has authoritative source != nipap
    if not modify_confirmed and p.authoritative_source.lower() != 'nipap':

        res = input("Prefix %s in %s is managed by system '%s'. Are you sure you want to modify it? [y/n]: " %
            (p.prefix, vrf_format(p.vrf), p.authoritative_source))

        # If the user declines, short-circuit...
        if res.lower() not in [ 'y', 'yes' ]:
            print("Operation aborted.")
            return

    try:
        p.save()
    except NipapError as exc:
        print("Could not save prefix changes: %s" % str(exc), file=sys.stderr)
        sys.exit(1)

    print("Prefix %s in %s saved." % (p.display_prefix, vrf_format(p.vrf)))