'Format DHCP option by option name or code.'

def _format_option(self, ip_version, tag, option, *args):

    option = str(option)
    pattern = '(tag:(.*),)?(.*)$'
    matches = re.match(pattern, option)
    extra_tag = matches.groups()[0]
    option = matches.groups()[2]
    if isinstance(tag, int):
        tag = (self._TAG_PREFIX % tag)
    if (not option.isdigit()):
        if (ip_version == 4):
            option = ('option:%s' % option)
        else:
            option = ('option6:%s' % option)
    if extra_tag:
        tags = (('tag:' + tag), extra_tag[:(-1)], ('%s' % option))
    else:
        tags = (('tag:' + tag), ('%s' % option))
    return ','.join((tags + args))
