-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c175f7e
commit 83ef298
Showing
3 changed files
with
22 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
from chrisomatic.spec.schema import schema | ||
import serde | ||
import strictyaml | ||
from rich.console import Console | ||
from rich.status import Status | ||
|
||
from chrisomatic.spec.given import GivenConfig | ||
from serde import from_dict | ||
from strictyaml import load | ||
from chrisomatic.spec.schema import schema | ||
|
||
|
||
def deserialize_config(input_config: str, filename: str): | ||
return _load_from_yaml(input_config, filename) | ||
def deserialize_config(input_config: str, filename: str, console: Console) -> GivenConfig: | ||
if input_config.count('\n') < 100: | ||
return _load_from_yaml(input_config, filename) | ||
text = f"Loading [green]\"{filename}\"[/green] using " \ | ||
"[italic]StrictYAML[/italic], might take a while..." | ||
with Status(status=text, spinner='dots10', console=console): | ||
return _load_from_yaml(input_config, filename) | ||
|
||
|
||
def _load_from_yaml(input_config: str, filename: str) -> GivenConfig: | ||
parsed_yaml = load(input_config, schema=schema, label=filename) | ||
return from_dict(GivenConfig, parsed_yaml.data) | ||
parsed_yaml = strictyaml.load(input_config, schema=schema, label=filename) | ||
return serde.from_dict(GivenConfig, parsed_yaml.data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters