janito 3.14.2__py3-none-any.whl → 3.15.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. janito/platform_discovery.py +1 -8
  2. janito/plugins/tools/local/adapter.py +3 -2
  3. janito/plugins/tools/local/ask_user.py +111 -112
  4. janito/plugins/tools/local/copy_file.py +86 -87
  5. janito/plugins/tools/local/create_directory.py +111 -112
  6. janito/plugins/tools/local/create_file.py +0 -1
  7. janito/plugins/tools/local/delete_text_in_file.py +133 -134
  8. janito/plugins/tools/local/fetch_url.py +465 -466
  9. janito/plugins/tools/local/find_files.py +142 -143
  10. janito/plugins/tools/local/markdown_view.py +0 -1
  11. janito/plugins/tools/local/move_file.py +130 -131
  12. janito/plugins/tools/local/open_html_in_browser.py +50 -51
  13. janito/plugins/tools/local/open_url.py +36 -37
  14. janito/plugins/tools/local/python_code_run.py +171 -172
  15. janito/plugins/tools/local/python_command_run.py +170 -171
  16. janito/plugins/tools/local/python_file_run.py +171 -172
  17. janito/plugins/tools/local/read_chart.py +258 -259
  18. janito/plugins/tools/local/read_files.py +57 -58
  19. janito/plugins/tools/local/remove_directory.py +54 -55
  20. janito/plugins/tools/local/remove_file.py +57 -58
  21. janito/plugins/tools/local/replace_text_in_file.py +275 -276
  22. janito/plugins/tools/local/run_bash_command.py +182 -183
  23. janito/plugins/tools/local/run_powershell_command.py +217 -218
  24. janito/plugins/tools/local/show_image.py +0 -1
  25. janito/plugins/tools/local/show_image_grid.py +0 -1
  26. janito/plugins/tools/local/view_file.py +0 -1
  27. janito/providers/alibaba/provider.py +1 -1
  28. janito/tools/base.py +19 -12
  29. janito/tools/tool_base.py +122 -121
  30. janito/tools/tools_schema.py +104 -104
  31. {janito-3.14.2.dist-info → janito-3.15.0.dist-info}/METADATA +9 -29
  32. {janito-3.14.2.dist-info → janito-3.15.0.dist-info}/RECORD +36 -36
  33. {janito-3.14.2.dist-info → janito-3.15.0.dist-info}/WHEEL +0 -0
  34. {janito-3.14.2.dist-info → janito-3.15.0.dist-info}/entry_points.txt +0 -0
  35. {janito-3.14.2.dist-info → janito-3.15.0.dist-info}/licenses/LICENSE +0 -0
  36. {janito-3.14.2.dist-info → janito-3.15.0.dist-info}/top_level.txt +0 -0
