ara-cli 0.1.9.57__py3-none-any.whl → 0.1.9.59__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.
Potentially problematic release.
This version of ara-cli might be problematic. Click here for more details.
- ara_cli/artefact_creator.py +5 -1
- ara_cli/artefact_renamer.py +25 -59
- ara_cli/tests/test_file_creator.py +3 -1
- ara_cli/version.py +1 -1
- {ara_cli-0.1.9.57.dist-info → ara_cli-0.1.9.59.dist-info}/METADATA +5 -5
- {ara_cli-0.1.9.57.dist-info → ara_cli-0.1.9.59.dist-info}/RECORD +9 -9
- {ara_cli-0.1.9.57.dist-info → ara_cli-0.1.9.59.dist-info}/WHEEL +1 -1
- {ara_cli-0.1.9.57.dist-info → ara_cli-0.1.9.59.dist-info}/entry_points.txt +0 -0
- {ara_cli-0.1.9.57.dist-info → ara_cli-0.1.9.59.dist-info}/top_level.txt +0 -0
ara_cli/artefact_creator.py
CHANGED
|
@@ -7,7 +7,7 @@ from ara_cli.artefact_models.artefact_model import Artefact
|
|
|
7
7
|
from ara_cli.artefact_models.artefact_templates import template_artefact_of_type
|
|
8
8
|
from ara_cli.artefact_fuzzy_search import suggest_close_name_matches
|
|
9
9
|
from pathlib import Path
|
|
10
|
-
from shutil import copyfile
|
|
10
|
+
from shutil import copyfile, rmtree
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class ArtefactCreator:
|
|
@@ -104,6 +104,9 @@ class ArtefactCreator:
|
|
|
104
104
|
file_exists = self.file_system.path.exists(file_path)
|
|
105
105
|
dir_exists = self.file_system.path.exists(dir_path)
|
|
106
106
|
|
|
107
|
+
if dir_exists and not os.listdir(dir_path):
|
|
108
|
+
dir_exists = False
|
|
109
|
+
|
|
107
110
|
if not self.handle_existing_files(file_exists, dir_exists):
|
|
108
111
|
return
|
|
109
112
|
|
|
@@ -116,6 +119,7 @@ class ArtefactCreator:
|
|
|
116
119
|
)
|
|
117
120
|
|
|
118
121
|
artefact_content = artefact.serialize()
|
|
122
|
+
rmtree(dir_path)
|
|
119
123
|
os.makedirs(dir_path, exist_ok=True)
|
|
120
124
|
with open(file_path, 'w') as artefact_file:
|
|
121
125
|
artefact_file.write(artefact_content)
|
ara_cli/artefact_renamer.py
CHANGED
|
@@ -2,10 +2,7 @@ import os
|
|
|
2
2
|
from functools import lru_cache
|
|
3
3
|
from ara_cli.classifier import Classifier
|
|
4
4
|
from ara_cli.artefact_link_updater import ArtefactLinkUpdater
|
|
5
|
-
from ara_cli.artefact_reader import ArtefactReader
|
|
6
|
-
from ara_cli.artefact_models.artefact_model import Contribution
|
|
7
5
|
from ara_cli.template_manager import DirectoryNavigator
|
|
8
|
-
from ara_cli.artefact_fuzzy_search import suggest_close_name_matches
|
|
9
6
|
import re
|
|
10
7
|
|
|
11
8
|
|
|
@@ -25,78 +22,47 @@ class ArtefactRenamer:
|
|
|
25
22
|
return re.compile(pattern)
|
|
26
23
|
|
|
27
24
|
def rename(self, old_name, new_name, classifier):
|
|
25
|
+
original_directory = self.navigate_to_target()
|
|
26
|
+
|
|
28
27
|
if not new_name:
|
|
29
28
|
raise ValueError("New name must be provided for renaming.")
|
|
29
|
+
|
|
30
30
|
if not Classifier.is_valid_classifier(classifier):
|
|
31
31
|
raise ValueError("Invalid classifier provided. Please provide a valid classifier.")
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
classified_artefacts = ArtefactReader.read_artefacts()
|
|
38
|
-
|
|
39
|
-
artefacts_by_current_classifier = classified_artefacts.get(classifier, [])
|
|
40
|
-
matching_artefacts = list(filter(lambda a: a.title == old_name, artefacts_by_current_classifier))
|
|
33
|
+
sub_directory = Classifier.get_sub_directory(classifier)
|
|
34
|
+
old_file_path = self.file_system.path.join(sub_directory, f"{old_name}.{classifier}")
|
|
35
|
+
new_file_path = self.file_system.path.join(sub_directory, f"{new_name}.{classifier}")
|
|
41
36
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
suggest_close_name_matches(old_name, all_artefact_names)
|
|
45
|
-
return
|
|
37
|
+
old_dir_path = self.file_system.path.join(sub_directory, f"{old_name}.data")
|
|
38
|
+
new_dir_path = self.file_system.path.join(sub_directory, f"{new_name}.data")
|
|
46
39
|
|
|
47
|
-
|
|
40
|
+
old_dir_exists = self.file_system.path.exists(old_dir_path)
|
|
48
41
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
old_dir_path = f"{old_base_path}/{old_name}.data"
|
|
52
|
-
|
|
53
|
-
old_file_path_display = old_file_path.replace('./', 'ara/')
|
|
54
|
-
old_dir_path_display = old_dir_path.replace('./', 'ara/')
|
|
55
|
-
|
|
56
|
-
old_dir_exists = fs.path.exists(old_dir_path)
|
|
57
|
-
|
|
58
|
-
if not fs.path.exists(old_file_path):
|
|
42
|
+
# Check if the original file exists
|
|
43
|
+
if not self.file_system.path.exists(old_file_path):
|
|
59
44
|
raise FileNotFoundError(f"The file {old_file_path} does not exist.")
|
|
60
45
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
classifier=classifier,
|
|
64
|
-
classified_artefacts=classified_artefacts
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
matching_artefact.title = new_name
|
|
68
|
-
new_file_path = matching_artefact.file_path
|
|
69
|
-
new_base_path = fs.path.dirname(new_file_path)
|
|
70
|
-
new_dir_path = f"{new_base_path}/{new_name}.data"
|
|
71
|
-
if fs.path.exists(new_file_path):
|
|
46
|
+
# Check if the new file name and directory already exist
|
|
47
|
+
if self.file_system.path.exists(new_file_path):
|
|
72
48
|
raise FileExistsError(f"The new file name {new_file_path} already exists.")
|
|
73
|
-
if
|
|
49
|
+
if self.file_system.path.exists(new_dir_path):
|
|
74
50
|
raise FileExistsError(f"The new directory name {new_dir_path} already exists.")
|
|
75
51
|
|
|
76
|
-
|
|
77
|
-
|
|
52
|
+
# Perform the renaming of the file and directory
|
|
53
|
+
self.file_system.rename(old_file_path, new_file_path)
|
|
54
|
+
print(f"Renamed file: ara/{old_file_path} to ara/{new_file_path}")
|
|
55
|
+
if old_dir_exists:
|
|
56
|
+
self.file_system.rename(old_dir_path, new_dir_path)
|
|
57
|
+
print(f"Renamed directory: ara/{old_dir_path} to ara/{new_dir_path}")
|
|
78
58
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
file.write(serialized_artefact)
|
|
82
|
-
fs.remove(old_file_path)
|
|
59
|
+
# Update the title within the artefact file
|
|
60
|
+
self._update_title_in_artefact(new_file_path, new_name, classifier)
|
|
83
61
|
|
|
84
|
-
|
|
62
|
+
# Update links in related artefact files
|
|
63
|
+
self.link_updater.update_links_in_related_artefacts(old_name, new_name)
|
|
85
64
|
|
|
86
|
-
|
|
87
|
-
fs.rename(old_dir_path, new_dir_path)
|
|
88
|
-
print(f"Renamed directory: {old_dir_path_display} to {new_dir_path_display}")
|
|
89
|
-
|
|
90
|
-
for children in children_by_classifier.values():
|
|
91
|
-
for child in children:
|
|
92
|
-
contribution = child.contribution
|
|
93
|
-
contribution.artefact_name = new_name
|
|
94
|
-
child.contribution = contribution
|
|
95
|
-
serialized_artefact = child.serialize()
|
|
96
|
-
with open(child.file_path, 'w') as file:
|
|
97
|
-
file.write(serialized_artefact)
|
|
98
|
-
|
|
99
|
-
fs.chdir(original_directory)
|
|
65
|
+
os.chdir(original_directory)
|
|
100
66
|
|
|
101
67
|
def _update_title_in_artefact(self, artefact_path, new_title, classifier):
|
|
102
68
|
# Format the new title: replace underscores with spaces
|
|
@@ -25,7 +25,8 @@ def test_run_with_invalid_classifier_prints_error_message(capfd):
|
|
|
25
25
|
|
|
26
26
|
@patch("ara_cli.artefact_creator.input", return_value="n")
|
|
27
27
|
@patch("ara_cli.artefact_creator.os.path.exists", return_value=True)
|
|
28
|
-
|
|
28
|
+
@patch("ara_cli.artefact_creator.os.listdir", return_value=["data_folder_content"])
|
|
29
|
+
def test_run_with_existing_file_does_not_overwrite(mock_input, mock_exists, mock_list, capfd):
|
|
29
30
|
fc = ArtefactCreator()
|
|
30
31
|
fc.run("filename", "vision")
|
|
31
32
|
|
|
@@ -42,6 +43,7 @@ def test_create_artefact_exploration_success():
|
|
|
42
43
|
creator.create_artefact_prompt_files("./dest", "./source", "sample")
|
|
43
44
|
|
|
44
45
|
|
|
46
|
+
|
|
45
47
|
def test_create_artefact_exploration_source_not_found():
|
|
46
48
|
creator = ArtefactCreator()
|
|
47
49
|
|
ara_cli/version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# version.py
|
|
2
|
-
__version__ = "0.1.9.
|
|
2
|
+
__version__ = "0.1.9.59" # fith parameter like .0 for local install test purposes only. official numbers should be 4 digit numbers
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name:
|
|
3
|
-
Version: 0.1.9.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ara_cli
|
|
3
|
+
Version: 0.1.9.59
|
|
4
4
|
Requires-Dist: litellm
|
|
5
5
|
Requires-Dist: llama-index
|
|
6
6
|
Requires-Dist: llama-index-llms-openai
|
|
@@ -10,6 +10,6 @@ Requires-Dist: markdown-it-py
|
|
|
10
10
|
Requires-Dist: json-repair
|
|
11
11
|
Requires-Dist: argparse
|
|
12
12
|
Requires-Dist: argcomplete
|
|
13
|
-
Requires-Dist: cmd2
|
|
13
|
+
Requires-Dist: cmd2>=2.5
|
|
14
14
|
Requires-Dist: pydantic
|
|
15
|
-
|
|
15
|
+
Dynamic: requires-dist
|
|
@@ -4,13 +4,13 @@ ara_cli/analyse_artefacts.py,sha256=JwA2zxkCy8vNOHoU9f3TICJesXRRXndHi2hT5m_uQ8Q,
|
|
|
4
4
|
ara_cli/ara_command_action.py,sha256=OsmNJ9XHVMPveVO0kxlYNU5vR16bX9Sn7mGKaOieZqg,18925
|
|
5
5
|
ara_cli/ara_command_parser.py,sha256=HluFJimQbxS_yuZ2IzLcsfUPrmIJbKJB71YvsGiUXQE,16883
|
|
6
6
|
ara_cli/ara_config.py,sha256=_Arkr-b9XnrNHbBlFKb9tAo3OmdP4ZZiWvbY9m6Sbo0,4178
|
|
7
|
-
ara_cli/artefact_creator.py,sha256=
|
|
7
|
+
ara_cli/artefact_creator.py,sha256=7d4iuh2sx73gy7MRZ_zzfN7P1Mt9KuGGWTY0Q4O5pPY,6139
|
|
8
8
|
ara_cli/artefact_deleter.py,sha256=Co4wwCH3yW8H9NrOq7_2p5571EeHr0TsfE-H8KqoOfY,1900
|
|
9
9
|
ara_cli/artefact_fuzzy_search.py,sha256=XAvoiRafd1u21uKbX5-bow7hdq7uiLLy1KtxHNAFbCk,1337
|
|
10
10
|
ara_cli/artefact_link_updater.py,sha256=itMS_Z64jE8bBly9WA01z8PqkBeNW6ntTO7ryMeCTRg,3703
|
|
11
11
|
ara_cli/artefact_lister.py,sha256=jhk4n4eqp7hDIq07q43QzS7-36BM3OfZ4EABxCeOGcw,4764
|
|
12
12
|
ara_cli/artefact_reader.py,sha256=qNaMPWShmWtDU5LLdh9efFB27djI4NAoq6zEFwdTd38,6983
|
|
13
|
-
ara_cli/artefact_renamer.py,sha256=
|
|
13
|
+
ara_cli/artefact_renamer.py,sha256=loIn1DF9kVnjhH7wP1v5qUvt3s0uKeWXuQPrHXenQGE,4025
|
|
14
14
|
ara_cli/artefact_scan.py,sha256=DgFGv4hnbCjYdIgPA2PbAuGDWg1q2fCjtIqxGs57b9w,1762
|
|
15
15
|
ara_cli/chat.py,sha256=7xTtPEDk052_wmIzoti7GavEJ1vpRxe5c084WQ1C7dg,28617
|
|
16
16
|
ara_cli/classifier.py,sha256=zWskj7rBYdqYBGjksBm46iTgVU5IIf2PZsJr4qeiwVU,1878
|
|
@@ -31,7 +31,7 @@ ara_cli/run_file_lister.py,sha256=XbrrDTJXp1LFGx9Lv91SNsEHZPP-PyEMBF_P4btjbDA,23
|
|
|
31
31
|
ara_cli/tag_extractor.py,sha256=R5T103Y60NppYifKV7b8KoI5kE1M66fULz6f_Fdc9VU,1081
|
|
32
32
|
ara_cli/template_manager.py,sha256=YXPj2jGNDb-diIHFEK_vGJ-ZucodnXSGAPofKTnOofI,6633
|
|
33
33
|
ara_cli/update_config_prompt.py,sha256=PZgNIN3dTw6p80GyX8Sp5apkAhSoykwnkEbHo3IOkUo,4571
|
|
34
|
-
ara_cli/version.py,sha256=
|
|
34
|
+
ara_cli/version.py,sha256=96UGMMnHR8CYMHP9Ai6qBVKbtLO4hpk3ZjYQaSuTzhc,146
|
|
35
35
|
ara_cli/artefact_models/artefact_load.py,sha256=dNcwZDW2Dk0bts9YnPZ0ESmWD2NbsLIvl4Z-qQeGmTQ,401
|
|
36
36
|
ara_cli/artefact_models/artefact_mapping.py,sha256=8aD0spBjkJ8toMAmFawc6UTUxB6-tEEViZXv2I-r88Q,1874
|
|
37
37
|
ara_cli/artefact_models/artefact_model.py,sha256=vV-Hhtl6DwVt7qcFTnxxr_WqyTZnKtkFU-nryVnTbUg,14853
|
|
@@ -142,14 +142,14 @@ ara_cli/tests/test_chat.py,sha256=V75baLk2ZFz5WDSFTlvdbmMb6Dm7o12xoFEulmMgMDI,46
|
|
|
142
142
|
ara_cli/tests/test_classifier.py,sha256=grYGPksydNdPsaEBQxYHZTuTdcJWz7VQtikCKA6BNaQ,1920
|
|
143
143
|
ara_cli/tests/test_directory_navigator.py,sha256=7G0MVrBbtBvbrFUpL0zb_9EkEWi1dulWuHsrQxMJxDY,140
|
|
144
144
|
ara_cli/tests/test_file_classifier.py,sha256=6OYM-lYVYjxq4Qwl8U1btv_FYJhc5t3rKjYr2CXZ4uI,10069
|
|
145
|
-
ara_cli/tests/test_file_creator.py,sha256=
|
|
145
|
+
ara_cli/tests/test_file_creator.py,sha256=G257M1duenDrgLCSql3wVWNuzcxyQqLQDybfbxiGYN0,2100
|
|
146
146
|
ara_cli/tests/test_file_lister.py,sha256=f6B_vIv-wAulKH2ZGgNg4SG79XqGGbfwoIvZlbEnYyM,4306
|
|
147
147
|
ara_cli/tests/test_list_filter.py,sha256=gSRKirTtFuhRS3QlFHqWl89WvCvAdVEnFsCWTYmgB2o,7928
|
|
148
148
|
ara_cli/tests/test_tag_extractor.py,sha256=n2xNApbDciqKO3QuaveEWSPXU1PCUa_EhxlZMrukONw,2074
|
|
149
149
|
ara_cli/tests/test_template_manager.py,sha256=bRxka6cxHsCAOvXjfG8MrVO8qSZXhxW01tnph80UtNk,3143
|
|
150
150
|
ara_cli/tests/test_update_config_prompt.py,sha256=vSsLvc18HZdVjVM93qXWVbJt752xTLL6VGjSVCrPufk,6729
|
|
151
|
-
ara_cli-0.1.9.
|
|
152
|
-
ara_cli-0.1.9.
|
|
153
|
-
ara_cli-0.1.9.
|
|
154
|
-
ara_cli-0.1.9.
|
|
155
|
-
ara_cli-0.1.9.
|
|
151
|
+
ara_cli-0.1.9.59.dist-info/METADATA,sha256=_L6D_eKlZKaC4Ltua2K2WPQr3Y0sZeJue6AdNtLtRm0,388
|
|
152
|
+
ara_cli-0.1.9.59.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
153
|
+
ara_cli-0.1.9.59.dist-info/entry_points.txt,sha256=v4h7MzysTgSIDYfEo3oj4Kz_8lzsRa3hq-KJHEcLVX8,45
|
|
154
|
+
ara_cli-0.1.9.59.dist-info/top_level.txt,sha256=zzee_PwFmKqfBi9XgIunP6xy2S4TIt593CLLxenNaAE,8
|
|
155
|
+
ara_cli-0.1.9.59.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|