Пример #1
0
    def match(self, root_value: object,
              current_value: object) -> Generator[MatchData, None, None]:
        """Match the root value against the current value."""
        if isinstance(current_value,
                      Sequence) and not isinstance(current_value, str):
            if self.index < 0:
                new_index = self.index + len(current_value)

                if 0 <= new_index < len(current_value):
                    return [
                        MatchData(
                            SubscriptNode(TerminalNode(), [self]),
                            root_value,
                            current_value[new_index],
                        )
                    ]
            elif self.index < len(current_value):
                return [
                    MatchData(
                        SubscriptNode(TerminalNode(), [self]),
                        root_value,
                        current_value[self.index],
                    )
                ]
        return []
Пример #2
0
    def __call__(self, root_value: object, current_value: object) -> Generator[MatchData, None, None]:
        """Perform entries() call."""
        if isinstance(current_value, Mapping):
            if not self.args:
                value = list(map(list, current_value.items()))

                yield MatchData(SubscriptNode(TerminalNode(), [self]),
                                root_value, value)
        elif isinstance(current_value, Sequence) and not isinstance(current_value, str):
            if not self.args:
                value = list(map(list, enumerate(current_value)))

                yield MatchData(SubscriptNode(TerminalNode(), [self]),
                                root_value, value)
Пример #3
0
    def __call__(self, root_value: object, current_value: object) -> Generator[MatchData, None, None]:
        """Perform length() call."""
        if isinstance(current_value, Sequence) and not isinstance(current_value, str):
            if not self.args:
                value = len(current_value)

                yield MatchData(SubscriptNode(TerminalNode(), [self]),
                                root_value, value)
        elif isinstance(current_value, str):
            if not self.args:
                value = len(current_value)

                yield MatchData(SubscriptNode(TerminalNode(), [self]),
                                root_value, value)
Пример #4
0
 def match(self, root_value: object,
           current_value: object) -> Generator[MatchData, None, None]:
     """Match root value and current value for subscripts."""
     for subscript in self.subscripts:
         for subscript_match_data in subscript.match(
                 root_value, current_value):
             for next_node_match_data in self.next_node.match(
                     subscript_match_data.root_value,
                     subscript_match_data.current_value):
                 if isinstance(subscript_match_data.node, TerminalNode):
                     yield next_node_match_data
                 elif isinstance(subscript_match_data.node, SubscriptNode):
                     if isinstance(subscript_match_data.node.next_node,
                                   TerminalNode):
                         yield MatchData(
                             SubscriptNode(
                                 next_node_match_data.node,
                                 subscript_match_data.node.subscripts,
                             ),
                             next_node_match_data.root_value,
                             next_node_match_data.current_value,
                         )
                     else:
                         raise ValueError()
                 else:
                     raise ValueError()
Пример #5
0
    def __call__(self, root_value: object, current_value: object) -> Generator[MatchData, None, None]:
        """Perform substring(number[, number]) call."""
        if isinstance(current_value, str):
            if (len(self.args) == 1) \
                    and isinstance(self.args[0].current_value, int):
                value = current_value[self.args[0].current_value:]

                yield MatchData(SubscriptNode(TerminalNode(), [self]),
                                root_value, value)
            elif (len(self.args) == 2) \
                    and isinstance(self.args[0].current_value, int) \
                    and isinstance(self.args[1].current_value, int):
                value = current_value[self.args[0].current_value:self.args[1].current_value]

                yield MatchData(SubscriptNode(TerminalNode(), [self]),
                                root_value, value)
Пример #6
0
 def match(self, root_value: object,
           current_value: object) -> Generator[MatchData, None, None]:
     """Match the current value and root value."""
     return map(
         lambda next_node_match_data: MatchData(
             CurrentNode(next_node_match_data.node), next_node_match_data.
             root_value, next_node_match_data.current_value),
         self.next_node.match(root_value, current_value))
