ara-cli 0.1.9.57__py3-none-any.whl → 0.1.9.58__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.
@@ -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
- fs = self.file_system
34
- original_directory = self.navigate_to_target()
35
- original_directory = fs.path.abspath(original_directory)
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
- if not matching_artefacts:
43
- all_artefact_names = [artefact.title for artefact in artefacts_by_current_classifier]
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
- matching_artefact = matching_artefacts[0]
40
+ old_dir_exists = self.file_system.path.exists(old_dir_path)
48
41
 
49
- old_file_path = matching_artefact.file_path
50
- old_base_path = fs.path.dirname(old_file_path)
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
- children_by_classifier = ArtefactReader.find_children(
62
- artefact_name=old_name,
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 fs.path.exists(new_dir_path):
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
- new_file_path_display = new_file_path.replace('./', 'ara/')
77
- new_dir_path_display = new_dir_path.replace('./', 'ara/')
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
- serialized_artefact = matching_artefact.serialize()
80
- with open(matching_artefact.file_path, 'w') as file:
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
- print(f"Renamed file: {old_file_path_display} to {new_file_path_display}")
62
+ # Update links in related artefact files
63
+ self.link_updater.update_links_in_related_artefacts(old_name, new_name)
85
64
 
86
- if old_dir_exists:
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
ara_cli/version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  # version.py
2
- __version__ = "0.1.9.57" # fith parameter like .0 for local install test purposes only. official numbers should be 4 digit numbers
2
+ __version__ = "0.1.9.58" # fith parameter like .0 for local install test purposes only. official numbers should be 4 digit numbers
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ara-cli
3
- Version: 0.1.9.57
3
+ Version: 0.1.9.58
4
4
  Requires-Dist: litellm
5
5
  Requires-Dist: llama-index
6
6
  Requires-Dist: llama-index-llms-openai
@@ -10,7 +10,7 @@ ara_cli/artefact_fuzzy_search.py,sha256=XAvoiRafd1u21uKbX5-bow7hdq7uiLLy1KtxHNAF
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=aJriqHdkeXAvHx1PuKOhpqgg9EBr7PMv6NK67CCasbU,5319
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=NgYOrYvT6ewQjO9blMaF-5PiscTJqlK0ahlRP7Xw_tI,146
34
+ ara_cli/version.py,sha256=qdSo9o1YwdXa0HfBW8B4HWfKm2lrHaX0bWf7t1Rum4c,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
@@ -148,8 +148,8 @@ ara_cli/tests/test_list_filter.py,sha256=gSRKirTtFuhRS3QlFHqWl89WvCvAdVEnFsCWTYm
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.57.dist-info/METADATA,sha256=PWvHyn9Eh2F65XzuO9mkqp8xgp_-SHCpxk6vrjK3VZQ,367
152
- ara_cli-0.1.9.57.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92
153
- ara_cli-0.1.9.57.dist-info/entry_points.txt,sha256=v4h7MzysTgSIDYfEo3oj4Kz_8lzsRa3hq-KJHEcLVX8,45
154
- ara_cli-0.1.9.57.dist-info/top_level.txt,sha256=zzee_PwFmKqfBi9XgIunP6xy2S4TIt593CLLxenNaAE,8
155
- ara_cli-0.1.9.57.dist-info/RECORD,,
151
+ ara_cli-0.1.9.58.dist-info/METADATA,sha256=c_8LXIyOHDd4PIFaHlL0x6C4CPg3dSAqvQg38xZ4YL4,367
152
+ ara_cli-0.1.9.58.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92
153
+ ara_cli-0.1.9.58.dist-info/entry_points.txt,sha256=v4h7MzysTgSIDYfEo3oj4Kz_8lzsRa3hq-KJHEcLVX8,45
154
+ ara_cli-0.1.9.58.dist-info/top_level.txt,sha256=zzee_PwFmKqfBi9XgIunP6xy2S4TIt593CLLxenNaAE,8
155
+ ara_cli-0.1.9.58.dist-info/RECORD,,