15 lines
452 B
Python
15 lines
452 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
from benedict.core.keylists import keylists
|
|
from benedict.utils import type_util
|
|
|
|
|
|
def keypaths(d, separator='.', indexes=False):
|
|
separator = separator or '.'
|
|
if not type_util.is_string(separator):
|
|
raise ValueError('separator argument must be a (non-empty) string.')
|
|
kls = keylists(d, indexes=indexes)
|
|
kps = [separator.join(['{}'.format(key) for key in kl]) for kl in kls]
|
|
kps.sort()
|
|
return kps
|