List all locations for a given field and term
(self,
field, # type: str
term # type: str
)
| 827 | return locations |
| 828 | |
| 829 | def get(self, |
| 830 | field, # type: str |
| 831 | term # type: str |
| 832 | ) -> List[SearchRowLocation]: |
| 833 | """List all locations for a given field and term""" |
| 834 | if field not in self._raw_locations: |
| 835 | raise InvalidArgumentException(f'Cannot find "{field}" field in locations.') |
| 836 | if term not in self._raw_locations[field]: |
| 837 | raise InvalidArgumentException(f'Cannot find "{term}" within {field}\'s locations.') |
| 838 | |
| 839 | locations = [] |
| 840 | for loc in self._raw_locations[field][term]: |
| 841 | new_location = {'field': field, 'term': term, 'position': None} |
| 842 | new_location.update({k: v for k, v in loc.items() if k != 'position'}) |
| 843 | new_location['position'] = loc.get('position', None) |
| 844 | locations.append(new_location) |
| 845 | |
| 846 | return [SearchRowLocation(**loc) for loc in locations] |
| 847 | |
| 848 | def fields(self) -> List[str]: |
| 849 | """ |
no test coverage detected