reqstool-python-decorators 0.0.1__tar.gz → 0.0.2__tar.gz

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.
Files changed (28) hide show
  1. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/PKG-INFO +2 -2
  2. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/docs/modules/ROOT/pages/usage.adoc +4 -5
  3. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/src/reqstool_python_decorators/processors/decorator_processor.py +19 -8
  4. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/tests/unit/reqstool_decorators/processors/test_processors.py +10 -12
  5. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/.github/dependabot.yml +0 -0
  6. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/.github/workflows/build.yml +0 -0
  7. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/.github/workflows/check_release.yml +0 -0
  8. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/.github/workflows/lint.yml +0 -0
  9. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/.github/workflows/publish_gh_pages.yml +0 -0
  10. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/.github/workflows/publish_pypi_prod.yml +0 -0
  11. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/.github/workflows/publish_pypi_test.yml +0 -0
  12. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/.gitignore +0 -0
  13. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/LICENSE +0 -0
  14. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/README.md +0 -0
  15. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/docs/antora-playbook.yml +0 -0
  16. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/docs/antora.yml +0 -0
  17. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/docs/modules/ROOT/nav.adoc +0 -0
  18. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/docs/modules/ROOT/pages/description.adoc +0 -0
  19. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/docs/modules/ROOT/pages/index.adoc +0 -0
  20. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/docs/modules/ROOT/pages/installation.adoc +0 -0
  21. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/docs/modules/ROOT/pages/licence.adoc +0 -0
  22. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/pyproject.toml +0 -0
  23. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/src/reqstool_python_decorators/__init__.py +0 -0
  24. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/src/reqstool_python_decorators/decorators/decorators.py +0 -0
  25. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/src/reqstool_python_decorators/processors/__init__.py +0 -0
  26. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/tests/resources/test_decorators/requirements_decorators.py +0 -0
  27. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/tests/resources/test_decorators/svc_decorators.py +0 -0
  28. {reqstool_python_decorators-0.0.1 → reqstool_python_decorators-0.0.2}/tests/unit/conftest.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: reqstool-python-decorators
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: Reqstool Python Decorators
5
5
  Project-URL: Source, https://github.com/Luftfartsverket/reqstool-python-decorators.git
6
6
  Author-email: LFV SYSDEV <sysdev@lfv.com>
@@ -42,17 +42,16 @@ def test_somefunction():
42
42
  Import processor:
43
43
 
44
44
  ```
45
- from reqstool_python_decorators.processors.decorator_processor import ProcessDecorator
45
+ from reqstool_python_decorators.processors.decorator_processor import DecoratorProcessor
46
46
  ```
47
47
 
48
48
  Main function to collect decorators data and generate yaml file:
49
49
 
50
50
  ```
51
- process_decorated_data(path_to_python_files)
51
+ process_decorated_data(path_to_python_files, output_file)
52
52
  ```
53
53
 
54
- Here `path_to_python_files` is the directories to search through to find decorated code.
54
+ `path_to_python_files` is the directories to search through to find decorated code.
55
55
 
56
- *Note:*
56
+ `output_file` is output file(path) the yaml file is stored to
57
57
 
58
- Yaml file is saved into the `/dist` folder, make sure the folder exists before running the `process_decorated_data` function.
@@ -18,7 +18,7 @@ class DECORATOR_TYPES(Enum):
18
18
  return f"from: {self.from_value}, to: {self.to_value}"
19
19
 
20
20
 
21
- class ProcessDecorator:
21
+ class DecoratorProcessor:
22
22
  """
23
23
  A class for collecting and processing Requirements and SVCs annotations on functions and classes in a directory.
24
24
 
@@ -30,11 +30,8 @@ class ProcessDecorator:
30
30
  """
31
31
 
32
32
  decorators_to_search = ["Requirements", "SVCs"]
33
- reqsvc_yaml_path = "dist/all_annotations.yml"
34
33
 
35
- yaml_language_server = (
36
- "# yaml-language-server: $schema=https://schemas.se/requirements-tool/v1/annotations.schema.json\n"
37
- )
34
+ yaml_language_server = "# yaml-language-server: $schema=https://raw.githubusercontent.com/Luftfartsverket/reqstool-client/main/src/reqstool/resources/schemas/v1/annotations.schema.json\n" # noqa: E501
38
35
 
39
36
  def __init__(self, *args, **kwargs):
40
37
  """
@@ -176,12 +173,24 @@ class ProcessDecorator:
176
173
 
177
174
  return formatted_data
178
175
 
179
- def process_decorated_data(self, path_to_python_files):
176
+ def create_dir_from_path(self, filepath: str):
177
+ """
178
+ Creates directory of provided filepath if it does not exists
179
+
180
+ Parameters:
181
+ - `filepath` (str): Filepath to check and create directory from.
182
+ """
183
+ directory = os.path.dirname(filepath)
184
+ if not os.path.exists(directory):
185
+ os.makedirs(directory)
186
+
187
+ def process_decorated_data(self, path_to_python_files, output_file="build/annotations.yml"):
180
188
  """
