Skip to content

Commit

Permalink
fix view tool (#1092)
Browse files Browse the repository at this point in the history
  • Loading branch information
CTY-git authored Dec 13, 2024
1 parent c9b02b0 commit b693b28
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
25 changes: 16 additions & 9 deletions patchwork/common/tools/code_edit_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,22 @@ def __view(self, abs_path: Path, view_range):
content = "\n".join(lines[start - 1 : end])
return content
elif abs_path.is_dir():
result = []
for root, dirs, files in os.walk(abs_path):
level = root[len(str(abs_path)) :].count(os.sep)
if level <= 2:
for d in dirs:
result.append(d)
for f in files:
result.append(f)
return "\n".join(result)
directories = []
files = []
for file in abs_path.iterdir():
directories.append(file.name) if file.is_dir() else files.append(file.name)

rv = ""
if len(directories) > 0:
rv += "Directories: \n"
rv += '\n'.join(directories)
rv += "\n"

if len(files) > 0:
rv += "Files: \n"
rv += '\n'.join(files)

return rv

def __create(self, file_text, abs_path):
if abs_path.exists():
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "patchwork-cli"
version = "0.0.82"
version = "0.0.83"
description = ""
authors = ["patched.codes"]
license = "AGPL"
Expand Down

0 comments on commit b693b28

Please sign in to comment.