forked from snowflakedb/snowflake-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
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
48ca3e2
commit 1b57bb3
Showing
3 changed files
with
34 additions
and
9 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import Generator | ||
from contextlib import contextmanager | ||
from pathlib import Path | ||
from strictyaml import YAML, load | ||
|
||
from snowcli.cli.project.schemas.project_definition import project_schema | ||
|
||
|
||
@contextmanager | ||
def modify_yml(path: Path) -> Generator[YAML, None, None]: | ||
""" | ||
Read, then write back modifications made to a YAML file. | ||
""" | ||
with open(path, "r") as f: | ||
yml = load(f.read(), schema=project_schema) | ||
|
||
yield yml | ||
|
||
with open(path, "w") as f: | ||
f.write(yml.as_yaml()) |
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