Skip to content

readprops can not read files where the top level is an array #19

@fhagemann

Description

@fhagemann

PropDicts can read this file:

# filename: propdicts.yaml
test:
  - value: 5
  - value: 6
readprops("propdict.yaml")
PropDict with 1 entry:
  :test => Dict{Any, Any}[Dict("value"=>5), Dict("value"=>6)]

However, it cannot read this:

# filename: array.yaml
- value: 5
- value: 6
readprops("array.yaml")
ERROR: MethodError: no method matching substitute_vars!(::Vector{Dict{Any, Any}}, ::Dict{String, String}; use_env::Bool, ignore_missing::Bool, recursive::Bool)
The function `substitute_vars!` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  substitute_vars!(::AbstractDict, ::Dict{String, String}; use_env, ignore_missing, recursive)
   @ PropDicts ~/.julia/packages/PropDicts/2ofWJ/src/varsubst.jl:142
  substitute_vars!(::AbstractDict; ...)
   @ PropDicts ~/.julia/packages/PropDicts/2ofWJ/src/varsubst.jl:142

Stacktrace:
 [1] readprops(filename::String; subst_pathvar::Bool, subst_env::Bool, trim_null::Bool)
   @ PropDicts ~/.julia/packages/PropDicts/2ofWJ/src/propdict.jl:238
 [2] readprops(filename::String)
   @ PropDicts ~/.julia/packages/PropDicts/2ofWJ/src/propdict.jl:224
 [3] top-level scope
   @ REPL[5]:1

One use case where this might be relevant is for example validity files.

Should this be supported in PropDicts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions