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

Function load_bolt

devtools/check_quotes.py:128–156  ·  view source on GitHub ↗

Return a list, divided into one-string-per-bolt-section, with whitespace collapsed into single spaces.

(boltdir: str, num: int)

Source from the content-addressed store, hash-verified

126
127
128def load_bolt(boltdir: str, num: int) -> List[str]:
129 """Return a list, divided into one-string-per-bolt-section, with
130 whitespace collapsed into single spaces.
131
132 """
133 boltfile = glob.glob("{}/{}-*md".format(boltdir, str(num).zfill(2)))
134 if len(boltfile) == 0:
135 print("Cannot find bolt {} in {}".format(num, boltdir), file=sys.stderr)
136 sys.exit(1)
137 elif len(boltfile) > 1:
138 print(
139 "More than one bolt {} in {}? {}".format(num, boltdir, boltfile),
140 file=sys.stderr,
141 )
142 sys.exit(1)
143
144 # We divide it into sections, and collapse whitespace.
145 boltsections = []
146 with open(boltfile[0]) as f:
147 sect = ""
148 for line in f.readlines():
149 if line.startswith("#"):
150 # Append with whitespace collapsed.
151 boltsections.append(collapse_whitespace(sect))
152 sect = ""
153 sect += line
154 boltsections.append(collapse_whitespace(sect))
155
156 return boltsections
157
158
159def find_quote(

Callers 1

mainFunction · 0.70

Calls 1

collapse_whitespaceFunction · 0.70

Tested by

no test coverage detected