|
8 | 8 | import pwd |
9 | 9 | import subprocess |
10 | 10 | import threading |
11 | | -import yaml |
12 | 11 | from copy import deepcopy |
13 | 12 | from dataclasses import dataclass |
14 | 13 | from functools import partial |
|
19 | 18 | import watchdog.events |
20 | 19 | import networkx |
21 | 20 |
|
22 | | -from .flutter import check_type, LoadError |
23 | 21 | from . import n, gizaparser, rstparser, util |
24 | 22 | from .gizaparser.nodes import GizaCategory |
25 | | -from .gizaparser.published_branches import PublishedBranches |
| 23 | +from .gizaparser.published_branches import PublishedBranches, parse_published_branches |
26 | 24 | from .postprocess import DevhubPostprocessor, Postprocessor |
27 | 25 | from .util import RST_EXTENSIONS |
28 | 26 | from .types import ( |
|
50 | 48 | InvalidURL, |
51 | 49 | InvalidLiteralInclude, |
52 | 50 | InvalidTableStructure, |
53 | | - UnmarshallingError, |
54 | | - ErrorParsingYAMLFile, |
55 | 51 | ) |
56 | 52 |
|
57 | 53 | # XXX: Work around to get snooty working with Python 3.8 until we can fix |
@@ -834,28 +830,13 @@ def __init__( |
834 | 830 | def get_parsed_branches( |
835 | 831 | self |
836 | 832 | ) -> Tuple[Optional[PublishedBranches], List[Diagnostic]]: |
837 | | - path = self.config.root |
838 | 833 | try: |
839 | | - with path.joinpath("published-branches.yaml").open(encoding="utf-8") as f: |
840 | | - data = yaml.safe_load(f) |
841 | | - try: |
842 | | - result = check_type(PublishedBranches, data) |
843 | | - return result, [] |
844 | | - except LoadError as err: |
845 | | - line: int = getattr(err.bad_data, "_start_line", 0) + 1 |
846 | | - error_node: Diagnostic = UnmarshallingError(str(err), line) |
847 | | - return None, [error_node] |
| 834 | + path = self.config.root |
| 835 | + return parse_published_branches( |
| 836 | + path.joinpath("published-branches.yaml"), self.config |
| 837 | + ) |
848 | 838 | except FileNotFoundError: |
849 | 839 | pass |
850 | | - except LoadError as err: |
851 | | - load_error_line: int = getattr(err.bad_data, "_start_line", 0) + 1 |
852 | | - load_error_node: Diagnostic = UnmarshallingError(str(err), load_error_line) |
853 | | - return None, [load_error_node] |
854 | | - except yaml.error.MarkedYAMLError as err: |
855 | | - yaml_error_node: Diagnostic = ErrorParsingYAMLFile( |
856 | | - path, str(err), err.problem_mark.line |
857 | | - ) |
858 | | - return None, [yaml_error_node] |
859 | 840 | return None, [] |
860 | 841 |
|
861 | 842 | def get_fileid(self, path: PurePath) -> FileId: |
|
0 commit comments