| 53 | |
| 54 | |
| 55 | class Path: |
| 56 | def __init__( |
| 57 | self, |
| 58 | kind: PathAction, |
| 59 | accessor: Optional[Union[str, int]] = None, |
| 60 | tokens: Optional[List[Token]] = None, |
| 61 | is_root: bool = False, |
| 62 | ): |
| 63 | self.kind = kind |
| 64 | self.accessor = accessor |
| 65 | self.tokens = tokens or [] |
| 66 | self.is_root = is_root |
| 67 | |
| 68 | def reconstruct(self) -> str: |
| 69 | if self.kind is PathAction.KEY: |
| 70 | if self.is_root: |
| 71 | return str(self.accessor) |
| 72 | return OPEN_BRACKET + self.accessor + CLOSE_BRACKET |
| 73 | elif self.kind is PathAction.INDEX: |
| 74 | return OPEN_BRACKET + str(self.accessor) + CLOSE_BRACKET |
| 75 | elif self.kind is PathAction.APPEND: |
| 76 | return OPEN_BRACKET + CLOSE_BRACKET |
| 77 | |
| 78 | |
| 79 | class NestedJSONArray(list): |
no outgoing calls