Return the keys of the dict at the given path. Args: text: Python representation of the path to the dict (e.g. data["key1"][0]["key2"]).
(self, text: str)
| 40 | return cls(dict_=dict_) |
| 41 | |
| 42 | def keys(self, text: str) -> str: |
| 43 | """Return the keys of the dict at the given path. |
| 44 | |
| 45 | Args: |
| 46 | text: Python representation of the path to the dict (e.g. data["key1"][0]["key2"]). |
| 47 | """ |
| 48 | try: |
| 49 | items = _parse_input(text) |
| 50 | val = self.dict_ |
| 51 | for i in items: |
| 52 | if i: |
| 53 | val = val[i] |
| 54 | if not isinstance(val, dict): |
| 55 | raise ValueError( |
| 56 | f"Value at path `{text}` is not a dict, get the value directly." |
| 57 | ) |
| 58 | return str(list(val.keys())) |
| 59 | except Exception as e: |
| 60 | return repr(e) |
| 61 | |
| 62 | def value(self, text: str) -> str: |
| 63 | """Return the value of the dict at the given path. |
no test coverage detected