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

Function main

devtools/check_quotes.py:250–355  ·  view source on GitHub ↗
(args: Namespace)

Source from the content-addressed store, hash-verified

248
249
250def main(args: Namespace) -> None:
251 boltquotes = gather_quotes(args)
252 failed = False
253 for bolt in boltquotes:
254 boltsections = load_bolt(args.boltdir, bolt)
255 last_section: Optional[str] = None
256 last_section_idx: int = -1
257 last_end: int = 0
258 last_filename: Optional[str] = None
259 for quote in boltquotes[bolt]:
260 # Reset per-file tracking when the file changes.
261 if quote.filename != last_filename:
262 last_section = None
263 last_section_idx = -1
264 last_end = 0
265 last_filename = quote.filename
266
267 if quote.text.startswith("..."):
268 # Leading '...' means this quote must immediately follow the
269 # previous quote (in this file) in the BOLT text.
270 if last_section is None:
271 print(
272 "{}:{}:'...' at start of quote but no previous BOLT #{} quote in this file".format(
273 quote.filename, quote.line, bolt
274 ),
275 file=sys.stderr,
276 )
277 if not args.keep_going:
278 sys.exit(1)
279 failed = True
280 sect, istart, end = None, -1, 0
281 else:
282 text_after = quote.text[3:]
283 istart, end = find_quote_immediate(text_after, last_section, last_end)
284 if istart < 0:
285 sect = None
286 print(
287 "{}:{}:cannot find match (must immediately follow previous quote)".format(
288 quote.filename, quote.line
289 ),
290 file=sys.stderr,
291 )
292 print(
293 " previous quote ended at: ...{:.45}".format(
294 last_section[last_end:]
295 ),
296 file=sys.stderr,
297 )
298 print(
299 " but quote expects: {:.45}".format(text_after),
300 file=sys.stderr,
301 )
302 if not args.keep_going:
303 sys.exit(1)
304 failed = True
305 else:
306 sect = last_section
307 if args.coverage:

Callers 1

check_quotes.pyFile · 0.70

Calls 5

gather_quotesFunction · 0.85
find_quote_immediateFunction · 0.85
write_coverageFunction · 0.85
find_quoteFunction · 0.85
load_boltFunction · 0.70

Tested by

no test coverage detected