ara-cli 0.1.10.5__py3-none-any.whl → 0.1.14.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.
- ara_cli/__init__.py +51 -6
- ara_cli/__main__.py +87 -75
- ara_cli/ara_command_action.py +189 -101
- ara_cli/ara_config.py +187 -128
- ara_cli/ara_subcommands/common.py +2 -2
- ara_cli/ara_subcommands/config.py +221 -0
- ara_cli/ara_subcommands/convert.py +107 -0
- ara_cli/ara_subcommands/fetch.py +41 -0
- ara_cli/ara_subcommands/fetch_agents.py +22 -0
- ara_cli/ara_subcommands/fetch_scripts.py +19 -0
- ara_cli/ara_subcommands/fetch_templates.py +15 -10
- ara_cli/ara_subcommands/list.py +97 -23
- ara_cli/ara_subcommands/prompt.py +266 -106
- ara_cli/artefact_autofix.py +117 -64
- ara_cli/artefact_converter.py +355 -0
- ara_cli/artefact_creator.py +41 -17
- ara_cli/artefact_lister.py +3 -3
- ara_cli/artefact_models/artefact_model.py +1 -1
- ara_cli/artefact_models/artefact_templates.py +0 -9
- ara_cli/artefact_models/feature_artefact_model.py +8 -8
- ara_cli/artefact_reader.py +62 -43
- ara_cli/artefact_scan.py +39 -17
- ara_cli/chat.py +300 -71
- ara_cli/chat_agent/__init__.py +0 -0
- ara_cli/chat_agent/agent_process_manager.py +155 -0
- ara_cli/chat_script_runner/__init__.py +0 -0
- ara_cli/chat_script_runner/script_completer.py +23 -0
- ara_cli/chat_script_runner/script_finder.py +41 -0
- ara_cli/chat_script_runner/script_lister.py +36 -0
- ara_cli/chat_script_runner/script_runner.py +36 -0
- ara_cli/chat_web_search/__init__.py +0 -0
- ara_cli/chat_web_search/web_search.py +263 -0
- ara_cli/children_contribution_updater.py +737 -0
- ara_cli/classifier.py +34 -0
- ara_cli/commands/agent_run_command.py +98 -0
- ara_cli/commands/fetch_agents_command.py +106 -0
- ara_cli/commands/fetch_scripts_command.py +43 -0
- ara_cli/commands/fetch_templates_command.py +39 -0
- ara_cli/commands/fetch_templates_commands.py +39 -0
- ara_cli/commands/list_agents_command.py +39 -0
- ara_cli/commands/load_command.py +4 -3
- ara_cli/commands/load_image_command.py +1 -1
- ara_cli/commands/read_command.py +23 -27
- ara_cli/completers.py +95 -35
- ara_cli/constants.py +2 -0
- ara_cli/directory_navigator.py +37 -4
- ara_cli/error_handler.py +26 -11
- ara_cli/file_loaders/document_reader.py +0 -178
- ara_cli/file_loaders/factories/__init__.py +0 -0
- ara_cli/file_loaders/factories/document_reader_factory.py +32 -0
- ara_cli/file_loaders/factories/file_loader_factory.py +27 -0
- ara_cli/file_loaders/file_loader.py +1 -30
- ara_cli/file_loaders/loaders/__init__.py +0 -0
- ara_cli/file_loaders/{document_file_loader.py → loaders/document_file_loader.py} +1 -1
- ara_cli/file_loaders/loaders/text_file_loader.py +47 -0
- ara_cli/file_loaders/readers/__init__.py +0 -0
- ara_cli/file_loaders/readers/docx_reader.py +49 -0
- ara_cli/file_loaders/readers/excel_reader.py +27 -0
- ara_cli/file_loaders/{markdown_reader.py → readers/markdown_reader.py} +1 -1
- ara_cli/file_loaders/readers/odt_reader.py +59 -0
- ara_cli/file_loaders/readers/pdf_reader.py +54 -0
- ara_cli/file_loaders/readers/pptx_reader.py +104 -0
- ara_cli/file_loaders/tools/__init__.py +0 -0
- ara_cli/llm_utils.py +58 -0
- ara_cli/output_suppressor.py +53 -0
- ara_cli/prompt_chat.py +20 -4
- ara_cli/prompt_extractor.py +47 -32
- ara_cli/prompt_handler.py +123 -17
- ara_cli/tag_extractor.py +8 -7
- ara_cli/template_loader.py +2 -1
- ara_cli/template_manager.py +52 -21
- ara_cli/templates/global-scripts/hello_global.py +1 -0
- ara_cli/templates/prompt-modules/commands/add_scenarios_for_new_behaviour.feature_creation_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/align_feature_with_implementation_changes.interview_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/analyze_codebase_and_plan_tasks.interview_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/choose_best_parent_artefact.interview_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/create_tasks_from_artefact_content.interview_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/create_tests_for_uncovered_modules.test_generation_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/derive_features_from_video_description.feature_creation_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/describe_agent_capabilities.agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/empty.commands.md +2 -12
- ara_cli/templates/prompt-modules/commands/execute_scoped_todos_in_task.interview_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/explain_single_file_purpose.interview_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/extract_file_information_bullets.interview_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/extract_general.commands.md +12 -0
- ara_cli/templates/prompt-modules/commands/extract_markdown.commands.md +11 -0
- ara_cli/templates/prompt-modules/commands/extract_python.commands.md +13 -0
- ara_cli/templates/prompt-modules/commands/feature_add_or_modifiy_specified_behavior.commands.md +36 -0
- ara_cli/templates/prompt-modules/commands/feature_generate_initial_specified_bevahior.commands.md +53 -0
- ara_cli/templates/prompt-modules/commands/fix_failing_behave_step_definitions.interview_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/fix_failing_pytest_tests.interview_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/general_instruction_policy.commands.md +47 -0
- ara_cli/templates/prompt-modules/commands/generate_and_fix_pytest_tests.test_generation_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/prompt_template_tech_stack_transformer.commands.md +95 -0
- ara_cli/templates/prompt-modules/commands/python_bug_fixing_code.commands.md +34 -0
- ara_cli/templates/prompt-modules/commands/python_generate_code.commands.md +27 -0
- ara_cli/templates/prompt-modules/commands/python_refactoring_code.commands.md +39 -0
- ara_cli/templates/prompt-modules/commands/python_step_definitions_generation_and_fixing.commands.md +40 -0
- ara_cli/templates/prompt-modules/commands/python_unittest_generation_and_fixing.commands.md +48 -0
- ara_cli/templates/prompt-modules/commands/suggest_next_story_child_tasks.interview_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/summarize_or_transcribe_media.interview_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/update_feature_to_match_implementation.feature_creation_agent.commands.md +1 -0
- ara_cli/templates/prompt-modules/commands/update_user_story_with_requirements.interview_agent.commands.md +1 -0
- ara_cli/version.py +1 -1
- {ara_cli-0.1.10.5.dist-info → ara_cli-0.1.14.0.dist-info}/METADATA +49 -11
- ara_cli-0.1.14.0.dist-info/RECORD +253 -0
- {ara_cli-0.1.10.5.dist-info → ara_cli-0.1.14.0.dist-info}/WHEEL +1 -1
- tests/test_ara_command_action.py +31 -19
- tests/test_ara_config.py +177 -90
- tests/test_artefact_autofix.py +170 -97
- tests/test_artefact_autofix_integration.py +495 -0
- tests/test_artefact_converter.py +312 -0
- tests/test_artefact_extraction.py +564 -0
- tests/test_artefact_lister.py +11 -8
- tests/test_chat.py +166 -130
- tests/test_chat_givens_images.py +603 -0
- tests/test_chat_script_runner.py +454 -0
- tests/test_children_contribution_updater.py +98 -0
- tests/test_document_loader_office.py +267 -0
- tests/test_llm_utils.py +164 -0
- tests/test_prompt_chat.py +343 -0
- tests/test_prompt_extractor.py +683 -0
- tests/test_prompt_handler.py +416 -214
- tests/test_setup_default_chat_prompt_mode.py +198 -0
- tests/test_tag_extractor.py +95 -49
- tests/test_web_search.py +467 -0
- ara_cli/file_loaders/document_readers.py +0 -233
- ara_cli/file_loaders/file_loaders.py +0 -123
- ara_cli/file_loaders/text_file_loader.py +0 -187
- ara_cli/templates/prompt-modules/blueprints/complete_pytest_unittest.blueprint.md +0 -27
- ara_cli/templates/prompt-modules/blueprints/pytest_unittest_prompt.blueprint.md +0 -32
- ara_cli/templates/prompt-modules/blueprints/task_todo_list_implement_feature_BDD_way.blueprint.md +0 -30
- ara_cli/templates/prompt-modules/commands/artefact_classification.commands.md +0 -9
- ara_cli/templates/prompt-modules/commands/artefact_extension.commands.md +0 -17
- ara_cli/templates/prompt-modules/commands/artefact_formulation.commands.md +0 -14
- ara_cli/templates/prompt-modules/commands/behave_step_generation.commands.md +0 -102
- ara_cli/templates/prompt-modules/commands/code_generation_complex.commands.md +0 -20
- ara_cli/templates/prompt-modules/commands/code_generation_simple.commands.md +0 -13
- ara_cli/templates/prompt-modules/commands/error_fixing.commands.md +0 -20
- ara_cli/templates/prompt-modules/commands/feature_file_update.commands.md +0 -18
- ara_cli/templates/prompt-modules/commands/feature_formulation.commands.md +0 -43
- ara_cli/templates/prompt-modules/commands/js_code_generation_simple.commands.md +0 -13
- ara_cli/templates/prompt-modules/commands/refactoring.commands.md +0 -15
- ara_cli/templates/prompt-modules/commands/refactoring_analysis.commands.md +0 -9
- ara_cli/templates/prompt-modules/commands/reverse_engineer_feature_file.commands.md +0 -15
- ara_cli/templates/prompt-modules/commands/reverse_engineer_program_flow.commands.md +0 -19
- ara_cli-0.1.10.5.dist-info/RECORD +0 -194
- /ara_cli/file_loaders/{binary_file_loader.py → loaders/binary_file_loader.py} +0 -0
- /ara_cli/file_loaders/{image_processor.py → tools/image_processor.py} +0 -0
- {ara_cli-0.1.10.5.dist-info → ara_cli-0.1.14.0.dist-info}/entry_points.txt +0 -0
- {ara_cli-0.1.10.5.dist-info → ara_cli-0.1.14.0.dist-info}/top_level.txt +0 -0
ara_cli/artefact_reader.py
CHANGED
|
@@ -3,20 +3,29 @@ from ara_cli.classifier import Classifier
|
|
|
3
3
|
from ara_cli.file_classifier import FileClassifier
|
|
4
4
|
from ara_cli.artefact_models.artefact_model import Artefact
|
|
5
5
|
from ara_cli.artefact_models.artefact_load import artefact_from_content
|
|
6
|
-
from ara_cli.artefact_fuzzy_search import
|
|
6
|
+
from ara_cli.artefact_fuzzy_search import (
|
|
7
|
+
suggest_close_name_matches_for_parent,
|
|
8
|
+
suggest_close_name_matches,
|
|
9
|
+
)
|
|
7
10
|
from typing import Dict, List
|
|
8
11
|
import os
|
|
9
12
|
import re
|
|
10
13
|
|
|
11
14
|
|
|
12
15
|
class ArtefactReader:
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
def __init__(self, file_system=None):
|
|
17
|
+
self.file_system = file_system or os
|
|
18
|
+
|
|
19
|
+
def read_artefact_data(
|
|
20
|
+
self, artefact_name, classifier, classified_file_info=None
|
|
21
|
+
) -> tuple[str, dict[str, str]]:
|
|
15
22
|
if not Classifier.is_valid_classifier(classifier):
|
|
16
|
-
raise ValueError(
|
|
23
|
+
raise ValueError(
|
|
24
|
+
"Invalid classifier provided. Please provide a valid classifier."
|
|
25
|
+
)
|
|
17
26
|
|
|
18
27
|
if not classified_file_info:
|
|
19
|
-
file_classifier = FileClassifier(
|
|
28
|
+
file_classifier = FileClassifier(self.file_system)
|
|
20
29
|
classified_file_info = file_classifier.classify_files()
|
|
21
30
|
artefact_info_of_classifier = classified_file_info.get(classifier, [])
|
|
22
31
|
|
|
@@ -24,21 +33,21 @@ class ArtefactReader:
|
|
|
24
33
|
file_path = artefact_info["file_path"]
|
|
25
34
|
artefact_title = artefact_info["title"]
|
|
26
35
|
if artefact_title == artefact_name:
|
|
27
|
-
with open(file_path,
|
|
36
|
+
with open(file_path, "r", encoding="utf-8") as file:
|
|
28
37
|
content = file.read()
|
|
29
38
|
return content, artefact_info
|
|
30
39
|
|
|
31
40
|
all_artefact_names = [info["title"] for info in artefact_info_of_classifier]
|
|
32
|
-
suggest_close_name_matches(
|
|
33
|
-
artefact_name,
|
|
34
|
-
all_artefact_names
|
|
35
|
-
)
|
|
41
|
+
suggest_close_name_matches(artefact_name, all_artefact_names)
|
|
36
42
|
|
|
37
43
|
return None, None
|
|
38
44
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
def read_artefact(
|
|
46
|
+
self, artefact_name, classifier, classified_file_info=None
|
|
47
|
+
) -> Artefact:
|
|
48
|
+
content, artefact_info = self.read_artefact_data(
|
|
49
|
+
artefact_name, classifier, classified_file_info
|
|
50
|
+
)
|
|
42
51
|
if not content or not artefact_info:
|
|
43
52
|
return None
|
|
44
53
|
file_path = artefact_info["file_path"]
|
|
@@ -49,9 +58,11 @@ class ArtefactReader:
|
|
|
49
58
|
@staticmethod
|
|
50
59
|
def extract_parent_tree(artefact_content):
|
|
51
60
|
artefact_titles = Classifier.artefact_titles()
|
|
52
|
-
title_segment =
|
|
61
|
+
title_segment = "|".join(artefact_titles)
|
|
53
62
|
|
|
54
|
-
regex_pattern =
|
|
63
|
+
regex_pattern = (
|
|
64
|
+
rf"(?:Contributes to|Illustrates)\s*:*\s*(.*)\s+({title_segment}).*"
|
|
65
|
+
)
|
|
55
66
|
regex = re.compile(regex_pattern)
|
|
56
67
|
match = re.search(regex, artefact_content)
|
|
57
68
|
if not match:
|
|
@@ -72,33 +83,40 @@ class ArtefactReader:
|
|
|
72
83
|
merged[key].extend(artefacts)
|
|
73
84
|
return dict(merged)
|
|
74
85
|
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
def read_artefacts(
|
|
87
|
+
self, classified_artefacts=None, tags=None
|
|
88
|
+
) -> Dict[str, List[Artefact]]:
|
|
77
89
|
|
|
78
90
|
if classified_artefacts is None:
|
|
79
|
-
file_classifier = FileClassifier(file_system)
|
|
91
|
+
file_classifier = FileClassifier(self.file_system)
|
|
80
92
|
classified_artefacts = file_classifier.classify_files()
|
|
81
93
|
|
|
82
|
-
artefacts = {artefact_type: []
|
|
83
|
-
for artefact_type in classified_artefacts.keys()}
|
|
94
|
+
artefacts = {artefact_type: [] for artefact_type in classified_artefacts.keys()}
|
|
84
95
|
for artefact_type, artefact_info_dicts in classified_artefacts.items():
|
|
85
96
|
for artefact_info in artefact_info_dicts:
|
|
86
97
|
title = artefact_info["title"]
|
|
87
98
|
try:
|
|
88
|
-
artefact =
|
|
99
|
+
artefact = self.read_artefact(
|
|
100
|
+
title, artefact_type, classified_artefacts
|
|
101
|
+
)
|
|
89
102
|
artefacts[artefact_type].append(artefact)
|
|
90
103
|
except Exception as e:
|
|
91
104
|
error_handler.report_error(e, f"reading {artefact_type} '{title}'")
|
|
92
105
|
continue
|
|
93
106
|
return artefacts
|
|
94
107
|
|
|
95
|
-
|
|
96
|
-
|
|
108
|
+
def find_children(
|
|
109
|
+
self,
|
|
110
|
+
artefact_name,
|
|
111
|
+
classifier,
|
|
112
|
+
artefacts_by_classifier=None,
|
|
113
|
+
classified_artefacts=None,
|
|
114
|
+
):
|
|
97
115
|
artefacts_by_classifier = artefacts_by_classifier or {}
|
|
98
116
|
filtered_artefacts = {k: [] for k in artefacts_by_classifier.keys()}
|
|
99
117
|
|
|
100
118
|
if classified_artefacts is None:
|
|
101
|
-
classified_artefacts =
|
|
119
|
+
classified_artefacts = self.read_artefacts()
|
|
102
120
|
|
|
103
121
|
for artefact_classifier, artefacts in classified_artefacts.items():
|
|
104
122
|
for artefact in artefacts:
|
|
@@ -112,38 +130,37 @@ class ArtefactReader:
|
|
|
112
130
|
def _process_artefact(artefact, artefact_name, classifier, filtered_artefacts):
|
|
113
131
|
if not isinstance(artefact, Artefact):
|
|
114
132
|
return
|
|
115
|
-
contribution = getattr(artefact,
|
|
133
|
+
contribution = getattr(artefact, "contribution", None)
|
|
116
134
|
if not contribution:
|
|
117
135
|
return
|
|
118
|
-
if getattr(contribution,
|
|
136
|
+
if getattr(contribution, "artefact_name", None) != artefact_name:
|
|
119
137
|
return
|
|
120
|
-
if getattr(contribution,
|
|
138
|
+
if getattr(contribution, "classifier", None) != classifier:
|
|
121
139
|
return
|
|
122
140
|
|
|
123
|
-
file_classifier = getattr(artefact,
|
|
141
|
+
file_classifier = getattr(artefact, "_file_path", "").split(".")[-1]
|
|
124
142
|
if file_classifier not in filtered_artefacts:
|
|
125
143
|
filtered_artefacts[file_classifier] = []
|
|
126
144
|
filtered_artefacts[file_classifier].append(artefact)
|
|
127
145
|
|
|
128
|
-
@staticmethod
|
|
129
146
|
def step_through_value_chain(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
147
|
+
self,
|
|
148
|
+
artefact_name,
|
|
149
|
+
classifier,
|
|
150
|
+
artefacts_by_classifier=None,
|
|
151
|
+
classified_artefacts: dict[str, list["Artefact"]] | None = None,
|
|
134
152
|
):
|
|
135
153
|
from ara_cli.artefact_models.artefact_load import artefact_from_content
|
|
136
154
|
|
|
137
155
|
artefacts_by_classifier = artefacts_by_classifier or {}
|
|
138
156
|
|
|
139
157
|
if classified_artefacts is None:
|
|
140
|
-
classified_artefacts =
|
|
158
|
+
classified_artefacts = self.read_artefacts()
|
|
141
159
|
|
|
142
160
|
ArtefactReader._ensure_classifier_key(classifier, artefacts_by_classifier)
|
|
143
161
|
|
|
144
162
|
artefact = ArtefactReader._find_artefact_by_name(
|
|
145
|
-
artefact_name,
|
|
146
|
-
classified_artefacts.get(classifier, [])
|
|
163
|
+
artefact_name, classified_artefacts.get(classifier, [])
|
|
147
164
|
)
|
|
148
165
|
|
|
149
166
|
if not artefact or artefact in artefacts_by_classifier[classifier]:
|
|
@@ -151,7 +168,7 @@ class ArtefactReader:
|
|
|
151
168
|
|
|
152
169
|
artefacts_by_classifier[classifier].append(artefact)
|
|
153
170
|
|
|
154
|
-
parent = getattr(artefact,
|
|
171
|
+
parent = getattr(artefact, "contribution", None)
|
|
155
172
|
if not ArtefactReader._has_valid_parent(parent):
|
|
156
173
|
return
|
|
157
174
|
|
|
@@ -168,11 +185,11 @@ class ArtefactReader:
|
|
|
168
185
|
print()
|
|
169
186
|
return
|
|
170
187
|
|
|
171
|
-
|
|
188
|
+
self.step_through_value_chain(
|
|
172
189
|
artefact_name=parent_name,
|
|
173
190
|
classifier=parent_classifier,
|
|
174
191
|
artefacts_by_classifier=artefacts_by_classifier,
|
|
175
|
-
classified_artefacts=classified_artefacts
|
|
192
|
+
classified_artefacts=classified_artefacts,
|
|
176
193
|
)
|
|
177
194
|
|
|
178
195
|
@staticmethod
|
|
@@ -186,13 +203,15 @@ class ArtefactReader:
|
|
|
186
203
|
|
|
187
204
|
@staticmethod
|
|
188
205
|
def _has_valid_parent(parent):
|
|
189
|
-
return
|
|
206
|
+
return (
|
|
207
|
+
parent
|
|
208
|
+
and getattr(parent, "artefact_name", None)
|
|
209
|
+
and getattr(parent, "classifier", None)
|
|
210
|
+
)
|
|
190
211
|
|
|
191
212
|
@staticmethod
|
|
192
213
|
def _suggest_parent_name_match(artefact_name, all_artefact_names, parent_name):
|
|
193
214
|
if parent_name is not None:
|
|
194
215
|
suggest_close_name_matches_for_parent(
|
|
195
|
-
artefact_name,
|
|
196
|
-
all_artefact_names,
|
|
197
|
-
parent_name
|
|
216
|
+
artefact_name, all_artefact_names, parent_name
|
|
198
217
|
)
|
ara_cli/artefact_scan.py
CHANGED
|
@@ -4,12 +4,16 @@ import os
|
|
|
4
4
|
|
|
5
5
|
def is_contribution_valid(contribution, classified_artefact_info) -> bool:
|
|
6
6
|
from ara_cli.artefact_fuzzy_search import extract_artefact_names_of_classifier
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
if (
|
|
9
|
+
not contribution
|
|
10
|
+
or not contribution.artefact_name
|
|
11
|
+
or not contribution.classifier
|
|
12
|
+
):
|
|
8
13
|
return True
|
|
9
14
|
|
|
10
15
|
all_artefact_names = extract_artefact_names_of_classifier(
|
|
11
|
-
classified_files=classified_artefact_info,
|
|
12
|
-
classifier=contribution.classifier
|
|
16
|
+
classified_files=classified_artefact_info, classifier=contribution.classifier
|
|
13
17
|
)
|
|
14
18
|
if contribution.artefact_name not in all_artefact_names:
|
|
15
19
|
return False
|
|
@@ -19,12 +23,18 @@ def is_contribution_valid(contribution, classified_artefact_info) -> bool:
|
|
|
19
23
|
def is_rule_valid(contribution, classified_artefact_info) -> bool:
|
|
20
24
|
from ara_cli.artefact_reader import ArtefactReader
|
|
21
25
|
|
|
22
|
-
if
|
|
26
|
+
if (
|
|
27
|
+
not contribution
|
|
28
|
+
or not contribution.artefact_name
|
|
29
|
+
or not contribution.classifier
|
|
30
|
+
):
|
|
23
31
|
return True
|
|
24
32
|
rule = contribution.rule
|
|
25
33
|
if not rule:
|
|
26
34
|
return True
|
|
27
|
-
parent = ArtefactReader.read_artefact(
|
|
35
|
+
parent = ArtefactReader().read_artefact(
|
|
36
|
+
contribution.artefact_name, contribution.classifier
|
|
37
|
+
)
|
|
28
38
|
if not parent:
|
|
29
39
|
return True
|
|
30
40
|
rules = parent.rules
|
|
@@ -33,20 +43,26 @@ def is_rule_valid(contribution, classified_artefact_info) -> bool:
|
|
|
33
43
|
return True
|
|
34
44
|
|
|
35
45
|
|
|
36
|
-
def check_contribution(
|
|
46
|
+
def check_contribution(
|
|
47
|
+
contribution, classified_artefact_info, file_path
|
|
48
|
+
) -> tuple[bool, str]:
|
|
37
49
|
if not contribution:
|
|
38
50
|
return True, None
|
|
39
51
|
|
|
40
52
|
if not is_contribution_valid(contribution, classified_artefact_info):
|
|
41
|
-
reason = (
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
reason = (
|
|
54
|
+
f"Invalid Contribution Reference: The contribution references "
|
|
55
|
+
f"'{contribution.classifier}' artefact '{contribution.artefact_name}' "
|
|
56
|
+
f"which does not exist."
|
|
57
|
+
)
|
|
44
58
|
return False, reason
|
|
45
59
|
|
|
46
60
|
if not is_rule_valid(contribution, classified_artefact_info):
|
|
47
|
-
reason = (
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
reason = (
|
|
62
|
+
f"Rule Mismatch: The contribution references "
|
|
63
|
+
f"rule '{contribution.rule}' which the parent "
|
|
64
|
+
f"{contribution.classifier} '{contribution.artefact_name}' does not have."
|
|
65
|
+
)
|
|
50
66
|
return False, reason
|
|
51
67
|
return True, None
|
|
52
68
|
|
|
@@ -73,13 +89,17 @@ def check_file(file_path, artefact_class, classified_artefact_info=None):
|
|
|
73
89
|
|
|
74
90
|
# Check title and file name matching
|
|
75
91
|
if artefact_instance.title != file_name_without_ext:
|
|
76
|
-
reason = (
|
|
77
|
-
|
|
92
|
+
reason = (
|
|
93
|
+
f"Filename-Title Mismatch: The file name '{file_name_without_ext}' "
|
|
94
|
+
f"does not match the artefact title '{artefact_instance.title}'."
|
|
95
|
+
)
|
|
78
96
|
return False, reason
|
|
79
97
|
|
|
80
98
|
contribution = artefact_instance.contribution
|
|
81
99
|
|
|
82
|
-
contribution_valid, reason = check_contribution(
|
|
100
|
+
contribution_valid, reason = check_contribution(
|
|
101
|
+
contribution, classified_artefact_info, file_path
|
|
102
|
+
)
|
|
83
103
|
if not contribution_valid:
|
|
84
104
|
return False, reason
|
|
85
105
|
|
|
@@ -100,7 +120,9 @@ def find_invalid_files(classified_artefact_info, classifier):
|
|
|
100
120
|
continue
|
|
101
121
|
if ".data" in artefact_info["file_path"]:
|
|
102
122
|
continue
|
|
103
|
-
is_valid, reason = check_file(
|
|
123
|
+
is_valid, reason = check_file(
|
|
124
|
+
artefact_info["file_path"], artefact_class, classified_artefact_info
|
|
125
|
+
)
|
|
104
126
|
if not is_valid:
|
|
105
127
|
invalid_files.append((artefact_info["file_path"], reason))
|
|
106
128
|
return invalid_files
|
|
@@ -122,4 +144,4 @@ def show_results(invalid_artefacts):
|
|
|
122
144
|
report.write("\n")
|
|
123
145
|
if not has_issues:
|
|
124
146
|
print("All files are good!")
|
|
125
|
-
report.write("No problems found.\n")
|
|
147
|
+
report.write("No problems found.\n")
|