forked from alliander-opensource/pycgmes
-
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.
Signed-off-by: Thomas Günther <[email protected]>
- Loading branch information
Showing
5 changed files
with
94 additions
and
15 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
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,40 @@ | ||
# SPDX-FileCopyrightText: 2025 Thomas Guenther <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import sys | ||
from pathlib import Path | ||
|
||
from pycgmes.utils.base import Base | ||
from pycgmes.utils.chevron_writer import ChevronWriter | ||
from pycgmes.utils.reader import Reader | ||
|
||
_curr_dir = Path(__file__).resolve().parent | ||
|
||
|
||
def main(input_files: list[str]) -> None: | ||
output_dir = _curr_dir / "output" | ||
output_dir.mkdir(parents=True, exist_ok=True) | ||
import_result = read(input_files) | ||
objects = import_result["topology"] | ||
write(output_dir / "Example_Model", "Example_Model", objects) | ||
|
||
|
||
def read(input_files: list[str]) -> dict: | ||
reader = Reader(cgmes_version_path="pycgmes.resources") | ||
return reader.parse_profiles(input_files) | ||
|
||
|
||
def write(outputfile: Path, model_id: str, objects: dict[str, Base]) -> None: | ||
writer = ChevronWriter(objects) | ||
class_profile_map = ChevronWriter.get_class_profile_map(writer.objects.values()) | ||
profile_file_map = writer.write(str(outputfile), model_id, class_profile_map) | ||
for idx, (profile, file) in enumerate(profile_file_map.items()): | ||
print(f"CIM outputfile {idx + 1} for {profile}: {file}") | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) <= 1: | ||
sys.exit("Too few arguments") | ||
input_files = sys.argv[1:] | ||
main(input_files) |
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,39 @@ | ||
# SPDX-FileCopyrightText: 2025 Thomas Guenther <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import sys | ||
from pathlib import Path | ||
|
||
from pycgmes.utils.base import Base | ||
from pycgmes.utils.reader import Reader | ||
from pycgmes.utils.writer import Writer | ||
|
||
_curr_dir = Path(__file__).resolve().parent | ||
|
||
|
||
def main(input_files: list[str]) -> None: | ||
output_dir = _curr_dir / "output" | ||
output_dir.mkdir(parents=True, exist_ok=True) | ||
import_result = read(input_files) | ||
objects = import_result["topology"] | ||
write(output_dir / "Example_Model", "Example_Model", objects) | ||
|
||
|
||
def read(input_files: list[str]) -> dict: | ||
reader = Reader(cgmes_version_path="pycgmes.resources") | ||
return reader.parse_profiles(input_files) | ||
|
||
|
||
def write(outputfile: Path, model_id: str, objects: dict[str, Base]) -> None: | ||
writer = Writer(objects=objects) | ||
profile_file_map = writer.write(str(outputfile), model_id) | ||
for idx, (profile, file) in enumerate(profile_file_map.items()): | ||
print(f"CIM outputfile {idx + 1} for {profile}: {file}") | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) <= 1: | ||
sys.exit("Too few arguments") | ||
input_files = sys.argv[1:] | ||
main(input_files) |
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