def _parse_links(json: JSON, area: str) -> Dict[str, Link]: if area not in json["input"]["links"]: return dict() properties_ini = json["input"]["links"][area]["properties"] return { link: Link( filters_synthesis=Link.split( properties_ini[link]["filter-synthesis"]), filters_year=Link.split( properties_ini[link]["filter-year-by-year"]), ) for link in list(properties_ini.keys()) }
def _parse_links(root: Path, area: str) -> Dict[str, Link]: properties_ini = IniReader().read(root / f"input/links/{area}/properties.ini") return { link: Link.from_json(properties_ini[link]) for link in list(properties_ini.keys()) }
def test_parse_links(tmp_path: Path) -> None: study_path = build_empty_files(tmp_path) (study_path / "input/links/fr").mkdir(parents=True) content = """ [l1] filter-synthesis = annual filter-year-by-year = hourly """ (study_path / "input/links/fr/properties.ini").write_text(content) link = Link(filters_synthesis=["annual"], filters_year=["hourly"]) assert ConfigPathBuilder._parse_links(study_path, "fr") == {"l1": link}
def test_parse_links() -> None: json = build_empty_json() json["input"]["links"] = { "fr": { "properties": { "l1": { "filter-synthesis": "annual", "filter-year-by-year": "hourly", } } } } link = Link(filters_synthesis=["annual"], filters_year=["hourly"]) assert ConfigJsonBuilder._parse_links(json, "fr") == {"l1": link}
def _parse_filters_year(json: JSON, area: str) -> List[str]: filters: str = json["input"]["areas"][area]["optimization"][ "filtering"]["filter-year-by-year"] return Link.split(filters)
def _parse_filters_synthesis(json: JSON, area: str) -> List[str]: filters: str = json["input"]["areas"][area]["optimization"][ "filtering"]["filter-synthesis"] return Link.split(filters)
def _parse_filters_year(root: Path, area: str) -> List[str]: filters: str = IniReader().read(root / f"input/areas/{area}/optimization.ini" )["filtering"]["filter-year-by-year"] return Link.split(filters)