lupin-danquin 0.0.1.dev1__tar.gz → 0.0.1.dev2__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.

Potentially problematic release.


This version of lupin-danquin might be problematic. Click here for more details.

Files changed (33) hide show
  1. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/PKG-INFO +1 -1
  2. lupin-danquin-0.0.1.dev2/lupin_danquin/__init__.py +1 -0
  3. lupin-danquin-0.0.1.dev2/lupin_danquin/__main__.py +5 -0
  4. lupin-danquin-0.0.1.dev2/lupin_danquin/core/tools/utils.py +69 -0
  5. lupin-danquin-0.0.1.dev2/lupin_danquin/core/val3_doc_generator/val3_doc_generator.py +94 -0
  6. lupin-danquin-0.0.1.dev2/lupin_danquin/run.py +48 -0
  7. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin.egg-info/PKG-INFO +1 -1
  8. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin.egg-info/SOURCES.txt +3 -2
  9. lupin-danquin-0.0.1.dev2/lupin_danquin.egg-info/entry_points.txt +2 -0
  10. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin.egg-info/requires.txt +2 -2
  11. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/setup.cfg +7 -3
  12. lupin-danquin-0.0.1.dev1/lupin_danquin/__init__.py +0 -1
  13. lupin-danquin-0.0.1.dev1/lupin_danquin/core/external_resources.py +0 -18
  14. lupin-danquin-0.0.1.dev1/lupin_danquin/core/tools/utils.py +0 -37
  15. lupin-danquin-0.0.1.dev1/lupin_danquin/core/val3_doc_generator/val3_doc_generator.py +0 -45
  16. lupin-danquin-0.0.1.dev1/lupin_danquin/documentation_extraction.py +0 -54
  17. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/LICENCE +0 -0
  18. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/README.md +0 -0
  19. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin/check_coding_rules.py +0 -0
  20. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin/core/__init__.py +0 -0
  21. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin/core/application.py +0 -0
  22. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin/core/global_variable.py +0 -0
  23. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin/core/line_ended.py +0 -0
  24. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin/core/local_variable.py +0 -0
  25. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin/core/parameter.py +0 -0
  26. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin/core/program.py +0 -0
  27. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin/core/rules.py +0 -0
  28. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin/core/tools/__init__.py +0 -0
  29. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin/core/val3_doc_generator/__init__.py +0 -0
  30. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin.egg-info/dependency_links.txt +0 -0
  31. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin.egg-info/not-zip-safe +0 -0
  32. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/lupin_danquin.egg-info/top_level.txt +0 -0
  33. {lupin-danquin-0.0.1.dev1 → lupin-danquin-0.0.1.dev2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lupin-danquin
3
- Version: 0.0.1.dev1
3
+ Version: 0.0.1.dev2
4
4
  Summary: Testing - Documentation
5
5
  License: MIT License
6
6
  Keywords: documentation,testing
@@ -0,0 +1 @@
1
+ __version__ = "0.0.1.dev2"
@@ -0,0 +1,5 @@
1
+ from lupin_danquin import run
2
+
3
+
4
+ if __name__ == "__main__":
5
+ run.cli()
@@ -0,0 +1,69 @@
1
+ from typing import List
2
+ import logging
3
+ import os
4
+ import re
5
+ import sys
6
+
7
+
8
+ def must_get_string_value_from_env_var(var_name: str):
9
+ """Get a string value from an environment variable.
10
+ Args:
11
+ var_name (str): The name of the environment variable.
12
+ Returns:
13
+ str: The value of the environment variable.
14
+ Logs:
15
+ Error: If the environment {var_name} variable is not set.
16
+ sys.exit(1)
17
+ """
18
+ if not os.getenv(var_name):
19
+ logging.error(f"Environment variable {var_name} is not set.")
20
+ sys.exit(1)
21
+ return os.getenv(var_name)
22
+
23
+
24
+ def configure_logging():
25
+ logging.basicConfig(
26
+ format="%(asctime)s %(levelname)s: %(message)s", level=logging.INFO
27
+ )
28
+
29
+
30
+ def die(msg: str) -> None:
31
+ logging.error(msg)
32
+ sys.exit(1)
33
+
34
+
35
+ def info(msg: str) -> None:
36
+ logging.info(msg)
37
+
38
+
39
+ def get_version():
40
+ """get version from setup.cfg file and
41
+ update __version__ in lupin_danquin.__init__.py
42
+ """
43
+ with open("setup.cfg", "r", encoding="utf-8") as f:
44
+ setup_cfg = f.read()
45
+ print(setup_cfg)
46
+ _version = re.search(
47
+ r"(^version = )(\d{1,2}\.\d{1,2}\.\d{1,2})(\.[a-z]{1,})?(\d{1,2})?",
48
+ setup_cfg,
49
+ re.MULTILINE,
50
+ )
51
+ version = ""
52
+ for group in _version.group(2, 3, 4):
53
+ if group is not None:
54
+ version = version + str(group)
55
+ content = f'__version__ = "{version}"\n'
56
+
57
+ with open("lupin_danquin/__init__.py", "w", encoding="utf-8") as outfile:
58
+ outfile.write(content)
59
+ return version
60
+
61
+
62
+ def convert_application_name_to_list(application_name: str) -> List:
63
+ """Convert application name to list.
64
+ Args:
65
+ application_name (str): The name of the application.
66
+ Returns:
67
+ list: The list of the application name.
68
+ """
69
+ return [app.strip() for app in application_name.split(",") if app.strip()]
@@ -0,0 +1,94 @@
1
+ from typing import Any, Dict, List
2
+ import codecs
3
+ import os
4
+
5
+ from jinja2 import (
6
+ Environment,
7
+ FileSystemLoader,
8
+ select_autoescape,
9
+ Template,
10
+ TemplateNotFound,
11
+ TemplateError,
12
+ TemplateRuntimeError,
13
+ )
14
+
15
+ from lupin_danquin.core.application import Application
16
+ from lupin_danquin.core.tools.utils import die, info
17
+
18
+
19
+ class Val3Documentation:
20
+ USR_APP_DIR = "usrapp"
21
+
22
+ def _find_usrapp_dir(self) -> str:
23
+ """Find the usrapp directory"""
24
+ for dirpath, dirnames, filenames in os.walk(os.getcwd()):
25
+ if self.USR_APP_DIR in dirnames:
26
+ return os.path.join(dirpath, self.USR_APP_DIR)
27
+ die(msg=f"'{self.USR_APP_DIR}' directory not found")
28
+
29
+ def _get_informations_from_applications(
30
+ self, application_names: List
31
+ ) -> List[Dict[str, Any]]:
32
+ """Get all informations from applications"""
33
+
34
+ apps_information = []
35
+ base_program_path = self._find_usrapp_dir() + os.sep
36
+ print(f"base_program_path: {base_program_path}")
37
+ for application_name in application_names:
38
+ program_path = base_program_path + application_name
39
+ apps_information.append(
40
+ Application(
41
+ program_path, application_name
42
+ ).get_all_information_from_app()
43
+ )
44
+ return apps_information
45
+
46
+ def _read_begining_of_file(self) -> str:
47
+ with codecs.open(
48
+ "lupin_danquin/assets/BeginingOfFile.md", encoding="utf-8"
49
+ ) as f:
50
+ result = f.read()
51
+ return result
52
+
53
+ def _read_end_of_file(self) -> str:
54
+ with codecs.open("lupin_danquin/assets/EndOfFile.md", encoding="utf-8") as f:
55
+ result = f.read()
56
+ return result
57
+
58
+ def _get_local_template(self) -> Template:
59
+ try:
60
+ # Create jinja2 environment
61
+ env = Environment(
62
+ loader=FileSystemLoader("lupin_danquin/templates"),
63
+ autoescape=select_autoescape(),
64
+ trim_blocks=True,
65
+ lstrip_blocks=True,
66
+ )
67
+ # Charge template
68
+ template = env.get_template("val3_documentation_md.j2")
69
+ return template
70
+ except TemplateNotFound:
71
+ die(
72
+ msg="Template 'lupin_danquin/templates/val3_documentation_md.j2 not found"
73
+ )
74
+
75
+ def generate_markdown(self, applications_list: List) -> None:
76
+ """Generate the documentation"""
77
+ info(msg="Get informations from VAL3 applications")
78
+ context = {
79
+ "begining_of_file": self._read_begining_of_file(),
80
+ "end_of_file": self._read_end_of_file(),
81
+ "applications": self._get_informations_from_applications(applications_list),
82
+ }
83
+
84
+ template = self._get_local_template()
85
+ try:
86
+ content = template.render(context)
87
+ except (TemplateError, TemplateRuntimeError) as e:
88
+ die(msg=f"Error rendering Jinja2 template: {e}")
89
+
90
+ with codecs.open(
91
+ "lupin_danquin/val3_documentation.md", "w", encoding="utf-8"
92
+ ) as f:
93
+ f.write(content)
94
+ info(msg="Documentation generated")
@@ -0,0 +1,48 @@
1
+ from typing import Optional
2
+
3
+ from dotenv import load_dotenv
4
+ import typer
5
+
6
+ from lupin_danquin.core.tools.utils import (
7
+ configure_logging,
8
+ convert_application_name_to_list,
9
+ must_get_string_value_from_env_var,
10
+ )
11
+ from lupin_danquin.core.val3_doc_generator.val3_doc_generator import Val3Documentation
12
+ from lupin_danquin.__init__ import __version__
13
+
14
+
15
+ load_dotenv()
16
+
17
+
18
+ cli = typer.Typer()
19
+
20
+
21
+ @cli.command(help="Print version")
22
+ def version():
23
+ print(f"Version: {__version__}")
24
+
25
+
26
+ @cli.command()
27
+ def val_docs(
28
+ application_names: Optional[str] = typer.Argument(
29
+ ...,
30
+ help="Name of applications to be documented. Ex: 'app1,app2,app3'",
31
+ envvar="VAL3_APPLICATIONS",
32
+ )
33
+ ):
34
+ """
35
+ Generate documentation from VAL3 applications in usrapp directory.
36
+ You can specify the applications to be documented in the 'danq val-docs' command
37
+ or by setting the VAL3_APPLICATIONS environment variable.
38
+ :param application_names: Name of applications to be documented. Ex: app1,app2,app3
39
+ :type application_names: str
40
+
41
+ :example: danq val_docs "App1,App2"
42
+ """
43
+ if not application_names:
44
+ application_names = must_get_string_value_from_env_var("VAL3_APPLICATIONS")
45
+
46
+ configure_logging()
47
+ applications_list = convert_application_name_to_list(application_names)
48
+ Val3Documentation().generate_markdown(applications_list=applications_list)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lupin-danquin
3
- Version: 0.0.1.dev1
3
+ Version: 0.0.1.dev2
4
4
  Summary: Testing - Documentation
5
5
  License: MIT License
6
6
  Keywords: documentation,testing
@@ -3,17 +3,18 @@ README.md
3
3
  setup.cfg
4
4
  setup.py
5
5
  lupin_danquin/__init__.py
6
+ lupin_danquin/__main__.py
6
7
  lupin_danquin/check_coding_rules.py
7
- lupin_danquin/documentation_extraction.py
8
+ lupin_danquin/run.py
8
9
  lupin_danquin.egg-info/PKG-INFO
9
10
  lupin_danquin.egg-info/SOURCES.txt
10
11
  lupin_danquin.egg-info/dependency_links.txt
12
+ lupin_danquin.egg-info/entry_points.txt
11
13
  lupin_danquin.egg-info/not-zip-safe
12
14
  lupin_danquin.egg-info/requires.txt
13
15
  lupin_danquin.egg-info/top_level.txt
14
16
  lupin_danquin/core/__init__.py
15
17
  lupin_danquin/core/application.py
16
- lupin_danquin/core/external_resources.py
17
18
  lupin_danquin/core/global_variable.py
18
19
  lupin_danquin/core/line_ended.py
19
20
  lupin_danquin/core/local_variable.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ danq = lupin_danquin.run:cli
@@ -1,5 +1,5 @@
1
- typer[all]==0.7.0
2
- python-dotenv==1.0.0
1
+ typer[all]==0.6.1
2
+ python-dotenv==0.21.0
3
3
  Jinja2==3.1.2
4
4
 
5
5
  [test]
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = lupin-danquin
3
- version = 0.0.1.dev1
3
+ version = 0.0.1.dev2
4
4
  description = Testing - Documentation
5
5
  long_description = Test VAL3 code and generate documentation from it
6
6
  keywords = documentation, testing
@@ -19,10 +19,14 @@ include_package_data = True
19
19
  packages = find:
20
20
  python_requires = >=3.10
21
21
  install_requires =
22
- typer[all]==0.7.0
23
- python-dotenv==1.0.0
22
+ typer[all]==0.6.1
23
+ python-dotenv==0.21.0
24
24
  Jinja2==3.1.2
25
25
 
26
+ [options.entry_points]
27
+ console_scripts =
28
+ danq = lupin_danquin.run:cli
29
+
26
30
  [options.extras_require]
27
31
  test =
28
32
  pytest==7.2.2
@@ -1 +0,0 @@
1
- __version__ = "0.0.1.dev1"
@@ -1,18 +0,0 @@
1
- import codecs
2
- import os
3
-
4
-
5
- def read_begining_of_file() -> str:
6
- result = ""
7
- path = os.path.dirname(__file__) + os.sep + ".." + os.sep + "assets" + os.sep
8
- with codecs.open(path + "BeginingOfFile.md", encoding="utf-8") as f:
9
- result = f.read()
10
- return result
11
-
12
-
13
- def read_end_of_file() -> str:
14
- result = ""
15
- path = os.path.dirname(__file__) + os.sep + ".." + os.sep + "assets" + os.sep
16
- with codecs.open(path + "EndOfFile.md", encoding="utf-8") as f:
17
- result = f.read()
18
- return result
@@ -1,37 +0,0 @@
1
- import logging
2
- import re
3
- import sys
4
-
5
-
6
- def configure_logging():
7
- logging.basicConfig(
8
- format="%(asctime)s %(levelname)s: %(message)s", level=logging.INFO
9
- )
10
-
11
-
12
- def die(msg: str) -> None:
13
- logging.error(msg)
14
- sys.exit(1)
15
-
16
-
17
- def get_version():
18
- """get version from setup.cfg file and
19
- update __version__ in lupin_danquin.__init__.py
20
- """
21
- with open("setup.cfg", "r", encoding="utf-8") as f:
22
- setup_cfg = f.read()
23
- print(setup_cfg)
24
- _version = re.search(
25
- r"(^version = )(\d{1,2}\.\d{1,2}\.\d{1,2})(\.[a-z]{1,})?(\d{1,2})?",
26
- setup_cfg,
27
- re.MULTILINE,
28
- )
29
- version = ""
30
- for group in _version.group(2, 3, 4):
31
- if group is not None:
32
- version = version + str(group)
33
- content = f'__version__ = "{version}"\n'
34
-
35
- with open("lupin_danquin/__init__.py", "w", encoding="utf-8") as outfile:
36
- outfile.write(content)
37
- return version
@@ -1,45 +0,0 @@
1
- import codecs
2
-
3
- from jinja2 import (
4
- Environment,
5
- FileSystemLoader,
6
- select_autoescape,
7
- Template,
8
- TemplateNotFound,
9
- TemplateError,
10
- TemplateRuntimeError,
11
- )
12
-
13
- from core.tools.utils import die
14
-
15
-
16
- class Val3Documentation:
17
- def _get_local_template(self) -> Template:
18
- try:
19
- # Create jinja2 environment
20
- env = Environment(
21
- loader=FileSystemLoader("lupin_danquin/templates"),
22
- autoescape=select_autoescape(),
23
- trim_blocks=True,
24
- lstrip_blocks=True,
25
- )
26
- # Charge template
27
- template = env.get_template("val3_documentation_md.j2")
28
- return template
29
- except TemplateNotFound:
30
- print(
31
- "Template 'lupin_danquin/templates/val3_documentation_md.j2 not found"
32
- )
33
-
34
- def generate_markdown(self, context={}) -> None:
35
- """Generate the documentation"""
36
- template = self._get_local_template()
37
- try:
38
- content = template.render(context)
39
- except (TemplateError, TemplateRuntimeError) as e:
40
- die(msg=f"Error rendering Jinja2 template: {e}")
41
-
42
- with codecs.open(
43
- "lupin_danquin/val3_documentation.md", "w", encoding="utf-8"
44
- ) as f:
45
- f.write(content)
@@ -1,54 +0,0 @@
1
- import os
2
-
3
- from core.application import Application
4
- from core.external_resources import read_begining_of_file, read_end_of_file
5
- from core.tools.utils import configure_logging, die
6
- from core.val3_doc_generator.val3_doc_generator import Val3Documentation
7
-
8
-
9
- APPLICATION_NAMES = [
10
- "TaskManager",
11
- "Watchdog",
12
- ]
13
- USR_APP_DIR = "usrapp"
14
-
15
-
16
- def find_usrapp_dir() -> str:
17
- """Find the usrapp directory"""
18
- for dirpath, dirnames, filenames in os.walk(os.getcwd()):
19
- if USR_APP_DIR in dirnames:
20
- return os.path.join(dirpath, USR_APP_DIR)
21
- die(msg=f"'{USR_APP_DIR}' directory not found")
22
-
23
-
24
- def get_informations_from_applications() -> list:
25
- """Get all informations from applications"""
26
-
27
- apps_information = []
28
- base_program_path = find_usrapp_dir() + os.sep
29
-
30
- for application_name in APPLICATION_NAMES:
31
- program_path = base_program_path + application_name
32
- apps_information.append(
33
- Application(program_path, application_name).get_all_information_from_app()
34
- )
35
-
36
- return apps_information
37
-
38
-
39
- def main() -> None:
40
- """Main function"""
41
-
42
- configure_logging()
43
-
44
- context = {
45
- "begining_of_file": read_begining_of_file(),
46
- "end_of_file": read_end_of_file(),
47
- "applications": get_informations_from_applications(),
48
- }
49
-
50
- Val3Documentation().generate_markdown(context=context)
51
-
52
-
53
- if __name__ == "__main__":
54
- main()