Skip to content

Commit 5d22d43

Browse files
committed
Add schema reader module
1 parent 055fb1c commit 5d22d43

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

harp/schema.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from os import PathLike
2+
from typing import TextIO, Union
3+
from harp.model import Model
4+
from pydantic_yaml import parse_yaml_raw_as
5+
6+
def read_schema(file: Union[str, PathLike, TextIO]) -> Model:
7+
try:
8+
with open(file) as fileIO:
9+
return read_schema(fileIO)
10+
except TypeError:
11+
return parse_yaml_raw_as(Model, file.read())

0 commit comments

Comments
 (0)