File size: 637 Bytes
49a03ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""Read the actual component graph for non-executing source smoke assertions."""
import re


def read_reader_source(root):
    static = root / "static"
    barrel = static / "reader/reader-components.mjs"
    exports = barrel.read_text(encoding="utf-8")
    files = [static / "reader.js", *(barrel.parent / name for name in
             re.findall(r'from "\./([\w/-]+\.mjs)"', exports))]
    sources = []
    for filename in files:
        source = filename.read_text(encoding="utf-8")
        source = re.sub(r"\breaderContext\.", "", source)
        sources.append(re.sub(r"^  ", "", source, flags=re.M))
    return "\n".join(sources)