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

Function get_boltstart

devtools/check_quotes.py:42–72  ·  view source on GitHub ↗
(
    args: Namespace, line: str, filename: str, linenum: int
)

Source from the content-addressed store, hash-verified

40# This looks like a BOLT line; return the bolt number and start of
41# quote if we shouldn't ignore it.
42def get_boltstart(
43 args: Namespace, line: str, filename: str, linenum: int
44) -> Tuple[Optional[int], Optional[str]]:
45 if not line.startswith(args.comment_start + "BOLT"):
46 return None, None
47
48 parts = line[len(args.comment_start + "BOLT"):].partition(":")
49 boltnum = parts[0].strip()
50
51 # e.g. BOLT-50143e388e16a449a92ed574fc16eb35b51426b9 #11:"
52 if boltnum.startswith("-"):
53 if not included_commit(args, boltnum[1:]):
54 return None, None
55 boltnum = boltnum.partition(" ")[2]
56
57 if not boltnum.startswith("#"):
58 print(
59 "{}:{}:expected # after BOLT in {}".format(filename, linenum, line),
60 file=sys.stderr,
61 )
62 sys.exit(1)
63
64 try:
65 boltint = int(boltnum[1:].strip())
66 except ValueError:
67 print(
68 "{}:{}:bad bolt number {}".format(filename, linenum, line), file=sys.stderr
69 )
70 sys.exit(1)
71
72 return boltint, parts[2]
73
74
75# We expect lines to start with '# BOLT #NN:'

Callers 1

gather_quotesFunction · 0.85

Calls 1

included_commitFunction · 0.85

Tested by

no test coverage detected