JunoLab / Weave.jl

Scientific reports/literate programming for Julia
http://weavejl.mpastell.com
MIT License
821 stars 94 forks source link

[BUG] An `out_path` arg with a "." in last segment results in incorrect save path #449

Open bencottier opened 2 years ago

bencottier commented 2 years ago

description

If the out_path argument to weave contains a "." character in the last segment, e.g. "/path/1.2" then the file ends up being saved to e.g. "/path/1.html". I don't think this is the case with an ending slash e.g. "/path/1.2/". One reason to have a "." character like this is using a timestamp as a folder for an experiment, e.g. Dates.now() == 2022-02-21T16:22:11.715.

I think the reason is here: https://github.com/JunoLab/Weave.jl/blob/381de22c7d4076fc210147f552c6e4132f6c805c/src/run.jl#L117-L130

It calls splitext before checking whether a folder or file was passed. Perhaps it could instead condition on isdir and then if not isdir, call splitext to get the file extension.

versions

using InteractiveUtils; versioninfo():

Julia Version 1.6.5
Commit 9058264a69 (2021-12-19 12:30 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin19.6.0)
CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
JULIA_PKG_DEVDIR = /Users/bencottier/JuliaEnvs
JULIA_EDITOR = code

using Pkg; Pkg.status():

(private packages omitted)

[1c724243] + AWSS3 v0.9.5
[a93c6f00] + DataFrames v1.3.2
[48062228] + FilePathsBase v0.9.15
[f28f55f0] + Memento v1.3.0
[91a5bcdd] + Plots v1.25.11
[44d3d7a6] + Weave v0.10.10

minimum reproducible steps

Should be reproduced by calling something like weave("/path/to/script.jl"; doctype="md2html", out_path="/some/other/path/1.2") and observing where the HTML file is saved.