DynarePreprocessor.jl 830 Bytes
Newer Older
1
using Artifacts
Michel Juillard's avatar
Michel Juillard committed
2

3
4
5
6
function dynare_preprocess(modfilename, args)
    dynare_args = [basename(modfilename), "language=julia", "output=third", "json=compute"]
    offset = 0
    for a in args
7
8
9
10
        astring = string(a)
        if (!occursin(r"^output=", astring)
            && !occursin(r"^json=", astring))
            push!(dynare_args, astring)
11
12
13
        end
    end
    println(dynare_args)
MichelJuillard's avatar
MichelJuillard committed
14
15
16
17
    run_dynare(modfilename, dynare_args)
end

function run_dynare(modfilename, dynare_args)
18
    directory = dirname(modfilename)
MichelJuillard's avatar
MichelJuillard committed
19
20
21
22
    if length(directory) > 0
        current_directory = pwd()
        cd(directory)
    end
23
24
25
26

    dynare_preprocessor_path = joinpath(artifact"dynare-preprocessor", "dynare-preprocessor")
    run(`$dynare_preprocessor_path $dynare_args`)

MichelJuillard's avatar
MichelJuillard committed
27
28
29
    if length(directory) > 0
        cd(current_directory)
    end
30
end