181
189
  "Main" function, runs all functions resulting in a yaml file containing decorated data.
182
190
 
183
191
  Parameters:
184
192
  - `path_to_python_files` (list): List of directories containing Python files.
193
+ - `output_file` (str): Set path for output file, defaults to build/annotations.yml
185
194
 
186
195
  This method takes a list of directories containing Python files, collects decorated data from these files,
187
196
  formats the collected data, and writes the formatted results to YAML file for Requirements and SVCs annotations.
@@ -191,6 +200,8 @@ class ProcessDecorator:
191
200
  python_files = self.find_python_files(directory=path)
192
201
  for file_path in python_files:
193
202
  self.get_functions_and_classes(file_path=file_path, decorator_names=self.decorators_to_search)
203
+
194
204
  formatted_reqsvc_data = self.format_results(results=self.req_svc_results)
195
- reqsvc_yaml_path = "dist/annotations.yml"
196
- self.write_to_yaml(output_file=reqsvc_yaml_path, formatted_data=formatted_reqsvc_data)
205
+
206
+ self.create_dir_from_path(output_file)
207
+ self.write_to_yaml(output_file=output_file, formatted_data=formatted_reqsvc_data)
@@ -1,20 +1,20 @@
1
1
  import pytest
2
- from src.reqstool_python_decorators.processors.decorator_processor import ProcessDecorator
2
+ from src.reqstool_python_decorators.processors.decorator_processor import DecoratorProcessor
3
3
  from ruamel.yaml import YAML
4
4
 
5
5
 
6
6
  @pytest.fixture
7
7
  def process_decorator_instance():
8
- return ProcessDecorator()
8
+ return DecoratorProcessor()
9
9
 
10
10
 
11
- def test_find_python_files(process_decorator_instance: ProcessDecorator, tmpdir):
11
+ def test_find_python_files(process_decorator_instance: DecoratorProcessor, tmpdir):
12
12
  tmpdir.join("pythonfile.py").write("content")
13
13
  result = process_decorator_instance.find_python_files(tmpdir)
14
14
  assert result == [str(tmpdir.join("pythonfile.py"))]
15
15
 
16
16
 
17
- def test_get_functions_and_classes(process_decorator_instance: ProcessDecorator, tmpdir):
17
+ def test_get_functions_and_classes(process_decorator_instance: DecoratorProcessor, tmpdir):
18
18
  file_path = str(tmpdir.join("test_file.py"))
19
19
  tmpdir.join("test_file.py").write('@SVCs("SVC_001")\nclass Test:\n pass')
20
20
  process_decorator_instance.get_functions_and_classes(file_path, ["SVCs"])
@@ -24,20 +24,18 @@ def test_get_functions_and_classes(process_decorator_instance: ProcessDecorator,
24
24
  assert process_decorator_instance.req_svc_results[0]["elementKind"] == "CLASS"
25
25
 
26
26
 
27
- def test_map_type_known_type(process_decorator_instance: ProcessDecorator):
27
+ def test_map_type_known_type(process_decorator_instance: DecoratorProcessor):
28
28
  result = process_decorator_instance.map_type("FUNCTION")
29
29
  assert result == "METHOD"
30
30
 
31
31
 
32
- def test_map_type_unknown_type(process_decorator_instance: ProcessDecorator):
32
+ def test_map_type_unknown_type(process_decorator_instance: DecoratorProcessor):
33
33
  result = process_decorator_instance.map_type("CLASS")
34
34
  assert result == "CLASS"
35
35
 
36
36
 
37
- def test_write_to_yaml(process_decorator_instance: ProcessDecorator, tmp_path):
38
- yaml_language_server = (
39
- "# yaml-language-server: $schema=https://schemas.se/requirements-tool/v1/annotations.schema.json"
40
- )
37
+ def test_write_to_yaml(process_decorator_instance: DecoratorProcessor, tmp_path):
38
+ yaml_language_server = "# yaml-language-server: $schema=https://raw.githubusercontent.com/Luftfartsverket/reqstool-client/main/src/reqstool/resources/schemas/v1/annotations.schema.json\n" # noqa: E501
41
39
 
42
40
  test_output_file = tmp_path / "test_output.yml"
43
41
  sample_formatted_data = """
@@ -59,7 +57,7 @@ def test_write_to_yaml(process_decorator_instance: ProcessDecorator, tmp_path):
59
57
  assert sample_formatted_data == loaded_data
60
58
 
61
59
 
62
- @pytest.mark.skip(reason="Test manually and check structure of the annotations.yml file generated in dist folder")
63
- def test_process_decorated_data(process_decorator_instance: ProcessDecorator):
60
+ @pytest.mark.skip(reason="Test manually and check structure of the annotations.yml file generated in build folder")
61
+ def test_process_decorated_data(process_decorator_instance: DecoratorProcessor):
64
62
  paths = ["tests"]
65
63
  process_decorator_instance.process_decorated_data(path_to_python_files=paths)