Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 19, 2024
1 parent b8e93a9 commit 8e4fbc2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion WrightTools/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from . import _tree
from . import _units
from . import _wt5
from . import _wt5
1 change: 0 additions & 1 deletion WrightTools/cli/_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ def tree(path, internal_path, depth=9, verbose=False):
obj.print_tree(verbose=verbose, depth=depth)



if __name__ == "__main__":
cli()
27 changes: 14 additions & 13 deletions WrightTools/kit/_glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
from .._open import open


__all__ = ["describe_wt5", "filter_wt5s", "glob_handler", "glob_wt5s", "search_for_attrs",]
__all__ = [
"describe_wt5",
"filter_wt5s",
"glob_handler",
"glob_wt5s",
"search_for_attrs",
]


def describe_wt5(path: Union[str, PathLike]) -> dict:
Expand Down Expand Up @@ -62,12 +68,10 @@ def glob_handler(extension, folder=None, identifier=None, recursive=True) -> Lis


def search_for_attrs(
directory: Union[str, PathLike],
recursive=True,
**kwargs
) -> List[pathlib.Path]:
directory: Union[str, PathLike], recursive=True, **kwargs
) -> List[pathlib.Path]:
"""
Find wt5 file(s) by matching data attrs items.
Find wt5 file(s) by matching data attrs items.
Parameters
----------
Expand All @@ -84,7 +88,7 @@ def search_for_attrs(
-------
paths : list
list of pathlib.Path objects that match
Example
-------
To find a scan from scan parameters in the bluesky-cmds:
Expand All @@ -93,12 +97,8 @@ def search_for_attrs(
return filter_wt5s(glob_wt5s(directory, recursive), **kwargs)


def filter_wt5s(
paths:List[Union[str, PathLike]],
**kwargs
) -> List[Union[str, PathLike]]:
"""fillter wt5s by attrs
"""
def filter_wt5s(paths: List[Union[str, PathLike]], **kwargs) -> List[Union[str, PathLike]]:
"""fillter wt5s by attrs"""
return [p for p in filter(_gen_filter_by_attrs(**kwargs), paths)]


Expand All @@ -109,4 +109,5 @@ def fil(x):
return all([attrs[key] == kwargs[key] for key in kwargs])
else:
return False

return fil
4 changes: 2 additions & 2 deletions WrightTools/kit/_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# --- functions -----------------------------------------------------------------------------------


def get_path_matching(name:str) -> pathlib.Path:
def get_path_matching(name: str) -> pathlib.Path:
"""
Non-recursive search for path to the folder "name".
Searches the user directory, then looks up the cwd for a parent folder that matches.
Expand All @@ -38,6 +38,6 @@ def get_path_matching(name:str) -> pathlib.Path:
p = None
drive, *folders = pathlib.Path.cwd().parts
if name in folders:
p = pathlib.Path(drive).joinpath(*folders[:folders.index(name)+1])
p = pathlib.Path(drive).joinpath(*folders[: folders.index(name) + 1])
# TODO: something more robust to catch the rest of the cases?
return p

0 comments on commit 8e4fbc2

Please sign in to comment.