This repository has been archived by the owner on Jan 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Z
committed
May 7, 2020
1 parent
6c2a406
commit 89d8721
Showing
4 changed files
with
63 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
twine==3.1.1 | ||
pbr==5.4.5 | ||
jinja2>=2.11 | ||
pyyaml>=5.3.1 |
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
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,33 @@ | ||
|
||
import yaml | ||
from typing import List | ||
from .exception import YamlParsingException | ||
from .inputoutput import SystemIO | ||
from .context import Context | ||
from .syntax import TaskDeclaration | ||
|
||
|
||
class YamlContextFactory: | ||
io: SystemIO | ||
|
||
def __init__(self, io: SystemIO): | ||
self.io = io | ||
|
||
def parse(self, content: str): | ||
parsed = yaml.parse(content) | ||
|
||
if "imports" in parsed: | ||
imports = self._parse_imports(parsed['imports']) | ||
|
||
if "tasks" not in parsed: | ||
raise YamlParsingException('"tasks" section not found in YAML file') | ||
|
||
def _parse_imports(self, classes: List[str]) -> List[TaskDeclaration]: | ||
parsed = [] | ||
|
||
for importstr in classes: | ||
parts = importstr.split('.') | ||
classname = parts[-1] | ||
import_path = parts[:-1] | ||
|
||
|