Skip to content

Commit

Permalink
Updates to fix pmd parser
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermebodin committed Sep 15, 2023
1 parent 55a9ed8 commit 48a9bae
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ docs/site/
Manifest.toml

*.out
*.ok
*.ok
debug_psrclasses
2 changes: 1 addition & 1 deletion revise/revise.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

SET BASEPATH=%~dp0

%JULIA_192% --project=%BASEPATH% --interactive --load=%BASEPATH%\revise.jl
julia --project=%BASEPATH% --load=%BASEPATH%\revise.jl
20 changes: 13 additions & 7 deletions src/PMD/PMD.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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
Expand All @@ -102,7 +104,8 @@ function _load_model!(
filepath,
loaded_files,
model_template,
relation_mapper,
relation_mapper;
verbose
)
end
else
Expand All @@ -117,7 +120,8 @@ function _load_model!(
filepath,
loaded_files,
model_template,
relation_mapper,
relation_mapper;
verbose
)
end
end
Expand All @@ -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}()
Expand All @@ -141,7 +146,8 @@ function load_model(
files,
loaded_files,
model_template,
relation_mapper,
relation_mapper;
verbose
)

return data_struct, loaded_files
Expand Down
2 changes: 2 additions & 0 deletions test/pmd_parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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" =>
Expand Down

0 comments on commit 48a9bae

Please sign in to comment.