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.
- janito/platform_discovery.py +1 -8
- janito/plugins/tools/local/adapter.py +3 -2
- janito/plugins/tools/local/ask_user.py +111 -112
- janito/plugins/tools/local/copy_file.py +86 -87
- janito/plugins/tools/local/create_directory.py +111 -112
- janito/plugins/tools/local/create_file.py +0 -1
- janito/plugins/tools/local/delete_text_in_file.py +133 -134
- janito/plugins/tools/local/fetch_url.py +465 -466
- janito/plugins/tools/local/find_files.py +142 -143
- janito/plugins/tools/local/markdown_view.py +0 -1
- janito/plugins/tools/local/move_file.py +130 -131
- janito/plugins/tools/local/open_html_in_browser.py +50 -51
- janito/plugins/tools/local/open_url.py +36 -37
- janito/plugins/tools/local/python_code_run.py +171 -172
- janito/plugins/tools/local/python_command_run.py +170 -171
- janito/plugins/tools/local/python_file_run.py +171 -172
- janito/plugins/tools/local/read_chart.py +258 -259
- janito/plugins/tools/local/read_files.py +57 -58
- janito/plugins/tools/local/remove_directory.py +54 -55
- janito/plugins/tools/local/remove_file.py +57 -58
- janito/plugins/tools/local/replace_text_in_file.py +275 -276
- janito/plugins/tools/local/run_bash_command.py +182 -183
- janito/plugins/tools/local/run_powershell_command.py +217 -218
- janito/plugins/tools/local/show_image.py +0 -1
- janito/plugins/tools/local/show_image_grid.py +0 -1
- janito/plugins/tools/local/view_file.py +0 -1
- janito/providers/alibaba/provider.py +1 -1
- janito/tools/base.py +19 -12
- janito/tools/tool_base.py +122 -121
- janito/tools/tools_schema.py +104 -104
- {janito-3.14.2.dist-info → janito-3.15.0.dist-info}/METADATA +9 -29
- {janito-3.14.2.dist-info → janito-3.15.0.dist-info}/RECORD +36 -36
- {janito-3.14.2.dist-info → janito-3.15.0.dist-info}/WHEEL +0 -0
- {janito-3.14.2.dist-info → janito-3.15.0.dist-info}/entry_points.txt +0 -0
- {janito-3.14.2.dist-info → janito-3.15.0.dist-info}/licenses/LICENSE +0 -0
- {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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
)
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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)
|