Пример #7
0
 def match(self, root_value: object,
           current_value: object) -> Generator[MatchData, None, None]:
     """Match the current value against the root value."""
     if isinstance(current_value, dict) and (self.index in current_value):
         return [
             MatchData(SubscriptNode(TerminalNode(), [self]), root_value,
                       current_value[self.index])
         ]
     return []
Пример #8
0
 def match(self, root_value: object,
           current_value: object) -> Generator[MatchData, None, None]:
     """Match the root value against the current value."""
     for args in itertools.product(*map(
             lambda arg: [arg] if isinstance(arg, MatchData) else arg.match(
                 root_value, current_value) if isinstance(arg, Node) else
         [MatchData(TerminalNode(), root_value, arg)],
             self.args,
     )):  # noqa: E501
         for callable_subscript_match_data in self.__class__(*args)(
                 root_value, current_value):
             yield callable_subscript_match_data
Пример #9
0
 def __call__(self, root_value: object, current_value: object) -> Generator[MatchData, None, None]:
     """Perform charAt(number) call."""
     if isinstance(current_value, str):
         if (len(self.args) == 1) \
                 and isinstance(self.args[0].current_value, int):
             try:
                 value = current_value[self.args[0].current_value]
             except IndexError:
                 pass
             else:
                 yield MatchData(SubscriptNode(TerminalNode(), [self]),
                                 root_value, value)
Пример #10
0
 def match(self, root_value: object,
           current_value: object) -> Generator[MatchData, None, None]:
     """Match the filter subscript against the current value."""
     if self.expression.evaluate(root_value, current_value):
         return [MatchData(TerminalNode(), root_value, current_value)]
     return []
Пример #11
0
 def match(self, root_value: object,
           current_value: object) -> Generator[MatchData, None, None]:
     """Match a termainal node."""
     return [MatchData(self, root_value, current_value)]
Пример #12
0
 def match(self, root_value, current_value):
     """One."""
     yield MatchData(SubscriptNode(None), root_value, current_value)
Пример #13
0
 def match(self, root_value, current_value):
     """One."""
     yield MatchData(None, root_value, current_value)
