From 48a9baef653fb52aef943b849b151af762f63d8f Mon Sep 17 00:00:00 2001 From: guilhermebodin Date: Fri, 15 Sep 2023 12:03:43 -0300 Subject: [PATCH] Updates to fix pmd parser --- .gitignore | 3 ++- revise/revise.bat | 2 +- src/PMD/PMD.jl | 20 +++++++++++++------- test/pmd_parser.jl | 2 ++ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 4de9dfa3..3c006041 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ docs/site/ Manifest.toml *.out -*.ok \ No newline at end of file +*.ok +debug_psrclasses \ No newline at end of file diff --git a/revise/revise.bat b/revise/revise.bat index 262f5a96..d79874fb 100644 --- a/revise/revise.bat +++ b/revise/revise.bat @@ -2,4 +2,4 @@ SET BASEPATH=%~dp0 -%JULIA_192% --project=%BASEPATH% --interactive --load=%BASEPATH%\revise.jl +julia --project=%BASEPATH% --load=%BASEPATH%\revise.jl diff --git a/src/PMD/PMD.jl b/src/PMD/PMD.jl index 2bad1154..a5f9bf97 100644 --- a/src/PMD/PMD.jl +++ b/src/PMD/PMD.jl @@ -66,7 +66,8 @@ function _load_model!( filepath::AbstractString, loaded_files::Set{String}, model_template::ModelTemplate, - relation_mapper::RelationMapper, + relation_mapper::RelationMapper; + verbose::Bool = false, ) if !isfile(filepath) error("'$filepath' is not a valid file") @@ -79,7 +80,7 @@ function _load_model!( filename = basename(filepath) if !in(filename, loaded_files) - parse!(filepath, data_struct, relation_mapper, model_template) + parse!(filepath, data_struct, relation_mapper, model_template; verbose) push!(loaded_files, filename) end @@ -93,7 +94,8 @@ function _load_model!( files::Vector{String}, loaded_files::Set{String}, model_template::ModelTemplate, - relation_mapper::RelationMapper, + relation_mapper::RelationMapper; + verbose::Bool = false, ) if !isempty(files) for filepath in files @@ -102,7 +104,8 @@ function _load_model!( filepath, loaded_files, model_template, - relation_mapper, + relation_mapper; + verbose ) end else @@ -117,7 +120,8 @@ function _load_model!( filepath, loaded_files, model_template, - relation_mapper, + relation_mapper; + verbose ) end end @@ -130,7 +134,8 @@ function load_model( path_pmds::AbstractString, files::Vector{String}, model_template::ModelTemplate, - relation_mapper::RelationMapper, + relation_mapper::RelationMapper; + verbose::Bool = false, ) data_struct = DataStruct() loaded_files = Set{String}() @@ -141,7 +146,8 @@ function load_model( files, loaded_files, model_template, - relation_mapper, + relation_mapper; + verbose ) return data_struct, loaded_files diff --git a/test/pmd_parser.jl b/test/pmd_parser.jl index 2e46a3e2..e4598ef8 100644 --- a/test/pmd_parser.jl +++ b/test/pmd_parser.jl @@ -207,6 +207,8 @@ function test_pmd_source_1() path = joinpath(@__DIR__, "data", "pmd", "source1.pmd") data = PSRI.PMD.parse(path, model_template; verbose = true) + @test haskey(data["PSRHydroPlant"], "Included") + @test data == Dict{String, Dict{String, PSRI.PMD.Attribute}}( "Contract_Forward" => Dict( "AVId" =>