Return the nested data at the given path. For instance: data = {'foo': ['bar', 'baz']} path = ['foo', 0] ==> 'bar'
(self, data, path)
| 144 | return token |
| 145 | |
| 146 | def _path_get(self, data, path): |
| 147 | """Return the nested data at the given path. |
| 148 | |
| 149 | For instance: |
| 150 | data = {'foo': ['bar', 'baz']} |
| 151 | path = ['foo', 0] |
| 152 | ==> 'bar' |
| 153 | """ |
| 154 | # jmespath isn't used here because it would be difficult to actually |
| 155 | # create the jmespath query when taking all of the unknowns of key |
| 156 | # structure into account. Gross though this is, it is simple and not |
| 157 | # very error prone. |
| 158 | d = data |
| 159 | for step in path: |
| 160 | d = d[step] |
| 161 | return d |
| 162 | |
| 163 | def _path_set(self, data, path, value): |
| 164 | """Set the value of a key in the given data. |