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

update glob docstring #929

Closed
wants to merge 4 commits into from
Closed
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
20 changes: 14 additions & 6 deletions src/marvin/tools/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,27 @@ def ls(path: str) -> str:

def glob(pattern: str) -> list[str]:
"""
Returns a list of paths matching a valid glob pattern.
The pattern can include ** for recursive matching, such as
'~/path/to/root/**/*.py'
Returns a list of paths matching a valid glob pattern. The pattern can
include ** for recursive matching, such as '/path/**/dir/*.py'. Only simple
glob patterns are supported, compound queries like '/path/*.{py, md}' are
NOT supported.
"""
return glob_module.glob(pattern, recursive=True)


def concat(source_paths: list[str], dest_path: str, add_headers: bool = True) -> str:
"""
Concatenates the contents of multiple source files into a single
destination file. The result should be markdown. If add_headers is True, the
file path will be added as a header above the contents of each file.
Concatenates the contents of multiple source files into a single destination
file. The result should be markdown. If add_headers is True, the file path
will be added as a header above the contents of each file.

Note that source paths can include simple glob patterns, such as
'/path/**/dir/*.py'. Compound queries like '/path/*.{py, md}' are NOT
supported.
"""
# source_paths can include glob patterns
source_paths = [path for pattern in source_paths for path in glob(pattern)]

dest_path = _safe_create_file(dest_path)
with open(dest_path, "w") as dest_file:
for source_path in source_paths:
Expand Down
Loading