builtup4/bu4/parsing/toolchain/readfile.py
2021-07-24 15:10:11 +03:00

18 lines
461 B
Python

# Copyright (c) PARRRATE T&V 2021. All rights reserved.
import os
from io import StringIO
__all__ = ('readfile',)
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, os.path.pardir, line.removeprefix('@').strip())))
else:
srcio.write(line)
return srcio.getvalue()