builtup4/bu4/toolchain/readfile.py
2021-07-24 02:34:37 +03:00

14 lines
368 B
Python

import os
from io import StringIO
def readfile(path: str) -> str:
srcio = StringIO()
with open(path + '.bu4') as file:
for line in file:
if line.startswith('@'):
srcio.write(readfile(os.path.join(path, '..', line.removeprefix('@').strip())))
else:
srcio.write(line)
return srcio.getvalue()