| Total Complexity | 23 |
| Total Lines | 76 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # -*- coding: utf-8 -*- |
||
| 2 | |||
| 3 | from benedict.utils import type_util |
||
| 4 | |||
| 5 | |||
| 6 | class BaseDict(dict): |
||
| 7 | |||
| 8 | _dict = {} |
||
| 9 | |||
| 10 | def __init__(self, *args, **kwargs): |
||
| 11 | super(BaseDict, self).__init__() |
||
| 12 | if len(args) == 1 and type_util.is_dict(args[0]): |
||
| 13 | self._dict = args[0] |
||
| 14 | else: |
||
| 15 | self._dict = dict(*args, **kwargs) |
||
| 16 | |||
| 17 | def __bool__(self): |
||
| 18 | return bool(self._dict) |
||
| 19 | |||
| 20 | def __contains__(self, key): |
||
| 21 | return key in self._dict |
||
| 22 | |||
| 23 | def __delitem__(self, key): |
||
| 24 | del self._dict[key] |
||
| 25 | |||
| 26 | def __eq__(self, other): |
||
| 27 | return self._dict == other |
||
| 28 | |||
| 29 | def __getitem__(self, key): |
||
| 30 | return self._dict[key] |
||
| 31 | |||
| 32 | def __iter__(self): |
||
| 33 | return iter(self._dict) |
||
| 34 | |||
| 35 | def __len__(self): |
||
| 36 | return len(self._dict) |
||
| 37 | |||
| 38 | def __repr__(self): |
||
| 39 | return repr(self._dict) |
||
| 40 | |||
| 41 | def __setitem__(self, key, value): |
||
| 42 | self._dict[key] = value |
||
| 43 | |||
| 44 | def __str__(self): |
||
| 45 | return str(self._dict) |
||
| 46 | |||
| 47 | def clear(self): |
||
| 48 | self._dict.clear() |
||
| 49 | |||
| 50 | def copy(self): |
||
| 51 | return self._dict.copy() |
||
| 52 | |||
| 53 | def dict(self): |
||
| 54 | return self._dict |
||
| 55 | |||
| 56 | def get(self, key, default=None): |
||
| 57 | return self._dict.get(key, default) |
||
| 58 | |||
| 59 | def items(self): |
||
| 60 | return self._dict.items() |
||
| 61 | |||
| 62 | def keys(self): |
||
| 63 | return self._dict.keys() |
||
| 64 | |||
| 65 | def pop(self, key, *args): |
||
| 66 | return self._dict.pop(key, *args) |
||
| 67 | |||
| 68 | def setdefault(self, key, default=None): |
||
| 69 | return self._dict.setdefault(key, default) |
||
| 70 | |||
| 71 | def update(self, other): |
||
| 72 | self._dict.update(other) |
||
| 73 | |||
| 74 | def values(self): |
||
| 75 | return self._dict.values() |
||
| 76 |