MCPcopy Create free account
hub / github.com/ElementsProject/lightning / find_quote_immediate

Function find_quote_immediate

devtools/check_quotes.py:205–231  ·  view source on GitHub ↗

Find text in section starting immediately at position start. Allows a single space separator (whitespace is already collapsed to single spaces). The text may still contain '...' wildcards for its own internal matching. Returns (match_start, end) or (-1, -1) on failure.

(
    text: str, section: str, start: int
)

Source from the content-addressed store, hash-verified

203
204
205def find_quote_immediate(
206 text: str, section: str, start: int
207) -> Tuple[int, int]:
208 """Find text in section starting immediately at position start.
209
210 Allows a single space separator (whitespace is already collapsed to single
211 spaces). The text may still contain '...' wildcards for its own internal
212 matching. Returns (match_start, end) or (-1, -1) on failure.
213 """
214 textparts = text.split("...")
215 off = start
216 # Allow for exactly one whitespace separator (already collapsed).
217 # The quote text itself may also have a leading space (from the comment
218 # continuation line joining), so strip both together.
219 if off < len(section) and section[off] == " ":
220 off += 1
221 match_start = off
222 first_part = textparts[0].lstrip(" ")
223 if not section[off:].startswith(first_part):
224 return -1, -1
225 off += len(first_part)
226 for part in textparts[1:]:
227 new_off = section.find(part, off)
228 if new_off == -1:
229 return -1, -1
230 off = new_off + len(part)
231 return match_start, off
232
233
234def write_coverage(filename: str, bolt: int, section_idx: int, start: int, end: int,

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected