reqstool-python-decorators 0.1.0__py3-none-any.whl → 1.0.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.
- reqstool_python_decorators/decorators/decorators.py +6 -0
- reqstool_python_decorators/processors/decorator_processor.py +9 -0
- {reqstool_python_decorators-0.1.0.dist-info → reqstool_python_decorators-1.0.0.dist-info}/METADATA +1 -1
- {reqstool_python_decorators-0.1.0.dist-info → reqstool_python_decorators-1.0.0.dist-info}/RECORD +6 -6
- {reqstool_python_decorators-0.1.0.dist-info → reqstool_python_decorators-1.0.0.dist-info}/WHEEL +0 -0
- {reqstool_python_decorators-0.1.0.dist-info → reqstool_python_decorators-1.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -11,6 +11,12 @@ def Requirements[T: Callable](*requirements: str) -> Callable[[T], T]:
|
|
|
11
11
|
return decorator
|
|
12
12
|
|
|
13
13
|
|
|
14
|
+
# Tagged here rather than on Requirements: by the time SVCs is defined, Requirements
|
|
15
|
+
# is already bound in module scope, so it can reference it as a decorator. Requirements
|
|
16
|
+
# can't self-tag this way (its own name isn't bound yet at its own def statement), but
|
|
17
|
+
# both factories jointly implement DECORATORS_001 -- this tag location is just where
|
|
18
|
+
# that fact gets recorded.
|
|
19
|
+
@Requirements("DECORATORS_001")
|
|
14
20
|
def SVCs[T: Callable](*svc_ids: str) -> Callable[[T], T]:
|
|
15
21
|
def decorator(func: T) -> T:
|
|
16
22
|
func.svc_ids = svc_ids # type: ignore[attr-defined]
|
|
@@ -6,6 +6,8 @@ from typing import ReadOnly, TypedDict
|
|
|
6
6
|
from ruamel.yaml import YAML
|
|
7
7
|
import ast
|
|
8
8
|
|
|
9
|
+
from reqstool_python_decorators.decorators.decorators import Requirements
|
|
10
|
+
|
|
9
11
|
|
|
10
12
|
@unique
|
|
11
13
|
class DECORATOR_TYPES(Enum):
|
|
@@ -79,6 +81,7 @@ class DecoratorProcessor:
|
|
|
79
81
|
super().__init__(*args, **kwargs)
|
|
80
82
|
self.req_svc_results: Results = []
|
|
81
83
|
|
|
84
|
+
@Requirements("DECORATORS_002")
|
|
82
85
|
def find_python_files(self, directory: str | os.PathLike) -> list[str]:
|
|
83
86
|
"""
|
|
84
87
|
Find Python files in the given directory.
|
|
@@ -96,6 +99,7 @@ class DecoratorProcessor:
|
|
|
96
99
|
python_files.append(os.path.join(root, file))
|
|
97
100
|
return python_files
|
|
98
101
|
|
|
102
|
+
@Requirements("DECORATORS_002")
|
|
99
103
|
def get_functions_and_classes(self, file_path: str | os.PathLike, decorator_names: list[str]) -> None:
|
|
100
104
|
"""
|
|
101
105
|
Get information about functions and classes, if annotated with "Requirements" or "SVCs":
|
|
@@ -133,6 +137,7 @@ class DecoratorProcessor:
|
|
|
133
137
|
}
|
|
134
138
|
)
|
|
135
139
|
|
|
140
|
+
@Requirements("DECORATORS_003")
|
|
136
141
|
def write_to_yaml(self, output_file: str | os.PathLike, formatted_data) -> None:
|
|
137
142
|
"""
|
|
138
143
|
Write formatted data to a YAML file.
|
|
@@ -158,10 +163,12 @@ class DecoratorProcessor:
|
|
|
158
163
|
yaml_file.write(self.yaml_language_server)
|
|
159
164
|
yaml.dump(formatted_data, yaml_file)
|
|
160
165
|
|
|
166
|
+
@Requirements("DECORATORS_002")
|
|
161
167
|
def map_type(self, input_str) -> str:
|
|
162
168
|
mapping = {item.from_value: item.to_value for item in DECORATOR_TYPES}
|
|
163
169
|
return mapping.get(input_str, input_str)
|
|
164
170
|
|
|
171
|
+
@Requirements("DECORATORS_002")
|
|
165
172
|
def format_results(self, results: Results) -> FormattedData:
|
|
166
173
|
"""
|
|
167
174
|
Format the collected results into a structured data format for YAML.
|
|
@@ -201,6 +208,7 @@ class DecoratorProcessor:
|
|
|
201
208
|
|
|
202
209
|
return formatted_data
|
|
203
210
|
|
|
211
|
+
@Requirements("DECORATORS_003")
|
|
204
212
|
def create_dir_from_path(self, filepath: str | os.PathLike) -> None:
|
|
205
213
|
"""
|
|
206
214
|
Creates directory of provided filepath if it does not exists
|
|
@@ -212,6 +220,7 @@ class DecoratorProcessor:
|
|
|
212
220
|
if not os.path.exists(directory):
|
|
213
221
|
os.makedirs(directory)
|
|
214
222
|
|
|
223
|
+
@Requirements("DECORATORS_002", "DECORATORS_003")
|
|
215
224
|
def process_decorated_data(
|
|
216
225
|
self,
|
|
217
226
|
path_to_python_files: list[str | os.PathLike],
|
{reqstool_python_decorators-0.1.0.dist-info → reqstool_python_decorators-1.0.0.dist-info}/RECORD
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
reqstool_python_decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
reqstool_python_decorators/decorators/__init__.py,sha256=9xL1ExocYj8K05rdGyEKT9CLX7bgWbOG3hsvDhWWnFc,19
|
|
3
|
-
reqstool_python_decorators/decorators/decorators.py,sha256=
|
|
3
|
+
reqstool_python_decorators/decorators/decorators.py,sha256=UtlQmqt2QdnCYHu8s4C54gMjvNrp5zlzZYWF6haTYe8,876
|
|
4
4
|
reqstool_python_decorators/processors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
reqstool_python_decorators/processors/decorator_processor.py,sha256=
|
|
6
|
-
reqstool_python_decorators-
|
|
7
|
-
reqstool_python_decorators-
|
|
8
|
-
reqstool_python_decorators-
|
|
9
|
-
reqstool_python_decorators-
|
|
5
|
+
reqstool_python_decorators/processors/decorator_processor.py,sha256=UlBMMGP6eE2x7BL9TBZGciL2b7q2gkB0u4qAXtyWeh4,9759
|
|
6
|
+
reqstool_python_decorators-1.0.0.dist-info/METADATA,sha256=uCA98lWDueDoNCMDjtDFsLZ8gE3iFvSwEgtJ6kL_9ig,2805
|
|
7
|
+
reqstool_python_decorators-1.0.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
8
|
+
reqstool_python_decorators-1.0.0.dist-info/licenses/LICENSE,sha256=FVfPRmqjYUYTodYsh2C7Y70MWH64m0aWgTeIbqPj-P0,1060
|
|
9
|
+
reqstool_python_decorators-1.0.0.dist-info/RECORD,,
|
{reqstool_python_decorators-0.1.0.dist-info → reqstool_python_decorators-1.0.0.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|