benedict.core.keypaths.keypaths()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 8
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nop 3
1
from benedict.core.keylists import keylists
2
from benedict.utils import type_util
3
4
5
def keypaths(d, separator=".", indexes=False):
6
    separator = separator or "."
7
    if not type_util.is_string(separator):
8
        raise ValueError("separator argument must be a (non-empty) string.")
9
    kls = keylists(d, indexes=indexes)
10
    kps = [separator.join([f"{key}" for key in kl]) for kl in kls]
11
    kps.sort()
12
    return kps
13