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

fix: cannot input multiple files when using "add" or "merge-root" in the command line #80

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/hepconvert/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main() -> None:
@click.option(
"-f",
"--force",
default=False,
is_flag=True,
help="If True, overwrites destination file if it already exists.",
)
def parquet_to_root(
Expand All @@ -59,7 +59,7 @@ def parquet_to_root(
resize_factor=10.0,
compression="zlib",
compression_level=1,
force=False,
force,
):
"""
Convert Parquet file to ROOT file.
Expand Down Expand Up @@ -111,7 +111,7 @@ def parquet_to_root(
@click.option(
"-f",
"--force",
default=False,
is_flag=True,
help="If True, overwrites destination file if it already exists.",
)
def copy_root(
Expand All @@ -125,7 +125,7 @@ def copy_root(
cut=None,
expressions=None,
progress_bar=None,
force=False,
force,
title="",
field_name=lambda outer, inner: inner if outer == "" else outer + "_" + inner,
initial_basket_capacity=10,
Expand Down Expand Up @@ -164,11 +164,11 @@ def copy_root(

@main.command()
@click.argument("destination")
@click.argument("files")
@click.argument("files", nargs=-1)
@click.option(
"-f",
"--force",
default=False,
is_flag=True,
help="Overwrite destination file if it already exists",
)
@click.option("--progress-bar", default=None, type=bool, required=False)
Expand Down Expand Up @@ -203,7 +203,7 @@ def add(
files,
*,
progress_bar=False,
force=False,
force,
append=False,
compression="zlib",
compression_level=1,
Expand Down Expand Up @@ -232,7 +232,7 @@ def add(

@main.command()
@click.argument("destination")
@click.argument("files")
@click.argument("files", nargs=-1)
@click.option("--title", required=False, default="", help="Set title of new TTree.")
@click.option(
"--initial-basket-capacity",
Expand All @@ -257,7 +257,7 @@ def add(
@click.option("--cut", default=None, type=str or list, required=False)
@click.option("--expressions", default=None, type=str or list, required=False)
@click.option(
"--force", default=True, help="Overwrite destination file if it already exists"
"--force", is_flag=True, help="Overwrite destination file if it already exists"
)
@click.option("--append", default=False, help="Append histograms to an existing file")
@click.option(
Expand Down Expand Up @@ -293,7 +293,7 @@ def merge_root(
resize_factor=10.0,
counter_name=lambda counted: "n" + counted,
step_size="100 MB",
force=True,
force,
append=False,
compression="LZ4",
compression_level=1,
Expand Down Expand Up @@ -342,7 +342,7 @@ def merge_root(
@click.option(
"-f",
"--force",
default=False,
is_flag=True,
type=bool,
help="If a file already exists at specified path, it gets replaced",
)
Expand Down Expand Up @@ -503,7 +503,7 @@ def root_to_parquet(
parquet_extra_options=None,
storage_options=None,
tree=None,
force=False,
force,
step_size=100,
):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/hepconvert/histogram_adding.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def add_histograms(
),
)

if not isinstance(files, list):
if not isinstance(files, list) and not isinstance(files, tuple):
path = Path(files)
files = sorted(path.glob("**/*.root"))

Expand Down
2 changes: 1 addition & 1 deletion src/hepconvert/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def merge_root(
)
first = True

if not isinstance(files, list):
if not isinstance(files, list) and not isinstance(files, tuple):
path = Path(files)
files = sorted(path.glob("**/*.root"))

Expand Down
Loading