Пример #14
0
    def setUp(self):
        """Setup the class."""
        root_value = {
            'hello': 'Hello, world!',
            'languages': [
                'en-GB',
                'en-US',
            ],
        }
        current_value = root_value['hello']

        self._state = [
            {
                '__jsonpath__':
                '',
                'node':
                TerminalNode(),
                'root_value':
                root_value,
                'current_value':
                current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__':
                '$',
                'node':
                RootNode(TerminalNode()),
                'root_value':
                root_value,
                'current_value':
                current_value,
                'match_data_list': [
                    MatchData(RootNode(TerminalNode()), root_value,
                              root_value),
                ],
            },
            {
                '__jsonpath__':
                '@',
                'node':
                CurrentNode(TerminalNode()),
                'root_value':
                root_value,
                'current_value':
                current_value,
                'match_data_list': [
                    MatchData(CurrentNode(TerminalNode()), root_value,
                              current_value),
                ],
            },
            {
                '__jsonpath__': '[]',
                'node': SubscriptNode(TerminalNode(), []),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [],
            },
            {
                '__jsonpath__':
                '[?(@)]',
                'node':
                SubscriptNode(TerminalNode(), [
                    FilterSubscript(SomeExpression(CurrentNode(
                        TerminalNode())))
                ]),
                'root_value':
                root_value,
                'current_value':
                current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__':
                '[?(@),?(@)]',
                'node':
                SubscriptNode(TerminalNode(), [
                    FilterSubscript(SomeExpression(CurrentNode(
                        TerminalNode()))),
                    FilterSubscript(SomeExpression(CurrentNode(
                        TerminalNode())))
                ]),
                'root_value':
                root_value,
                'current_value':
                current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__': '[*]',
                'node': SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [],
            },
            {
                '__jsonpath__':
                '[*]',
                'node':
                SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('hello')]),
                        root_value, root_value['hello']),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('languages')]),
                        root_value, root_value['languages']),
                ],
            },
            {
                '__jsonpath__':
                '["languages"][*]',
                'node':
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                    [ObjectIndexSubscript('languages')]),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][0]),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][1]),
                ],
            },
            {
                '__jsonpath__':
                '["hello","languages"]',
                'node':
                SubscriptNode(TerminalNode(), [
                    ObjectIndexSubscript('hello'),
                    ObjectIndexSubscript('languages')
                ]),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('hello')]),
                        root_value, root_value['hello']),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('languages')]),
                        root_value, root_value['languages']),
                ],
            },
            {
                '__jsonpath__':
                '..',
                'node':
                RecursiveDescentNode(TerminalNode()),
                'root_value':
                root_value,
                'current_value':
                current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__':
                '..',
                'node':
                RecursiveDescentNode(TerminalNode()),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, root_value),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('hello')]),
                        root_value, root_value['hello']),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('languages')]),
                        root_value, root_value['languages']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][0]),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][1]),
                ],
            },
            {
                '__jsonpath__':
                '..[?(@)]',
                'node':
                RecursiveDescentNode(
                    SubscriptNode(TerminalNode(), [
                        FilterSubscript(
                            SomeExpression(CurrentNode(TerminalNode())))
                    ])),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, root_value),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('hello')]),
                        root_value, root_value['hello']),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('languages')]),
                        root_value, root_value['languages']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][0]),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][1]),
                ],
            },
            {
                '__jsonpath__':
                '..[*]',
                'node':
                RecursiveDescentNode(
                    SubscriptNode(TerminalNode(), [WildcardSubscript()])),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('hello')]),
                        root_value, root_value['hello']),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('languages')]),
                        root_value, root_value['languages']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][0]),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][1]),
                ],
            },
            {
                '__jsonpath__':
                '..["hello"]',
                'node':
                RecursiveDescentNode(
                    SubscriptNode(TerminalNode(),
                                  [ObjectIndexSubscript('hello')])),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('hello')]),
                        root_value, root_value['hello']),
                ],
            },
            {
                '__jsonpath__':
                '..[0]',
                'node':
                RecursiveDescentNode(
                    SubscriptNode(TerminalNode(), [ArrayIndexSubscript(0)])),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][0]),
                ],
            },
        ]
