|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
|
|
3
|
|
|
from benedict.dicts.io import IODict |
|
4
|
|
|
from benedict.dicts.keypath import KeypathDict |
|
5
|
|
|
from benedict.dicts.parse import ParseDict |
|
6
|
|
|
from benedict.utils import dict_util |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
class benedict(IODict, KeypathDict, ParseDict): |
|
10
|
|
|
|
|
11
|
|
|
def __init__(self, *args, **kwargs): |
|
12
|
|
|
super(benedict, self).__init__(*args, **kwargs) |
|
13
|
|
|
|
|
14
|
|
|
def clean(self, strings=True, dicts=True, lists=True): |
|
15
|
|
|
dict_util.clean(self, strings=strings, dicts=dicts, lists=lists) |
|
16
|
|
|
|
|
17
|
|
|
def clone(self): |
|
18
|
|
|
return dict_util.clone(self) |
|
19
|
|
|
|
|
20
|
|
|
def copy(self): |
|
21
|
|
|
return benedict(super(benedict, self).copy()) |
|
22
|
|
|
|
|
23
|
|
|
def deepcopy(self): |
|
24
|
|
|
return self.clone() |
|
25
|
|
|
|
|
26
|
|
|
def deepupdate(self, other, *args): |
|
27
|
|
|
self.merge(other, *args) |
|
28
|
|
|
|
|
29
|
|
|
def dump(self, data=None): |
|
30
|
|
|
return dict_util.dump(data or self) |
|
31
|
|
|
|
|
32
|
|
|
def filter(self, predicate): |
|
33
|
|
|
return dict_util.filter(self, predicate) |
|
34
|
|
|
|
|
35
|
|
|
def flatten(self, separator='_'): |
|
36
|
|
|
return dict_util.flatten(self, separator) |
|
37
|
|
|
|
|
38
|
|
|
def invert(self, flat=False): |
|
39
|
|
|
return dict_util.invert(self, flat) |
|
40
|
|
|
|
|
41
|
|
|
def items_sorted_by_keys(self, reverse=False): |
|
42
|
|
|
return dict_util.items_sorted_by_keys(self, reverse=reverse) |
|
43
|
|
|
|
|
44
|
|
|
def items_sorted_by_values(self, reverse=False): |
|
45
|
|
|
return dict_util.items_sorted_by_values(self, reverse=reverse) |
|
46
|
|
|
|
|
47
|
|
|
def keypaths(self): |
|
48
|
|
|
sep = self._keypath_separator or '.' |
|
49
|
|
|
return dict_util.keypaths(self, separator=sep) |
|
50
|
|
|
|
|
51
|
|
|
def merge(self, other, *args): |
|
52
|
|
|
dict_util.merge(self, other, *args) |
|
53
|
|
|
|
|
54
|
|
|
def move(self, key_src, key_dest): |
|
55
|
|
|
dict_util.move(self, key_src, key_dest) |
|
56
|
|
|
|
|
57
|
|
|
def remove(self, keys, *args): |
|
58
|
|
|
dict_util.remove(self, keys, *args) |
|
59
|
|
|
|
|
60
|
|
|
def standardize(self): |
|
61
|
|
|
dict_util.standardize(self) |
|
62
|
|
|
|
|
63
|
|
|
def subset(self, keys, *args): |
|
64
|
|
|
return dict_util.subset(self, keys, *args) |
|
65
|
|
|
|
|
66
|
|
|
def swap(self, key1, key2): |
|
67
|
|
|
dict_util.swap(self, key1, key2) |
|
68
|
|
|
|
|
69
|
|
|
def traverse(self, callback): |
|
70
|
|
|
dict_util.traverse(self, callback) |
|
71
|
|
|
|
|
72
|
|
|
def unique(self): |
|
73
|
|
|
dict_util.unique(self) |
|
74
|
|
|
|