Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bencottier opened this issue Feb 21, 2022 · 0 comments
Labels

Comments

@bencottier
Copy link

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:

Weave.jl/src/run.jl

Lines 117 to 130 in 381de22

function get_cwd(doc, out_path)
return if out_path === :doc
dirname(doc.path)
elseif out_path === :pwd
pwd()
else
path, ext = splitext(out_path)
if isempty(ext) # directory given
path
else # file given
dirname(path)
end
end |> abspath
end

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.

@bencottier bencottier added the bug label Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant