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

lazytree that takes either a file or a directory full of similar files #224

Closed
Yuan-Ru-Lin opened this issue Mar 14, 2023 · 2 comments
Closed

Comments

@Yuan-Ru-Lin
Copy link
Member

Yuan-Ru-Lin commented Mar 14, 2023

I propose a common API for creating a LazyTree from either a file and a directory full of similar files.

The implementation is quite simple:

using UnROOT

function lazytree(path::AbstractString, key::AbstractString)
    if isfile(path)
        LazyTree(path, key)
    elseif isdir(path)
        UnROOT.chaintrees(LazyTree(_path, key) for _path in readdir(path, join=true))
    else
        error("wrong path")
    end
end

Here is a demo:

julia> ;
shell> tree
.
├── file.root
└── dir
    ├── file1.root
    └── file2.root

1 directories, 3 files

shell>
julia> lazytree("file.root", "tree")  # will work
...
julia> lazytree("dir", "tree")  # will work
...
julia> lazytree("nonnexistent", "tree")  # will error
@Moelf
Copy link
Member

Moelf commented Mar 14, 2023

Because user can easily do this, we should leave it to the user, particularly, there's no guarantee when path is a directory, all files in that directory are .root files.

@Yuan-Ru-Lin
Copy link
Member Author

there's no guarantee when path is a directory, all files in that directory are .root files.

Good point. Let me close this then.

@Yuan-Ru-Lin Yuan-Ru-Lin closed this as not planned Won't fix, can't repro, duplicate, stale Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants