mirror of
https://github.com/lightning/bolts.git
synced 2024-11-19 01:50:03 +01:00
tools: remove broken structured.py (#812)
This script was previously used in Electrum but no more. So since this script doesn't even parse the output of extract-formats.py any more, just remove it.
This commit is contained in:
parent
57e5545bbc
commit
5afe7028f4
@ -1,51 +0,0 @@
|
||||
from io import StringIO
|
||||
import glob
|
||||
import collections
|
||||
import json
|
||||
|
||||
formats = __import__("extract-formats")
|
||||
|
||||
|
||||
class Options(object):
|
||||
output_types = True
|
||||
output_fields = True
|
||||
check_alignment = False
|
||||
|
||||
|
||||
options = Options()
|
||||
csv = []
|
||||
|
||||
output = StringIO()
|
||||
for i in sorted(glob.glob("../??-*.md")):
|
||||
with open(i) as f:
|
||||
formats.main(options, output=output, lines=f.readlines())
|
||||
csvstr = output.getvalue().strip()
|
||||
if csvstr == "":
|
||||
continue
|
||||
csv += csvstr.split("\n")
|
||||
|
||||
resmap = collections.OrderedDict()
|
||||
|
||||
currentmsgname = None
|
||||
currentmsgfields = {}
|
||||
typenum = None
|
||||
for line in csv:
|
||||
parts = line.split(",")
|
||||
if len(parts) == 2:
|
||||
if currentmsgname is not None:
|
||||
resmap[currentmsgname] = collections.OrderedDict(
|
||||
[("type", typenum), ("payload", currentmsgfields)])
|
||||
currentmsgfields = collections.OrderedDict()
|
||||
currentmsgname = parts[0]
|
||||
typenum = parts[1]
|
||||
continue
|
||||
assert currentmsgname == parts[0], line
|
||||
assert len(parts) in [4, 5], line
|
||||
position = parts[1]
|
||||
length = parts[3]
|
||||
fieldname = parts[2]
|
||||
currentmsgfields[fieldname] = {"position": position, "length": length}
|
||||
if len(parts) == 5: currentmsgfields[fieldname]["feature"] = parts[4]
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(json.dumps(resmap, indent=True))
|
Loading…
Reference in New Issue
Block a user