Skip to content

Commit

Permalink
Add some comments to gen_python.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
deltamarnix committed Feb 7, 2024
1 parent 705c244 commit 3407f62
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions utils/gen_python.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ function strip_prefix(T::DataType)
end

function get_models()
"""
Set up models including field properties for all subtypes of Legolas.AbstractRecord.
"""
[
(
name = strip_prefix(T),
Expand All @@ -40,11 +43,14 @@ function get_models()
]
end

# Setup template with whitespace settings that mainly strips whitespace.
# See model.py.jinja for the layout of the template.
model_template = Template(
normpath(@__DIR__, "templates", "model.py.jinja");
config = Dict("trim_blocks" => true, "lstrip_blocks" => true, "autoescape" => false),
)

# Write schemas.py
open(normpath(@__DIR__, "..", "python", "ribasim", "ribasim", "schemas.py"), "w") do io
init = Dict("models" => get_models())
println(io, model_template(; init = init))
Expand Down

0 comments on commit 3407f62

Please sign in to comment.