in sapp/json_diagnostics.py [0:0]
def entries(self, search: str, pretty_print: bool = False) -> List[Dict[str, Any]]:
lookup_table = self.lookup_table
assert lookup_table, "Call load() first"
parser = self.parser_class()
entry_locations = {
c: lookup_table.entries.get(c, []) for c in self.callables() if search in c
}
entries = []
for callable_name, entry_location in entry_locations.items():
for (file_id, offset) in entry_location:
path = lookup_table.file_index[file_id]
errors = parser.get_json_from_file_offset(path, offset)
if errors:
if pretty_print:
entries.append(
highlight(
json.dumps({callable_name: errors}, indent=2),
JsonLexer(),
TerminalFormatter(),
)
)
else:
entries.append(errors)
else:
logger.warn(f"No json found at {path, offset}")
return entries