Block summaries
Block summaries for rg(summary=True) and rga(summary=True).
Each SearchBlock groups contiguous non-blank lines containing one or more matches into a single pilcrow-joined summary row, returned in a BlockResults list.
SearchBlock
def SearchBlock(
path:str, # Relative path label for the file
block_index:int, # 0-based index of this block within `path`
start_line:int, # 1-based first line number of the block
end_line:int, # 1-based last line number of the block
start_lnhash:str, # Hash-verified `lineno|hash|` address of `start_line`
end_lnhash:str, # Hash-verified `lineno|hash|` address of `end_line`
kind:str, # `'match'` or `'context'`
source:str, # Full source text of the block
matches:list, # Matching `SearchLine` rows within this block
maxlen:int=180, # Maximum source characters shown in `str()`
display_lnhash:bool=False, # Format locations with `lnhash` addresses instead of line numbers
):
A blank-line-delimited source block containing a match, or context for one.
The display format is path:start-end:source, with - in place of the last colon on context rows. Hashed locations use start_lnhash,end_lnhash (or one hash for a single line). Newline runs display as ΒΆ while keeping indentation; maxlen limits the displayed preview, not the stored source.
SearchBlock.asdict
def asdict()->dict:
Return all block fields (with matches converted via asdict()) as a plain dict.
BlockResults
def BlockResults(
*args, **kwargs
):
List of SearchBlock rows with one-line block summary display.