Compiler can load from file-like objects
This commit is contained in:
parent
8dc51d70e7
commit
b1f9eb45d2
|
@ -3,6 +3,7 @@ then
|
|||
python -m venv .venv
|
||||
. .venv/bin/activate
|
||||
pip install -U coverage setuptools setuptools_scm wheel
|
||||
pip install -e .
|
||||
else
|
||||
. .venv/bin/activate
|
||||
fi
|
||||
|
|
|
@ -456,15 +456,18 @@ class Compiler:
|
|||
def __init__(self):
|
||||
self.root = Namespace(())
|
||||
|
||||
def load_filelike(self, module_path, f):
|
||||
x = Decoder(f.read()).next()
|
||||
if x.key == SCHEMA:
|
||||
self.load_schema((Symbol(module_path),), x)
|
||||
elif x.key == BUNDLE:
|
||||
for (p, s) in x[0].items():
|
||||
self.load_schema(p, s)
|
||||
|
||||
def load(self, filename):
|
||||
filename = pathlib.Path(filename)
|
||||
with open(filename, 'rb') as f:
|
||||
x = Decoder(f.read()).next()
|
||||
if x.key == SCHEMA:
|
||||
self.load_schema((Symbol(filename.stem),), x)
|
||||
elif x.key == BUNDLE:
|
||||
for (p, s) in x[0].items():
|
||||
self.load_schema(p, s)
|
||||
self.load_filelike(filename.stem, f)
|
||||
|
||||
def load_schema(self, module_path, schema):
|
||||
if schema[0][VERSION] != 1:
|
||||
|
|
Loading…
Reference in New Issue