def convert_tag(self, default_ns, tag, src=Tag.LXML_ETREE, dst=Tag.YTOOL):
def possible_part1():<EOL><INDENT>if src[<NUM_LIT:0>] == Tag.NAME:<EOL><INDENT>return [i[<NUM_LIT:0>] for i in self.namespaces]<EOL><DEDENT>elif src[<NUM_LIT:0>] == Tag.PREFIX:<EOL><INDENT>return [i[<NUM_LIT:1>] for i in self.namespaces] +list(special_prefixes.values())<EOL><DEDENT>else:<EOL><INDENT>return [i[<NUM_LIT:2>] for i in self.namespaces] +list(special_prefixes.keys())<EOL><DEDENT><DEDENT>def split_tag(tag):<EOL><INDENT>ret = re.search(src[<NUM_LIT:2>][<NUM_LIT:0>], tag)<EOL>if ret:<EOL><INDENT>if ret.group(<NUM_LIT:1>) in possible_part1():<EOL><INDENT>return (ret.group(<NUM_LIT:1>), ret.group(<NUM_LIT:2>))<EOL><DEDENT>else:<EOL><INDENT>return ('<STR_LIT>', tag)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return ('<STR_LIT>', tag)<EOL><DEDENT><DEDENT>def format_tag(tag_ns, tag_name):<EOL><INDENT>if tag_ns:<EOL><INDENT>return dst[<NUM_LIT:2>][<NUM_LIT:1>].format(tag_ns, tag_name)<EOL><DEDENT>else:<EOL><INDENT>return tag_name<EOL><DEDENT><DEDENT>def convert(ns):<EOL><INDENT>matches = [i for i in self.namespaces if i[src[<NUM_LIT:0>]] == ns]<EOL>c = len(matches)<EOL>if c > <NUM_LIT:1>:<EOL><INDENT>raise ModelError("<STR_LIT>".format(Tag.STR[src[<NUM_LIT:0>]], ns, matches))<EOL><DEDENT>if c == <NUM_LIT:1>:<EOL><INDENT>return matches[<NUM_LIT:0>][dst[<NUM_LIT:0>]]<EOL><DEDENT>if src[<NUM_LIT:0>] != Tag.NAME and dst[<NUM_LIT:0>] != Tag.NAME:<EOL><INDENT>special = [('<STR_LIT>', v, k) for k, v in special_prefixes.items()]<EOL>matches = [i for i in special if i[src[<NUM_LIT:0>]] == ns]<EOL>if len(matches) == <NUM_LIT:1>:<EOL><INDENT>return matches[<NUM_LIT:0>][dst[<NUM_LIT:0>]]<EOL><DEDENT><DEDENT>raise ValueError("<STR_LIT>""<STR_LIT>".format(Tag.STR[src[<NUM_LIT:0>]], ns, tag))<EOL><DEDENT>tag_ns, tag_name = split_tag(tag)<EOL>if src[<NUM_LIT:1>] == Tag.NO_OMIT and not tag_ns:<EOL><INDENT>raise ValueError("<STR_LIT>""<STR_LIT>".format(tag))<EOL><DEDENT>elif not tag_ns:<EOL><INDENT>tag_ns = default_ns<EOL><DEDENT>if dst[<NUM_LIT:1>] == Tag.NO_OMIT:<EOL><INDENT>return tag_ns, format_tag(convert(tag_ns), tag_name)<EOL><DEDENT>elif dst[<NUM_LIT:1>] == Tag.OMIT_BY_INHERITANCE:<EOL><INDENT>if default_ns == tag_ns:<EOL><INDENT>return default_ns, format_tag('<STR_LIT>', tag_name)<EOL><DEDENT>else:<EOL><INDENT>return tag_ns, format_tag(convert(tag_ns), tag_name)<EOL><DEDENT><DEDENT>elif dst[<NUM_LIT:1>] == Tag.OMIT_BY_MODULE:<EOL><INDENT>if default_ns == tag_ns:<EOL><INDENT>return default_ns, format_tag('<STR_LIT>', tag_name)<EOL><DEDENT>else:<EOL><INDENT>return default_ns, format_tag(convert(tag_ns), tag_name)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>".format(dst[<NUM_LIT:1>]))<EOL><DEDENT>
convert_tag

        High-level api: Convert a tag or an identifier from one notation to
        another. Notations are defined by tuple constants in yang.ncdiff.Tag.

        Parameters
        ----------

        default_ns : `str`
            The default namespace. Usually it's the namespace of parent node. It
            could be a model name, a model prefix, or a model URL, depending on
            your argument 'src'. An empty string is considered as none default
            namespace.

        tag : `str`
            A tag or an identifier of a config node or a schema node.

        src : `tuple`
            The type of notation the input tag is, which is a tuple constant
            defined in yang.ncdiff.Tag. Most commonly it could be Tag.XPATH or
            Tag.LXML_XPATH.

        dst : `tuple`
            The type of notation we want, which is a tuple constant defined in
            yang.ncdiff.Tag. Most commonly it could be Tag.XPATH or
            Tag.LXML_XPATH.

        Returns
        -------

        tuple
            A tuple that has two elements: The first element is the namespace of
            argument 'tag'. It could be a model name, a model prefix, or a model
            URL, depending on your argument 'src'. The second element is the
            converted tag or identifier, which is in notation specified by
            argument 'dst'.


        Code Example::

            >>> device.nc.convert_tag('',
                                      '{http://openconfig.net/yang/interfaces}interface',
                                      dst=Tag.JSON_NAME)
            ('http://openconfig.net/yang/interfaces', 'openconfig-interfaces:interface')
            >>>