Пример #15
0
    def setUp(self):
        """Setup the class."""
        root_value = {
            'hello': 'Hello, world!',
            'languages': [
                'en-GB',
                'en-US',
            ],
            'preferences': {
                'coffee': True,
                'tea': False,
            },
        }
        current_value = root_value['hello']

        self._state = [
            {
                '__jsonpath__': '',
                'node': TerminalNode(),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__': '$',
                'node': RootNode(TerminalNode()),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [
                    MatchData(RootNode(TerminalNode()),
                              root_value, root_value),
                ],
            },
            {
                '__jsonpath__': '@',
                'node': CurrentNode(TerminalNode()),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [
                    MatchData(CurrentNode(TerminalNode()),
                              root_value, current_value),
                ],
            },
            {
                '__jsonpath__': '[]',
                'node': SubscriptNode(TerminalNode(), []),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [],
            },
            {
                '__jsonpath__': '[?(@)]',
                'node': SubscriptNode(TerminalNode(), [FilterSubscript(SomeExpression(CurrentNode(TerminalNode())))]),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__': '[?(@),?(@)]',
                'node': SubscriptNode(
                    TerminalNode(),
                    [
                        FilterSubscript(SomeExpression(
                            CurrentNode(TerminalNode()))),
                        FilterSubscript(SomeExpression(
                            CurrentNode(TerminalNode())))
                    ]
                ),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__': '[*]',
                'node': SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [],
            },
            {
                '__jsonpath__': '[*]',
                'node': SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'hello')]), root_value, root_value['hello']),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'languages')]), root_value, root_value['languages']),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'preferences')]), root_value, root_value['preferences']),
                ],
            },
            {
                '__jsonpath__': '["languages"][*]',
                'node': SubscriptNode(
                    SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                    [ObjectIndexSubscript('languages')]
                ),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(0)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][0]
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][1]
                    ),
                ],
            },
            {
                '__jsonpath__': '["hello","languages"]',
                'node': SubscriptNode(
                    TerminalNode(),
                    [ObjectIndexSubscript('hello'),
                     ObjectIndexSubscript('languages')]
                ),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'hello')]), root_value, root_value['hello']),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'languages')]), root_value, root_value['languages']),
                ],
            },
            {
                '__jsonpath__': '..',
                'node': RecursiveDescentNode(TerminalNode()),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__': '..',
                'node': RecursiveDescentNode(TerminalNode()),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, root_value),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'hello')]), root_value, root_value['hello']),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'languages')]), root_value, root_value['languages']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(0)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][0]
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(1)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][1]
                    ),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'preferences')]), root_value, root_value['preferences']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ObjectIndexSubscript('coffee')]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        root_value['preferences']['coffee']
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ObjectIndexSubscript('tea')]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        root_value['preferences']['tea']
                    ),
                ],
            },
            {
                '__jsonpath__': '..[?(@)]',
                'node': RecursiveDescentNode(
                    SubscriptNode(
                        TerminalNode(),
                        [
                            FilterSubscript(SomeExpression(
                                CurrentNode(TerminalNode())))
                        ]
                    )
                ),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, root_value),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'hello')]), root_value, root_value['hello']),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'languages')]), root_value, root_value['languages']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(0)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][0]
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(1)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][1]
                    ),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'preferences')]), root_value, root_value['preferences']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ObjectIndexSubscript('coffee')]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        root_value['preferences']['coffee']
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ObjectIndexSubscript('tea')]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        root_value['preferences']['tea']
                    ),
                ],
            },
            {
                '__jsonpath__': '..[*]',
                'node': RecursiveDescentNode(SubscriptNode(TerminalNode(), [WildcardSubscript()])),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'hello')]), root_value, root_value['hello']),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'languages')]), root_value, root_value['languages']),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'preferences')]), root_value, root_value['preferences']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(0)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][0]
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(1)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][1]
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ObjectIndexSubscript('coffee')]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        root_value['preferences']['coffee']
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ObjectIndexSubscript('tea')]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        root_value['preferences']['tea']
                    ),
                ],
            },
            {
                '__jsonpath__': '..["hello"]',
                'node': RecursiveDescentNode(SubscriptNode(TerminalNode(), [ObjectIndexSubscript('hello')])),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'hello')]), root_value, root_value['hello']),
                ],
            },
            {
                '__jsonpath__': '..[0]',
                'node': RecursiveDescentNode(SubscriptNode(TerminalNode(), [ArrayIndexSubscript(0)])),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(0)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][0]
                    ),
                ],
            },
            {
                '__jsonpath__': '["hello"][length()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [LengthCallableSubscript()]), [ObjectIndexSubscript('hello')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [LengthCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('hello')]
                        ),
                        root_value,
                        len(root_value['hello'])
                    ),
                ],
            },
            {
                '__jsonpath__': '["hello"][charAt(0)]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [CharAtCallableSubscript(0)]), [ObjectIndexSubscript('hello')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [CharAtCallableSubscript(MatchData(TerminalNode(), root_value, 0))]
                            ),
                            [ObjectIndexSubscript('hello')]
                        ),
                        root_value,
                        root_value['hello'][0]
                    ),
                ],
            },
            {
                '__jsonpath__': '["hello"][charAt(1000)]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [CharAtCallableSubscript(1000)]), [ObjectIndexSubscript('hello')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [],
            },
            {
                '__jsonpath__': '["hello"][charAt($["hello"][length()])]',
                'node': SubscriptNode(SubscriptNode(TerminalNode(), [CharAtCallableSubscript(
                    RootNode(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [LengthCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('hello')]
                        )
                    )
                )]), [ObjectIndexSubscript('hello')]),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [],
            },
            {
                '__jsonpath__': '["hello"][substring(1)]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [SubstringCallableSubscript(1)]), [ObjectIndexSubscript('hello')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [SubstringCallableSubscript(MatchData(TerminalNode(), root_value, 1))]
                            ),
                            [ObjectIndexSubscript('hello')]
                        ),
                        root_value,
                        root_value['hello'][1:]
                    ),
                ],
            },
            {
                '__jsonpath__': '["hello"][substring(1,3)]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [SubstringCallableSubscript(1, 3)]), [ObjectIndexSubscript('hello')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [SubstringCallableSubscript(MatchData(TerminalNode(), root_value, 1),
                                                            MatchData(TerminalNode(), root_value, 3))]
                            ),
                            [ObjectIndexSubscript('hello')]
                        ),
                        root_value,
                        root_value['hello'][1:3]
                    ),
                ],
            },
            {
                '__jsonpath__': '["languages"][length()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [LengthCallableSubscript()]), [ObjectIndexSubscript('languages')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [LengthCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        len(root_value['languages'])
                    ),
                ],
            },
            {
                '__jsonpath__': '["languages"][entries()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [EntriesCallableSubscript()]), [ObjectIndexSubscript('languages')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [EntriesCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        list(map(list, enumerate(root_value['languages'])))
                    ),
                ],
            },
            {
                '__jsonpath__': '["languages"][keys()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [KeysCallableSubscript()]), [ObjectIndexSubscript('languages')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [KeysCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        list(range(len(root_value['languages'])))
                    ),
                ],
            },
            {
                '__jsonpath__': '["languages"][values()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [ValuesCallableSubscript()]), [ObjectIndexSubscript('languages')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ValuesCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages']
                    ),
                ],
            },
            {
                '__jsonpath__': '["preferences"][entries()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [EntriesCallableSubscript()]), [ObjectIndexSubscript('preferences')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [EntriesCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        list(map(list, root_value['preferences'].items()))
                    ),
                ],
            },
            {
                '__jsonpath__': '["preferences"][keys()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [KeysCallableSubscript()]), [ObjectIndexSubscript('preferences')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [KeysCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        list(root_value['preferences'].keys())
                    ),
                ],
            },
            {
                '__jsonpath__': '["preferences"][values()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [ValuesCallableSubscript()]), [ObjectIndexSubscript('preferences')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ValuesCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        list(root_value['preferences'].values())
                    ),
                ],
            },
        ]
