python-benedict/benedict/core/keylists.py

18 lines
346 B
Python
Raw Normal View History

2020-02-04 09:33:20 +00:00
# -*- coding: utf-8 -*-
from benedict.utils import type_util
def _get_keylist(item, parent_keys):
l = []
for key, value in item.items():
keys = parent_keys + [key]
l += [keys]
if type_util.is_dict(value):
l += _get_keylist(value, keys)
return l
def keylists(d):
return _get_keylist(d, [])