napalm_yang/parsers/base.py
def _flatten_dictionary(obj, path, key_name):
    """
    This method tries to use the path `?my_field` to convert:

    a:
        aa: 1
        ab: 2
    b:
        ba: 3
        ba: 4

    into:

    - my_field: a
      aa: 1
      ab: 2
    - my_field: b
      ba: 3
      ba: 4
    """
    result = []
    if ">" in key_name:
        key_name, group_key = key_name.split(">")
    else:
        group_key = None

    for k, v in obj.items():
        if path:
            if k == path[0]:
                path.pop(0)
        if k.startswith("#"):
            continue
        r = _resolve_path(v, list(path))

        if isinstance(r, dict):
            # You can either have a dict here, which means your path is like ?a.b
            # or a list, which means you have a path like ?a.?b
            r = [r]

        for e in r:
            if group_key:
                e[group_key] = {kk: vv for kk, vv in v.items() if kk not in path}
            e[key_name] = k
            result.append(e)
    return result
def _flatten_dictionary(obj, path, key_name):
    """
    This method tries to use the path `?my_field` to convert:

    a:
        aa: 1
        ab: 2
    b:
        ba: 3
        ba: 4

    into:

    - my_field: a
      aa: 1
      ab: 2
    - my_field: b
      ba: 3
      ba: 4
    """
    result = []
    if ">" in key_name:
        key_name, group_key = key_name.split(">")
    else:
        group_key = None

    for k, v in obj.items():
        if path:
            if k == path[0]:
                path.pop(0)
        if k.startswith("#"):
            continue
        r = _resolve_path(v, list(path))

        if isinstance(r, dict):
            # You can either have a dict here, which means your path is like ?a.b
            # or a list, which means you have a path like ?a.?b
            r = [r]

        for e in r:
            if group_key:
                e[group_key] = {kk: vv for kk, vv in v.items() if kk not in path}
            e[key_name] = k
            result.append(e)
    return result
This method tries to use the path `?my_field` to convert:

    a:
        aa: 1
        ab: 2
    b:
        ba: 3
        ba: 4

    into:

    - my_field: a
      aa: 1
      ab: 2
    - my_field: b
      ba: 3
      ba: 4