Пример #16
0
    def setUp(self):
        """Setup the class."""
        root_value = {
            "hello": "Hello, world!",
            "languages": [
                "en-GB",
                "en-US",
            ],
            "preferences": {
                "coffee": True,
                "tea": False,
            },
        }
        current_value = root_value["hello"]

        self._state = [
            {
                "__jsonpath__":
                "",
                "node":
                TerminalNode(),
                "root_value":
                root_value,
                "current_value":
                current_value,
                "match_data_list": [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                "__jsonpath__":
                "$",
                "node":
                RootNode(TerminalNode()),
                "root_value":
                root_value,
                "current_value":
                current_value,
                "match_data_list": [
                    MatchData(RootNode(TerminalNode()), root_value,
                              root_value),
                ],
            },
            {
                "__jsonpath__":
                "@",
                "node":
                CurrentNode(TerminalNode()),
                "root_value":
                root_value,
                "current_value":
                current_value,
                "match_data_list": [
                    MatchData(CurrentNode(TerminalNode()), root_value,
                              current_value),
                ],
            },
            {
                "__jsonpath__": "[]",
                "node": SubscriptNode(TerminalNode(), []),
                "root_value": root_value,
                "current_value": current_value,
                "match_data_list": [],
            },
            {
                "__jsonpath__":
                "[?(@)]",
                "node":
                SubscriptNode(
                    TerminalNode(),
                    [
                        FilterSubscript(
                            SomeExpression(CurrentNode(TerminalNode())))
                    ],
                ),
                "root_value":
                root_value,
                "current_value":
                current_value,
                "match_data_list": [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                "__jsonpath__":
                "[?(@),?(@)]",
                "node":
                SubscriptNode(
                    TerminalNode(),
                    [
                        FilterSubscript(
                            SomeExpression(CurrentNode(TerminalNode()))),
                        FilterSubscript(
                            SomeExpression(CurrentNode(TerminalNode()))),
                    ],
                ),
                "root_value":
                root_value,
                "current_value":
                current_value,
                "match_data_list": [
                    MatchData(TerminalNode(), root_value, current_value),
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                "__jsonpath__": "[*]",
                "node": SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                "root_value": root_value,
                "current_value": current_value,
                "match_data_list": [],
            },
            {
                "__jsonpath__":
                "[*]",
                "node":
                SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("hello")]),
                        root_value,
                        root_value["hello"],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("languages")]),
                        root_value,
                        root_value["languages"],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("preferences")]),
                        root_value,
                        root_value["preferences"],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["languages"][*]',
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                    [ObjectIndexSubscript("languages")],
                ),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][0],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][1],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["hello","languages"]',
                "node":
                SubscriptNode(
                    TerminalNode(),
                    [
                        ObjectIndexSubscript("hello"),
                        ObjectIndexSubscript("languages")
                    ],
                ),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("hello")]),
                        root_value,
                        root_value["hello"],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("languages")]),
                        root_value,
                        root_value["languages"],
                    ),
                ],
            },
            {
                "__jsonpath__":
                "..",
                "node":
                RecursiveDescentNode(TerminalNode()),
                "root_value":
                root_value,
                "current_value":
                current_value,
                "match_data_list": [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                "__jsonpath__":
                "..",
                "node":
                RecursiveDescentNode(TerminalNode()),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(TerminalNode(), root_value, root_value),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("hello")]),
                        root_value,
                        root_value["hello"],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("languages")]),
                        root_value,
                        root_value["languages"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][0],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][1],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("preferences")]),
                        root_value,
                        root_value["preferences"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ObjectIndexSubscript("coffee")]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        root_value["preferences"]["coffee"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ObjectIndexSubscript("tea")]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        root_value["preferences"]["tea"],
                    ),
                ],
            },
            {
                "__jsonpath__":
                "..[?(@)]",
                "node":
                RecursiveDescentNode(
                    SubscriptNode(
                        TerminalNode(),
                        [
                            FilterSubscript(
                                SomeExpression(CurrentNode(TerminalNode())))
                        ],
                    )),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(TerminalNode(), root_value, root_value),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("hello")]),
                        root_value,
                        root_value["hello"],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("languages")]),
                        root_value,
                        root_value["languages"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][0],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][1],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("preferences")]),
                        root_value,
                        root_value["preferences"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ObjectIndexSubscript("coffee")]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        root_value["preferences"]["coffee"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ObjectIndexSubscript("tea")]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        root_value["preferences"]["tea"],
                    ),
                ],
            },
            {
                "__jsonpath__":
                "..[*]",
                "node":
                RecursiveDescentNode(
                    SubscriptNode(TerminalNode(), [WildcardSubscript()])),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("hello")]),
                        root_value,
                        root_value["hello"],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("languages")]),
                        root_value,
                        root_value["languages"],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("preferences")]),
                        root_value,
                        root_value["preferences"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][0],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][1],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ObjectIndexSubscript("coffee")]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        root_value["preferences"]["coffee"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ObjectIndexSubscript("tea")]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        root_value["preferences"]["tea"],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '..["hello"]',
                "node":
                RecursiveDescentNode(
                    SubscriptNode(TerminalNode(),
                                  [ObjectIndexSubscript("hello")])),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("hello")]),
                        root_value,
                        root_value["hello"],
                    ),
                ],
            },
            {
                "__jsonpath__":
                "..[0]",
                "node":
                RecursiveDescentNode(
                    SubscriptNode(TerminalNode(), [ArrayIndexSubscript(0)])),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][0],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["hello"][length()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [LengthCallableSubscript()]),
                    [ObjectIndexSubscript("hello")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [LengthCallableSubscript()]),
                            [ObjectIndexSubscript("hello")],
                        ),
                        root_value,
                        len(root_value["hello"]),
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["hello"][charAt(0)]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(),
                                  [CharAtCallableSubscript(0)]),
                    [ObjectIndexSubscript("hello")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [
                                    CharAtCallableSubscript(
                                        MatchData(TerminalNode(), root_value,
                                                  0))
                                ],
                            ),
                            [ObjectIndexSubscript("hello")],
                        ),
                        root_value,
                        root_value["hello"][0],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["hello"][charAt(1000)]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(),
                                  [CharAtCallableSubscript(1000)]),
                    [ObjectIndexSubscript("hello")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [],
            },
            {
                "__jsonpath__":
                '["hello"][charAt($["hello"][length()])]',
                "node":
                SubscriptNode(
                    SubscriptNode(
                        TerminalNode(),
                        [
                            CharAtCallableSubscript(
                                RootNode(
                                    SubscriptNode(
                                        SubscriptNode(
                                            TerminalNode(),
                                            [LengthCallableSubscript()]),
                                        [ObjectIndexSubscript("hello")],
                                    )))
                        ],
                    ),
                    [ObjectIndexSubscript("hello")],
                ),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [],
            },
            {
                "__jsonpath__":
                '["hello"][substring(1)]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(),
                                  [SubstringCallableSubscript(1)]),
                    [ObjectIndexSubscript("hello")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [
                                    SubstringCallableSubscript(
                                        MatchData(TerminalNode(), root_value,
                                                  1))
                                ],
                            ),
                            [ObjectIndexSubscript("hello")],
                        ),
                        root_value,
                        root_value["hello"][1:],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["hello"][substring(1,3)]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(),
                                  [SubstringCallableSubscript(1, 3)]),
                    [ObjectIndexSubscript("hello")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [
                                    SubstringCallableSubscript(
                                        MatchData(TerminalNode(), root_value,
                                                  1),
                                        MatchData(TerminalNode(), root_value,
                                                  3),
                                    )
                                ],
                            ),
                            [ObjectIndexSubscript("hello")],
                        ),
                        root_value,
                        root_value["hello"][1:3],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["languages"][length()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [LengthCallableSubscript()]),
                    [ObjectIndexSubscript("languages")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [LengthCallableSubscript()]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        len(root_value["languages"]),
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["languages"][entries()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(),
                                  [EntriesCallableSubscript()]),
                    [ObjectIndexSubscript("languages")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [EntriesCallableSubscript()]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        list(map(list, enumerate(root_value["languages"]))),
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["languages"][keys()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [KeysCallableSubscript()]),
                    [ObjectIndexSubscript("languages")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [KeysCallableSubscript()]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        list(range(len(root_value["languages"]))),
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["languages"][values()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [ValuesCallableSubscript()]),
                    [ObjectIndexSubscript("languages")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ValuesCallableSubscript()]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["preferences"][entries()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(),
                                  [EntriesCallableSubscript()]),
                    [ObjectIndexSubscript("preferences")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [EntriesCallableSubscript()]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        list(map(list, root_value["preferences"].items())),
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["preferences"][keys()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [KeysCallableSubscript()]),
                    [ObjectIndexSubscript("preferences")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [KeysCallableSubscript()]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        list(root_value["preferences"].keys()),
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["preferences"][values()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [ValuesCallableSubscript()]),
                    [ObjectIndexSubscript("preferences")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ValuesCallableSubscript()]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        list(root_value["preferences"].values()),
                    ),
                ],
            },
        ]