Skip to content

Commit

Permalink
change entry points
Browse files Browse the repository at this point in the history
  • Loading branch information
ddkohler committed Feb 17, 2024
1 parent 0de18ce commit b797ef7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
29 changes: 16 additions & 13 deletions WrightTools/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def load(path):
_interact(shell, path)


@cli.command(name="scan", help="scan a directory and survey the wt5 objects found.")
@cli.command(name="glob", help="Scan a directory and survey the wt5 objects found.")
@click.option(
"--directory", "-d", default=None, help="Directory to scan. Defaults to current directory."
)
Expand All @@ -56,25 +56,28 @@ def scan(directory=None, no_recursion=False):

table = Table(title=directory)
table.add_column("", justify="right") # index
table.add_column("path", max_width=60, no_wrap=True)
table.add_column("size (MB)", justify="center")
table.add_column("created", max_width=30)
table.add_column("name")
table.add_column("shape")
table.add_column("axes", max_width=50)
table.add_column("variables")
table.add_column("channels")
table.add_column("path", max_width=60, no_wrap=True, style="blue")
table.add_column("size (MB)", justify="center", style="blue")
table.add_column("created", max_width=30, style="blue")
table.add_column("name", style="blue")
table.add_column("shape", style="blue")
table.add_column("axes", max_width=50, style="blue")
table.add_column("variables", style="blue")
table.add_column("channels", style="blue")

update_title = lambda n: directory + f" ({n} wt5 file{'s' if n != 1 else None} found)"
paths = []

with Live(table) as live:
for i, path in enumerate(wt.kit.glob_wt5s(directory, not no_recursion)):
paths.append(path)
desc = wt.kit.describe_wt5(path)
desc["filesize"] = f"{os.path.getsize(path) / 1e6:.1f}"
desc["path"] = str(path.relative_to(directory))
row = [str(i)] + [
path = path.relative_to(directory)
print(path.parent)
desc["path"] = f"[link={path.parent}]{path.parent}[/link]" + r"\\" if str(path.parent) != "." else ""
desc["path"] += f"[bold]{path.name}[/bold]"
# desc["path"] = f"[link={str(path)}]{path}[/link]"
row = [f"{i}"] + [
str(desc[k])
for k in ["path", "filesize", "created", "name", "shape", "axes", "nvars", "nchan"]
]
Expand All @@ -93,7 +96,7 @@ def raise_sys_exit():
" ".join(
[
"Specify an index to load that entry.",
"Use 't' to rerender table.",
"Use `t` to rerender table.",
"Use no argument to exit.",
]
)
Expand Down
3 changes: 1 addition & 2 deletions WrightTools/kit/_glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@ def describe_wt5(path: Union[str, os.PathLike]) -> dict:

def glob_wt5s(directory: Union[str, os.PathLike], recursive=True):
"""find all wt5 files in a directory"""
pattern = "**/*.wt5" if recursive else "*.wt5"
print(pattern)
pattern = "**/*.wt5" if recursive else f"*.wt5"
return pathlib.Path(directory).glob(pattern)
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ def read(fname):
license="MIT",
url="http://wright.tools",
keywords="spectroscopy science multidimensional visualization",
entry_points={"console_scripts": ["wtools=WrightTools.__main__:cli"]},
entry_points={"console_scripts": [
"wt-tree=WrightTools.__main__:tree",
"wt5=WrightTools.__main__:wt5",
"wt-convert=WrightTools.__main__:convert"
]},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
Expand Down

0 comments on commit b797ef7

Please sign in to comment.