@@ -1,55 +1,54 @@
1
- from janito.tools.tool_base import ToolBase, ToolPermissions
2
- from janito.report_events import ReportAction
3
- from janito.plugins.tools.local.adapter import register_local_tool
4
- from janito.tools.tool_utils import pluralize, display_path
5
- from janito.i18n import tr
6
- import shutil
7
- import os
8
- import zipfile
9
- from janito.tools.path_utils import expand_path
10
-
11
-
12
- @register_local_tool
13
- class RemoveDirectoryTool(ToolBase):
14
- """
15
- Remove a directory.
16
-
17
- Args:
18
- path (str): Path to the directory to remove.
19
- recursive (bool, optional): If True, remove non-empty directories recursively (with backup). If False, only remove empty directories. Defaults to False.
20
- Returns:
21
- str: Status message indicating result. Example:
22
- - "Directory removed: /path/to/dir"
23
- - "Error removing directory: <error message>"
24
- """
25
-
26
- permissions = ToolPermissions(write=True)
27
- tool_name = "remove_directory"
28
-
29
- def run(self, path: str, recursive: bool = False) -> str:
30
- path = expand_path(path)
31
- disp_path = display_path(path)
32
- self.report_action(
33
- tr("🗃️ Remove directory '{disp_path}' ...", disp_path=disp_path),
34
- ReportAction.DELETE,
35
- )
36
-
37
- try:
38
- if recursive:
39
-
40
- shutil.rmtree(path)
41
- else:
42
- os.rmdir(path)
43
- self.report_success(
44
- tr("✅ 1 {dir_word}", dir_word=pluralize("directory", 1)),
45
- ReportAction.DELETE,
46
- )
47
- msg = tr("Directory removed: {disp_path}", disp_path=disp_path)
48
-
49
- return msg
50
- except Exception as e:
51
- self.report_error(
52
- tr(" ❌ Error removing directory: {error}", error=e),
53
- ReportAction.DELETE,
54
- )
55
- return tr("Error removing directory: {error}", error=e)
1
+ from janito.tools.tool_base import ToolBase, ToolPermissions
2
+ from janito.report_events import ReportAction
3
+ from janito.plugins.tools.local.adapter import register_local_tool
4
+ from janito.tools.tool_utils import pluralize, display_path
5
+ from janito.i18n import tr
6
+ import shutil
7
+ import os
8
+ import zipfile
9
+ from janito.tools.path_utils import expand_path
10
+
11
+
12
+ @register_local_tool
13
+ class RemoveDirectoryTool(ToolBase):
14
+ """
15
+ Remove a directory.
16
+
17
+ Args:
18
+ path (str): Path to the directory to remove.
19
+ recursive (bool, optional): If True, remove non-empty directories recursively (with backup). If False, only remove empty directories. Defaults to False.
20
+ Returns:
21
+ str: Status message indicating result. Example:
22
+ - "Directory removed: /path/to/dir"
23
+ - "Error removing directory: <error message>"
24
+ """
25
+
26
+ permissions = ToolPermissions(write=True)
27
+
28
+ def run(self, path: str, recursive: bool = False) -> str:
29
+ path = expand_path(path)
30
+ disp_path = display_path(path)
31
+ self.report_action(
32
+ tr("🗃️ Remove directory '{disp_path}' ...", disp_path=disp_path),
33
+ ReportAction.DELETE,
34
+ )
35
+
36
+ try:
37
+ if recursive:
38
+
39
+ shutil.rmtree(path)
40
+ else:
41
+ os.rmdir(path)
42
+ self.report_success(
43
+ tr("✅ 1 {dir_word}", dir_word=pluralize("directory", 1)),
44
+ ReportAction.DELETE,
45
+ )
46
+ msg = tr("Directory removed: {disp_path}", disp_path=disp_path)
47
+
48
+ return msg
49
+ except Exception as e:
50
+ self.report_error(
51
+ tr(" ❌ Error removing directory: {error}", error=e),
52
+ ReportAction.DELETE,
53
+ )
54
+ return tr("Error removing directory: {error}", error=e)
@@ -1,58 +1,57 @@
1
- import os
2
- from janito.tools.path_utils import expand_path
3
- import shutil
4
- from janito.plugins.tools.local.adapter import register_local_tool
5
-
6
- from janito.tools.tool_utils import display_path
7
- from janito.tools.tool_base import ToolBase, ToolPermissions
8
- from janito.report_events import ReportAction
9
- from janito.i18n import tr
10
-
11
-
12
- @register_local_tool
13
- class RemoveFileTool(ToolBase):
14
- """
15
- Remove a file at the specified path.
16
-
17
- Args:
18
- path (str): Path to the file to remove.
19
- backup (bool, optional): Deprecated. Backups are no longer created. Flag ignored.
20
- Returns:
21
- str: Status message indicating the result. Example:
22
- - " Successfully removed the file at ..."
23
- - " Cannot remove file: ..."
24
- """
25
-
26
- permissions = ToolPermissions(write=True)
27
- tool_name = "remove_file"
28
-
29
- def run(self, path: str, backup: bool = False) -> str:
30
- path = expand_path(path)
31
- disp_path = display_path(path)
32
-
33
- # Report initial info about what is going to be removed
34
- self.report_action(
35
- tr("🗑️ Remove file '{disp_path}' ...", disp_path=disp_path),
36
- ReportAction.DELETE,
37
- )
38
- if not os.path.exists(path):
39
- self.report_error(tr("❌ File does not exist."), ReportAction.DELETE)
40
- return tr("❌ File does not exist.")
41
- if not os.path.isfile(path):
42
- self.report_error(tr("❌ Path is not a file."), ReportAction.DELETE)
43
- return tr("❌ Path is not a file.")
44
- try:
45
-
46
- os.remove(path)
47
- self.report_success(tr("✅ File removed"), ReportAction.DELETE)
48
- msg = tr(
49
- "✅ Successfully removed the file at '{disp_path}'.",
50
- disp_path=disp_path,
51
- )
52
-
53
- return msg
54
- except Exception as e:
55
- self.report_error(
56
- tr("❌ Error removing file: {error}", error=e), ReportAction.DELETE
57
- )
58
- return tr("❌ Error removing file: {error}", error=e)
1
+ import os
2
+ from janito.tools.path_utils import expand_path
3
+ import shutil
4
+ from janito.plugins.tools.local.adapter import register_local_tool
5
+
6
+ from janito.tools.tool_utils import display_path
7
+ from janito.tools.tool_base import ToolBase, ToolPermissions
8
+ from janito.report_events import ReportAction
9
+ from janito.i18n import tr
10
+
11
+
12
+ @register_local_tool
13
+ class RemoveFileTool(ToolBase):
14
+ """
15
+ Remove a file at the specified path.
16
+
17
+ Args:
18
+ path (str): Path to the file to remove.
19
+ backup (bool, optional): Deprecated. Backups are no longer created. Flag ignored.
20
+ Returns:
21
+ str: Status message indicating the result. Example:
22
+ - " Successfully removed the file at ..."
23
+ - " Cannot remove file: ..."
24
+ """
25
+
26
+ permissions = ToolPermissions(write=True)
27
+
28
+ def run(self, path: str, backup: bool = False) -> str:
29
+ path = expand_path(path)
30
+ disp_path = display_path(path)
31
+
32
+ # Report initial info about what is going to be removed
33
+ self.report_action(
34
+ tr("🗑️ Remove file '{disp_path}' ...", disp_path=disp_path),
35
+ ReportAction.DELETE,
36
+ )
37
+ if not os.path.exists(path):
38
+ self.report_error(tr("❌ File does not exist."), ReportAction.DELETE)
39
+ return tr("❌ File does not exist.")
40
+ if not os.path.isfile(path):
41
+ self.report_error(tr("❌ Path is not a file."), ReportAction.DELETE)
42
+ return tr("❌ Path is not a file.")
43
+ try:
44
+
45
+ os.remove(path)
46
+ self.report_success(tr("✅ File removed"), ReportAction.DELETE)
47
+ msg = tr(
48
+ "✅ Successfully removed the file at '{disp_path}'.",
49
+ disp_path=disp_path,
50
+ )
51
+
52
+ return msg
53
+ except Exception as e:
54
+ self.report_error(
55
+ tr("❌ Error removing file: {error}", error=e), ReportAction.DELETE
56
+ )
57
+ return tr("❌ Error removing file: {error}", error=e)