lib-explorer 1.1.1__tar.gz → 1.1.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 (29) hide show
  1. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/PKG-INFO +20 -1
  2. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/README.md +17 -0
  3. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/lib_explorer.egg-info/PKG-INFO +20 -1
  4. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/lib_explorer.egg-info/SOURCES.txt +10 -1
  5. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/lib_explorer.egg-info/requires.txt +2 -0
  6. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/pyproject.toml +3 -1
  7. lib_explorer-1.1.2/rf_explorer/__init__.py +7 -0
  8. lib_explorer-1.1.2/rf_explorer/audit/__init__.py +1 -0
  9. lib_explorer-1.1.2/rf_explorer/audit/cli.py +92 -0
  10. lib_explorer-1.1.2/rf_explorer/audit/core.py +30 -0
  11. lib_explorer-1.1.2/rf_explorer/audit/exporters/__init__.py +5 -0
  12. lib_explorer-1.1.2/rf_explorer/audit/exporters/excel.py +113 -0
  13. lib_explorer-1.1.2/rf_explorer/audit/exporters/html.py +544 -0
  14. lib_explorer-1.1.2/rf_explorer/audit/exporters/json.py +38 -0
  15. lib_explorer-1.1.2/rf_explorer/audit/scanner/__init__.py +3 -0
  16. lib_explorer-1.1.2/rf_explorer/audit/scanner/project_scanners.py +228 -0
  17. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/rf_explorer/cli.py +9 -1
  18. lib_explorer-1.1.1/rf_explorer/__init__.py +0 -7
  19. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/LICENSE +0 -0
  20. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/lib_explorer.egg-info/dependency_links.txt +0 -0
  21. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/lib_explorer.egg-info/entry_points.txt +0 -0
  22. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/lib_explorer.egg-info/top_level.txt +0 -0
  23. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/rf_explorer/core.py +0 -0
  24. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/rf_explorer/python_doc.py +0 -0
  25. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/rf_explorer/rf_doc_show.py +0 -0
  26. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/rf_explorer/robot_doc.py +0 -0
  27. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/rf_explorer/scanner.py +0 -0
  28. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/rf_explorer/utils.py +0 -0
  29. {lib_explorer-1.1.1 → lib_explorer-1.1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lib-explorer
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: A CLI tool for exploring Python modules and Robot Framework libraries
5
5
  Author: Khaled LIMAM
6
6
  License: MIT License
@@ -35,6 +35,8 @@ Requires-Dist: rich>=13.0
35
35
  Requires-Dist: InquirerPy>=0.3.4
36
36
  Requires-Dist: robotframework>=6.0
37
37
  Requires-Dist: Pygments>=2.15
38
+ Requires-Dist: openpyxl>=3.0
39
+ Requires-Dist: PyYAML>=6.0
38
40
  Dynamic: license-file
39
41
 
40
42
  # RF Explorer
@@ -49,6 +51,10 @@ GitHub: https://github.com/khaledlim/rf-explorer
49
51
  RF Explorer is an interactive command-line tool to explore Python modules and Robot Framework libraries.
50
52
  It renders readable, syntax-highlighted documentation directly in the terminal using Rich.
51
53
 
54
+ ## Audit Report Preview
55
+
56
+ ![RF Explorer Audit Report Preview](docs/images/audit-report-preview.png)
57
+
52
58
  ## Highlights
53
59
 
54
60
  - Interactive terminal mode (menu-driven UI with InquirerPy)
@@ -94,6 +100,11 @@ rf-explorer --scan python
94
100
  rf-explorer --scan --all
95
101
 
96
102
  rf-explorer --search <keyword-or-regex>
103
+
104
+ rf-explorer audit --path <folder-path> --all
105
+ rf-explorer audit --path <folder-path> --all --export-html report.html
106
+ rf-explorer audit --path <folder-path> --tests --keywords --variables
107
+
97
108
  ```
98
109
 
99
110
  ## Examples
@@ -135,6 +146,14 @@ rf-explorer --scan --all
135
146
  rf-explorer --search browser
136
147
  ```
137
148
 
149
+ ### Audit Robot project content
150
+
151
+ ```bash
152
+ rf-explorer audit --path <folder-path> --all --export-html report.html
153
+ rf-explorer audit --path <folder-path> --all --export-json audit.json
154
+ rf-explorer audit --path <folder-path> --all --export-excell export.xlsx
155
+ ```
156
+
138
157
  ## Notes
139
158
 
140
159
  - Requires Python 3.9+
@@ -10,6 +10,10 @@ GitHub: https://github.com/khaledlim/rf-explorer
10
10
  RF Explorer is an interactive command-line tool to explore Python modules and Robot Framework libraries.
11
11
  It renders readable, syntax-highlighted documentation directly in the terminal using Rich.
12
12
 
13
+ ## Audit Report Preview
14
+
15
+ ![RF Explorer Audit Report Preview](docs/images/audit-report-preview.png)
16
+
13
17
  ## Highlights
14
18
 
15
19
  - Interactive terminal mode (menu-driven UI with InquirerPy)
@@ -55,6 +59,11 @@ rf-explorer --scan python
55
59
  rf-explorer --scan --all
56
60
 
57
61
  rf-explorer --search <keyword-or-regex>
62
+
63
+ rf-explorer audit --path <folder-path> --all
64
+ rf-explorer audit --path <folder-path> --all --export-html report.html
65
+ rf-explorer audit --path <folder-path> --tests --keywords --variables
66
+
58
67
  ```
59
68
 
60
69
  ## Examples
@@ -96,6 +105,14 @@ rf-explorer --scan --all
96
105
  rf-explorer --search browser
97
106
  ```
98
107
 
108
+ ### Audit Robot project content
109
+
110
+ ```bash
111
+ rf-explorer audit --path <folder-path> --all --export-html report.html
112
+ rf-explorer audit --path <folder-path> --all --export-json audit.json
113
+ rf-explorer audit --path <folder-path> --all --export-excell export.xlsx
114
+ ```
115
+
99
116
  ## Notes
100
117
 
101
118
  - Requires Python 3.9+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lib-explorer
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: A CLI tool for exploring Python modules and Robot Framework libraries
5
5
  Author: Khaled LIMAM
6
6
  License: MIT License
@@ -35,6 +35,8 @@ Requires-Dist: rich>=13.0
35
35
  Requires-Dist: InquirerPy>=0.3.4
36
36
  Requires-Dist: robotframework>=6.0
37
37
  Requires-Dist: Pygments>=2.15
38
+ Requires-Dist: openpyxl>=3.0
39
+ Requires-Dist: PyYAML>=6.0
38
40
  Dynamic: license-file
39
41
 
40
42
  # RF Explorer
@@ -49,6 +51,10 @@ GitHub: https://github.com/khaledlim/rf-explorer
49
51
  RF Explorer is an interactive command-line tool to explore Python modules and Robot Framework libraries.
50
52
  It renders readable, syntax-highlighted documentation directly in the terminal using Rich.
51
53
 
54
+ ## Audit Report Preview
55
+
56
+ ![RF Explorer Audit Report Preview](docs/images/audit-report-preview.png)
57
+
52
58
  ## Highlights
53
59
 
54
60
  - Interactive terminal mode (menu-driven UI with InquirerPy)
@@ -94,6 +100,11 @@ rf-explorer --scan python
94
100
  rf-explorer --scan --all
95
101
 
96
102
  rf-explorer --search <keyword-or-regex>
103
+
104
+ rf-explorer audit --path <folder-path> --all
105
+ rf-explorer audit --path <folder-path> --all --export-html report.html
106
+ rf-explorer audit --path <folder-path> --tests --keywords --variables
107
+
97
108
  ```
98
109
 
99
110
  ## Examples
@@ -135,6 +146,14 @@ rf-explorer --scan --all
135
146
  rf-explorer --search browser
136
147
  ```
137
148
 
149
+ ### Audit Robot project content
150
+
151
+ ```bash
152
+ rf-explorer audit --path <folder-path> --all --export-html report.html
153
+ rf-explorer audit --path <folder-path> --all --export-json audit.json
154
+ rf-explorer audit --path <folder-path> --all --export-excell export.xlsx
155
+ ```
156
+
138
157
  ## Notes
139
158
 
140
159
  - Requires Python 3.9+
@@ -14,4 +14,13 @@ rf_explorer/python_doc.py
14
14
  rf_explorer/rf_doc_show.py
15
15
  rf_explorer/robot_doc.py
16
16
  rf_explorer/scanner.py
17
- rf_explorer/utils.py
17
+ rf_explorer/utils.py
18
+ rf_explorer/audit/__init__.py
19
+ rf_explorer/audit/cli.py
20
+ rf_explorer/audit/core.py
21
+ rf_explorer/audit/exporters/__init__.py
22
+ rf_explorer/audit/exporters/excel.py
23
+ rf_explorer/audit/exporters/html.py
24
+ rf_explorer/audit/exporters/json.py
25
+ rf_explorer/audit/scanner/__init__.py
26
+ rf_explorer/audit/scanner/project_scanners.py
@@ -2,3 +2,5 @@ rich>=13.0
2
2
  InquirerPy>=0.3.4
3
3
  robotframework>=6.0
4
4
  Pygments>=2.15
5
+ openpyxl>=3.0
6
+ PyYAML>=6.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "lib-explorer"
7
- version = "1.1.1"
7
+ version = "1.1.2"
8
8
  description = "A CLI tool for exploring Python modules and Robot Framework libraries"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -20,6 +20,8 @@ dependencies = [
20
20
  "InquirerPy>=0.3.4",
21
21
  "robotframework >=6.0",
22
22
  "Pygments>=2.15",
23
+ "openpyxl>=3.0",
24
+ "PyYAML>=6.0",
23
25
  ]
24
26
 
25
27
  keywords = ["robotframework", "documentation", "interactive", "cli", "python"]
@@ -0,0 +1,7 @@
1
+
2
+ """
3
+ RF Explorer package initialization.
4
+ """
5
+
6
+ __version__ = "1.1.2"
7
+ __author__ = "Khaledlim"
@@ -0,0 +1 @@
1
+ __version__ = "1.1.2"
@@ -0,0 +1,92 @@
1
+
2
+ import argparse, os
3
+ from rf_explorer.audit.core import AuditResult, Collector
4
+ from rf_explorer.audit.scanner import RobotScanner, PythonKeywordScanner, VariableScanner
5
+ from rf_explorer.audit.exporters import export_json, export_html, export_excel
6
+ from rf_explorer.audit import __version__
7
+
8
+
9
+ def build_parser(prog=None):
10
+ parser = argparse.ArgumentParser(description="RF Audit Tool", prog=prog)
11
+ parser.add_argument("--path", help="Path file or folder", required=False)
12
+ parser.add_argument("--version", action="store_true")
13
+
14
+ parser.add_argument("--all", action="store_true")
15
+ parser.add_argument("--tests", action="store_true")
16
+ parser.add_argument("--keywords", action="store_true")
17
+ parser.add_argument("--variables", action="store_true")
18
+
19
+ parser.add_argument("--export-json")
20
+ parser.add_argument("--export-html")
21
+ parser.add_argument("--export-excel")
22
+
23
+ return parser
24
+
25
+
26
+ def execute_audit(args):
27
+ if args.version:
28
+ print(__version__)
29
+ return 0
30
+
31
+ if not args.path:
32
+ print("Error: --path is required")
33
+ return 2
34
+
35
+ if not os.path.exists(args.path):
36
+ print("Error: path not found")
37
+ return 2
38
+
39
+ if not any([args.all, args.tests, args.keywords, args.variables]):
40
+ print("No scan option provided")
41
+ return 2
42
+
43
+ if args.all:
44
+ args.tests = args.keywords = args.variables = True
45
+
46
+ result = AuditResult()
47
+
48
+ scanners = []
49
+
50
+ if args.tests:
51
+ scanners.append(RobotScanner())
52
+
53
+ if args.keywords:
54
+ scanners.append(PythonKeywordScanner())
55
+
56
+ if args.variables:
57
+ scanners.append(VariableScanner())
58
+
59
+ Collector(scanners).run(args.path, result)
60
+
61
+ summary = result.summary.copy()
62
+ libs = len(getattr(result, "libraries", []))
63
+ ress = len(getattr(result, "resources", []))
64
+ tags = getattr(result, "tags", {})
65
+
66
+ ordered = {"libraries": libs, "resources": ress}
67
+ ordered.update(summary)
68
+ ordered["tags"] = len(tags)
69
+ print("SUMMARY:", ordered)
70
+
71
+ if args.export_json:
72
+ export_json(result, args.export_json)
73
+
74
+ if args.export_html:
75
+ export_html(result, args.export_html, scanned_path=args.path)
76
+
77
+ if args.export_excel:
78
+ export_excel(result, args.export_excel)
79
+
80
+ return 0
81
+
82
+
83
+ def run_cli(argv=None, prog=None):
84
+ parser = build_parser(prog=prog)
85
+ args = parser.parse_args(argv)
86
+ return execute_audit(args)
87
+
88
+ def main():
89
+ raise SystemExit(run_cli())
90
+
91
+ if __name__ == "__main__":
92
+ main()
@@ -0,0 +1,30 @@
1
+
2
+ class Collector:
3
+ def __init__(self, scanners):
4
+ self.scanners = scanners
5
+
6
+ def run(self, path, result):
7
+ for scanner in self.scanners:
8
+ scanner.scan(path, result)
9
+
10
+ class AuditResult:
11
+ def __init__(self):
12
+ self.files = []
13
+ self.summary = {
14
+ "suites": 0,
15
+ "tests": 0,
16
+ "keywords": 0,
17
+ "variables": 0
18
+ }
19
+ self.tags = {}
20
+ self.libraries = []
21
+ self.resources = []
22
+ self.libraries_set = set()
23
+ self.resources_set = set()
24
+
25
+ class Issue:
26
+ def __init__(self, severity, rule, message, file):
27
+ self.severity = severity
28
+ self.rule = rule
29
+ self.message = message
30
+ self.file = file
@@ -0,0 +1,5 @@
1
+ from .excel import export_excel
2
+ from .html import export_html
3
+ from .json import export_json
4
+
5
+ __all__ = ["export_json", "export_html", "export_excel"]
@@ -0,0 +1,113 @@
1
+ from openpyxl import Workbook
2
+ from openpyxl.styles import Font, PatternFill, Alignment, Border, Side
3
+ from openpyxl.utils import get_column_letter
4
+
5
+ HEADER_FILL = PatternFill("solid", fgColor="1F4E79")
6
+ HEADER_FONT = Font(color="FFFFFF", bold=True)
7
+ CENTER = Alignment(vertical="center", horizontal="center", wrap_text=True)
8
+
9
+ BORDER = Border(
10
+ left=Side(style="thin", color="D9D9D9"),
11
+ right=Side(style="thin", color="D9D9D9"),
12
+ top=Side(style="thin", color="D9D9D9"),
13
+ bottom=Side(style="thin", color="D9D9D9"),
14
+ )
15
+
16
+ def style_header(row):
17
+ for cell in row:
18
+ cell.fill = HEADER_FILL
19
+ cell.font = HEADER_FONT
20
+ cell.alignment = CENTER
21
+ cell.border = BORDER
22
+
23
+ def style_cells(ws):
24
+ for row in ws.iter_rows():
25
+ for cell in row:
26
+ cell.border = BORDER
27
+ cell.alignment = Alignment(vertical="center", wrap_text=True)
28
+
29
+ def auto_width(ws):
30
+ for col in ws.columns:
31
+ max_len = 0
32
+ col_letter = get_column_letter(col[0].column)
33
+ for cell in col:
34
+ if cell.value:
35
+ max_len = max(max_len, len(str(cell.value)))
36
+ ws.column_dimensions[col_letter].width = min(max_len + 3, 50)
37
+
38
+ def export_excel(result, path):
39
+ wb = Workbook()
40
+
41
+ default_sheet = wb.active
42
+ wb.remove(default_sheet)
43
+
44
+ # ===================== SETTINGS (Libraries + Resources) =====================
45
+ ws_set = wb.create_sheet("Settings")
46
+ ws_set.append(["Library", "Resource"])
47
+ style_header(ws_set[1])
48
+ libs = sorted(result.libraries, key=lambda l: str(l.get('name', ''))) if hasattr(result, 'libraries') and result.libraries else []
49
+ ress = sorted(result.resources, key=lambda r: str(r.get('name', ''))) if hasattr(result, 'resources') and result.resources else []
50
+ max_len = max(len(libs), len(ress))
51
+ for i in range(max_len):
52
+ lib_name = libs[i].get('name', '') if i < len(libs) else ''
53
+ res_name = ress[i].get('name', '') if i < len(ress) else ''
54
+ ws_set.append([lib_name, res_name])
55
+ style_cells(ws_set)
56
+ auto_width(ws_set)
57
+
58
+ # ===================== TAGS =====================
59
+ if hasattr(result, 'tags') and result.tags:
60
+ ws_tag = wb.create_sheet("Tags")
61
+ ws_tag.append(["Tag", "Test Count"])
62
+ style_header(ws_tag[1])
63
+ for tag, count in sorted(result.tags.items(), key=lambda x: -x[1]):
64
+ ws_tag.append([tag, count])
65
+ style_cells(ws_tag)
66
+ auto_width(ws_tag)
67
+
68
+ # ===================== SUITES =====================
69
+ suites = [f for f in result.files if f.get("type") == "suite"]
70
+ if suites:
71
+ ws_suite = wb.create_sheet("Suites")
72
+ ws_suite.append(["Suite Name", "File", "Tests"])
73
+ style_header(ws_suite[1])
74
+
75
+ for s in suites:
76
+ tests = ", ".join(s.get("tests", []))
77
+ ws_suite.append([s.get("name"), s.get("file"), tests])
78
+
79
+ ws_suite.freeze_panes = "A2"
80
+ style_cells(ws_suite)
81
+ auto_width(ws_suite)
82
+
83
+ # ===================== KEYWORDS =====================
84
+ keywords = [f for f in result.files if f.get("type") == "keywords"]
85
+ if keywords:
86
+ ws_kw = wb.create_sheet("Keywords")
87
+ ws_kw.append(["File", "Keyword"])
88
+ style_header(ws_kw[1])
89
+
90
+ for kw in keywords:
91
+ for k in kw.get("values", []):
92
+ ws_kw.append([kw.get("file"), k])
93
+
94
+ ws_kw.freeze_panes = "A2"
95
+ style_cells(ws_kw)
96
+ auto_width(ws_kw)
97
+
98
+ # ===================== VARIABLES =====================
99
+ variables = [f for f in result.files if f.get("type") == "variables"]
100
+ if variables:
101
+ ws_var = wb.create_sheet("Variables")
102
+ ws_var.append(["File", "Variable"])
103
+ style_header(ws_var[1])
104
+
105
+ for var in variables:
106
+ for v in var.get("values", []):
107
+ ws_var.append([var.get("file"), v])
108
+
109
+ ws_var.freeze_panes = "A2"
110
+ style_cells(ws_var)
111
+ auto_width(ws_var)
112
+
113
+ wb.save(path)
@@ -0,0 +1,544 @@
1
+ import os
2
+ from html import escape
3
+
4
+ def export_html(result, path, scanned_path=None):
5
+
6
+ if scanned_path is None:
7
+ scanned_path = os.path.dirname(path)
8
+
9
+ if os.path.isfile(scanned_path):
10
+ folder_name = os.path.basename(os.path.dirname(scanned_path))
11
+ else:
12
+ folder_name = os.path.basename(os.path.normpath(scanned_path))
13
+
14
+ tests_count = result.summary.get("tests", 0)
15
+ keywords_count = result.summary.get("keywords", 0)
16
+ variables_count = result.summary.get("variables", 0)
17
+ libraries_count = len(getattr(result, "libraries", []))
18
+ resources_count = len(getattr(result, "resources", []))
19
+
20
+ html = f"""
21
+ <!DOCTYPE html>
22
+ <html lang="en">
23
+ <head>
24
+ <meta charset="utf-8">
25
+ <title>Robot Framework Audit - {folder_name}</title>
26
+
27
+ <style>
28
+
29
+ * {{
30
+ margin:0;
31
+ padding:0;
32
+ box-sizing:border-box;
33
+ }}
34
+
35
+ body {{
36
+ font-family:Segoe UI, Arial, sans-serif;
37
+ background:#f5f7fb;
38
+ color:#1f2937;
39
+ padding:28px;
40
+ }}
41
+
42
+ .topbar {{
43
+ display:flex;
44
+ align-items:baseline;
45
+ gap:16px;
46
+ margin-bottom:24px;
47
+ }}
48
+
49
+ h1 {{
50
+ font-size:38px;
51
+ font-weight:800;
52
+ }}
53
+
54
+ .project-name {{
55
+ font-size:24px;
56
+ color:#6b7280;
57
+ }}
58
+
59
+ .summary {{
60
+ display:grid;
61
+ grid-template-columns:repeat(5, minmax(0, 1fr));
62
+ gap:18px;
63
+ }}
64
+
65
+ @media (max-width: 1400px) {{
66
+ .summary {{
67
+ grid-template-columns:repeat(3, minmax(0, 1fr));
68
+ }}
69
+ }}
70
+
71
+ @media (max-width: 900px) {{
72
+ .summary {{
73
+ grid-template-columns:repeat(2, minmax(0, 1fr));
74
+ }}
75
+ }}
76
+
77
+ @media (max-width: 600px) {{
78
+ .summary {{
79
+ grid-template-columns:1fr;
80
+ }}
81
+ }}
82
+
83
+ .card {{
84
+ background:white;
85
+ border-radius:18px;
86
+ padding:20px;
87
+ display:flex;
88
+ align-items:center;
89
+ gap:16px;
90
+ border:1px solid #edf0f5;
91
+ box-shadow:0 4px 12px rgba(0,0,0,.06);
92
+ transition:.2s;
93
+ }}
94
+
95
+ .card:hover {{
96
+ transform:translateY(-4px);
97
+ box-shadow:0 10px 18px rgba(0,0,0,.08);
98
+ }}
99
+
100
+ .icon {{
101
+ width:54px;
102
+ height:54px;
103
+ border-radius:50%;
104
+ display:flex;
105
+ justify-content:center;
106
+ align-items:center;
107
+ color:white;
108
+ font-size:24px;
109
+ font-weight:bold;
110
+ }}
111
+
112
+ .tests .icon {{ background:#22c55e; }}
113
+ .keywords .icon {{ background:#3b82f6; }}
114
+ .variables .icon {{ background:#f59e0b; }}
115
+ .libraries .icon {{ background:#7c3aed; }}
116
+ .resources .icon {{ background:#06b6d4; }}
117
+
118
+ .card-title {{
119
+ font-size:18px;
120
+ font-weight:700;
121
+ }}
122
+
123
+ .card-value {{
124
+ font-size:34px;
125
+ font-weight:800;
126
+ line-height:1;
127
+ margin-top:4px;
128
+ }}
129
+
130
+ .card-sub {{
131
+ font-size:13px;
132
+ color:#6b7280;
133
+ margin-top:4px;
134
+ }}
135
+
136
+ .search-wrap {{
137
+ margin:24px 0;
138
+ }}
139
+
140
+ .search {{
141
+ width:420px;
142
+ max-width:100%;
143
+ padding:14px 16px;
144
+ border-radius:14px;
145
+ border:1px solid #dbe2ea;
146
+ background:white;
147
+ font-size:15px;
148
+ outline:none;
149
+ }}
150
+
151
+ .section {{
152
+ margin-top:28px;
153
+ }}
154
+
155
+ .section h2 {{
156
+ font-size:26px;
157
+ margin-bottom:14px;
158
+ }}
159
+
160
+ .box {{
161
+ background:white;
162
+ border-radius:18px;
163
+ padding:18px;
164
+ margin-bottom:14px;
165
+ border:1px solid #edf0f5;
166
+ box-shadow:0 4px 12px rgba(0,0,0,.06);
167
+ transition:.2s;
168
+ }}
169
+
170
+ .box:hover {{
171
+ transform:translateY(-3px);
172
+ box-shadow:0 10px 18px rgba(0,0,0,.08);
173
+ }}
174
+
175
+ .header {{
176
+ display:flex;
177
+ justify-content:space-between;
178
+ align-items:center;
179
+ gap:18px;
180
+ cursor:pointer;
181
+ }}
182
+
183
+ .file {{
184
+ font-size:16px;
185
+ font-weight:700;
186
+ }}
187
+
188
+ .path {{
189
+ font-size:13px;
190
+ color:#6b7280;
191
+ margin-top:4px;
192
+ }}
193
+
194
+ .count {{
195
+ font-size:14px;
196
+ font-weight:700;
197
+ color:#374151;
198
+ }}
199
+
200
+ .content {{
201
+ display:none;
202
+ margin-top:16px;
203
+ padding-top:14px;
204
+ border-top:1px solid #edf0f5;
205
+ }}
206
+
207
+ .pills {{
208
+ display:flex;
209
+ flex-wrap:wrap;
210
+ gap:10px;
211
+ }}
212
+
213
+ .file-pill {{
214
+ display:inline-block;
215
+ padding:10px 16px;
216
+ border-radius:999px;
217
+ margin:8px 10px 0 0;
218
+ font-size:14px;
219
+ font-weight:600;
220
+ }}
221
+
222
+ .test-pill {{
223
+ background:#dcfce7;
224
+ color:#166534;
225
+ }}
226
+
227
+ .keyword-pill {{
228
+ background:#dbeafe;
229
+ color:#1d4ed8;
230
+ }}
231
+
232
+ .var-pill {{
233
+ background:#fef3c7;
234
+ color:#b45309;
235
+ }}
236
+
237
+ .lib {{
238
+ background:#f3e8ff;
239
+ color:#6d28d9;
240
+ }}
241
+
242
+ .res {{
243
+ background:#ccfbf1;
244
+ color:#0f766e;
245
+ }}
246
+
247
+ .tag {{
248
+ background:#eff6ff;
249
+ color:#1d4ed8;
250
+ }}
251
+
252
+ .empty {{
253
+ color:#9ca3af;
254
+ }}
255
+
256
+ </style>
257
+
258
+ <script>
259
+
260
+ function toggle(id){{
261
+ let el = document.getElementById(id);
262
+
263
+ if(el.style.display === "block")
264
+ el.style.display = "none";
265
+ else
266
+ el.style.display = "block";
267
+ }}
268
+
269
+ function filterItems(){{
270
+ let q = document.getElementById("search").value.toLowerCase();
271
+ let boxes = document.getElementsByClassName("box");
272
+
273
+ for(let b of boxes){{
274
+ let txt = b.innerText.toLowerCase();
275
+ b.style.display = txt.includes(q) ? "block" : "none";
276
+ }}
277
+ }}
278
+
279
+ </script>
280
+ </head>
281
+
282
+ <body>
283
+
284
+ <div class="topbar">
285
+ <h1>Robot Framework Audit</h1>
286
+ <div class="project-name" style="font-size:48px;font-weight:800;letter-spacing:1.5px;line-height:1.1;">{folder_name}</div>
287
+ </div>
288
+
289
+ <div class="summary">
290
+
291
+ <div class="card libraries">
292
+ <div class="icon">📦</div>
293
+ <div>
294
+ <div class="card-title">Libraries</div>
295
+ <div class="card-value">{libraries_count}</div>
296
+ <div class="card-sub">Imported libraries</div>
297
+ </div>
298
+ </div>
299
+
300
+ <div class="card resources">
301
+ <div class="icon">📄</div>
302
+ <div>
303
+ <div class="card-title">Resources</div>
304
+ <div class="card-value">{resources_count}</div>
305
+ <div class="card-sub">Resource files</div>
306
+ </div>
307
+ </div>
308
+
309
+ <div class="card tests">
310
+ <div class="icon">✔</div>
311
+ <div>
312
+ <div class="card-title">Tests</div>
313
+ <div class="card-value">{tests_count}</div>
314
+ <div class="card-sub">Test cases</div>
315
+ </div>
316
+ </div>
317
+
318
+ <div class="card keywords">
319
+ <div class="icon">⚙</div>
320
+ <div>
321
+ <div class="card-title">Keywords</div>
322
+ <div class="card-value">{keywords_count}</div>
323
+ <div class="card-sub">Defined keywords</div>
324
+ </div>
325
+ </div>
326
+
327
+ <div class="card variables">
328
+ <div class="icon">$</div>
329
+ <div>
330
+ <div class="card-title">Variables</div>
331
+ <div class="card-value">{variables_count}</div>
332
+ <div class="card-sub">Defined variables</div>
333
+ </div>
334
+ </div>
335
+
336
+ </div>
337
+
338
+ <div class="search-wrap">
339
+ <input id="search" class="search" placeholder="Search..." onkeyup="filterItems()">
340
+ </div>
341
+ """
342
+
343
+ idx = 0
344
+
345
+ # SETTINGS
346
+ html += "<div class='section'><h2>Settings</h2>"
347
+
348
+ libs = getattr(result, "libraries", [])
349
+ html += f"""
350
+ <div class="box">
351
+ <div class="header" onclick="toggle('libs')">
352
+ <div class="file">Libraries</div>
353
+ <div class="count">{libraries_count} libraries</div>
354
+ </div>
355
+ <div class="content" id="libs">
356
+ """
357
+
358
+ if libs:
359
+ for lib in libs:
360
+ html += f"<span class='file-pill lib'>{escape(os.path.basename(str(lib.get('name',''))))}</span>"
361
+ else:
362
+ html += "<div class='empty'>No libraries found.</div>"
363
+
364
+ html += "</div></div>"
365
+
366
+ res_list = getattr(result, "resources", [])
367
+ html += f"""
368
+ <div class="box">
369
+ <div class="header" onclick="toggle('res')">
370
+ <div class="file">Resources</div>
371
+ <div class="count">{resources_count} resources</div>
372
+ </div>
373
+ <div class="content" id="res">
374
+ """
375
+
376
+ if res_list:
377
+ for res in res_list:
378
+ html += f"<span class='file-pill res'>{escape(os.path.basename(str(res.get('name',''))))}</span>"
379
+ else:
380
+ html += "<div class='empty'>No resources found.</div>"
381
+
382
+ html += "</div></div></div>"
383
+
384
+ # SUITES / TESTS
385
+ html += "<div class='section'><h2>Suites / Tests</h2>"
386
+
387
+ suite_files = [item for item in result.files if item["type"] == "suite"]
388
+
389
+ if not suite_files:
390
+ html += """
391
+ <div class="box">
392
+ <div class="header" onclick="toggle('empty-suites')">
393
+ <div class="file">Suites / Tests</div>
394
+ <div class="count">0 tests</div>
395
+ </div>
396
+ <div class="content" id="empty-suites">
397
+ <div class='empty'>No suites or tests found.</div>
398
+ </div>
399
+ </div>
400
+ """
401
+
402
+ for f in suite_files:
403
+
404
+ cid = f"s{idx}"
405
+ idx += 1
406
+
407
+ suite_name = escape(str(f.get("name", "N/A")))
408
+ full_path = escape(str(f.get("file", "N/A")))
409
+ count = len(f.get("tests", []))
410
+
411
+ html += f"""
412
+ <div class="box">
413
+ <div class="header" onclick="toggle('{cid}')">
414
+ <div>
415
+ <div class="file">{suite_name}</div>
416
+ <div class="path">{full_path}</div>
417
+ </div>
418
+ <div class="count">{count} tests</div>
419
+ </div>
420
+
421
+ <div class="content" id="{cid}">
422
+ """
423
+
424
+ for t in f.get("tests", []):
425
+ html += f"<span class='file-pill test-pill'>{escape(str(t))}</span>"
426
+
427
+ html += "</div></div>"
428
+
429
+ html += "</div>"
430
+
431
+ # KEYWORDS
432
+ html += f"<div class='section'><h2>Keywords</h2>"
433
+
434
+ keyword_files = [item for item in result.files if item["type"] == "keywords"]
435
+
436
+ if not keyword_files:
437
+ html += """
438
+ <div class="box">
439
+ <div class="header" onclick="toggle('empty-keywords')">
440
+ <div class="file">Keywords</div>
441
+ <div class="count">0 keywords</div>
442
+ </div>
443
+ <div class="content" id="empty-keywords">
444
+ <div class='empty'>No keywords found.</div>
445
+ </div>
446
+ </div>
447
+ """
448
+
449
+ for f in keyword_files:
450
+ cid = f"k{idx}"
451
+ idx += 1
452
+ full_path = str(f.get("file", ""))
453
+ filename = os.path.basename(full_path)
454
+ count = len(f.get("values", []))
455
+ html += f"""
456
+ <div class="box">
457
+ <div class="header" onclick="toggle('{cid}')">
458
+ <div>
459
+ <div class="file">{escape(filename)}</div>
460
+ <div class="path">{escape(full_path)}</div>
461
+ </div>
462
+ <div class="count">{count} keywords</div>
463
+ </div>
464
+ <div class="content" id="{cid}">
465
+ """
466
+ for k in f.get("values", []):
467
+ html += f"<span class='file-pill keyword-pill'>{escape(str(k))}</span>"
468
+ html += "</div></div>"
469
+ html += "</div>"
470
+
471
+ # VARIABLES
472
+ html += "<div class='section'><h2>Variables</h2>"
473
+
474
+ variable_files = [item for item in result.files if item["type"] == "variables"]
475
+
476
+ if not variable_files:
477
+ html += """
478
+ <div class="box">
479
+ <div class="header" onclick="toggle('empty-variables')">
480
+ <div class="file">Variables</div>
481
+ <div class="count">0 variables</div>
482
+ </div>
483
+ <div class="content" id="empty-variables">
484
+ <div class='empty'>No variables found.</div>
485
+ </div>
486
+ </div>
487
+ """
488
+
489
+ for f in variable_files:
490
+
491
+ cid = f"v{idx}"
492
+ idx += 1
493
+
494
+ full_path = str(f.get("file", ""))
495
+ filename = os.path.basename(full_path)
496
+ count = len(f.get("values", []))
497
+
498
+ html += f"""
499
+ <div class="box">
500
+ <div class="header" onclick="toggle('{cid}')">
501
+ <div>
502
+ <div class="file">{escape(filename)}</div>
503
+ <div class="path">{escape(full_path)}</div>
504
+ </div>
505
+ <div class="count">{count} variables</div>
506
+ </div>
507
+
508
+ <div class="content" id="{cid}">
509
+ """
510
+
511
+ for v in f.get("values", []):
512
+ html += f"<span class='file-pill var-pill'>{escape(str(v))}</span>"
513
+
514
+ html += "</div></div>"
515
+
516
+ html += "</div>"
517
+
518
+ # TAGS
519
+ tags_count = len(result.tags) if hasattr(result, "tags") and result.tags else 0
520
+ html += f"""
521
+ <div class='section'>
522
+ <h2>Tags</h2>
523
+ <div class="box">
524
+ <div class="header" onclick="toggle('tags')">
525
+ <div class="file">Tags</div>
526
+ <div class="count">{tags_count} tags</div>
527
+ </div>
528
+ <div class="content" id="tags">
529
+ """
530
+ if hasattr(result, "tags") and result.tags:
531
+ for tag, count in sorted(result.tags.items(), key=lambda x: -x[1]):
532
+ html += f"<span class='file-pill tag'>{escape(str(tag))} ({count})</span>"
533
+ else:
534
+ html += "<div class='empty'>No tags found.</div>"
535
+ html += """
536
+ </div>
537
+ </div>
538
+ </div>
539
+
540
+ </body>
541
+ </html>
542
+ """
543
+ with open(path, "w", encoding="utf-8") as f:
544
+ f.write(html)
@@ -0,0 +1,38 @@
1
+ import json
2
+
3
+ def export_json(result, path):
4
+
5
+ data = result.__dict__.copy()
6
+ data.pop('libraries_set', None)
7
+ data.pop('resources_set', None)
8
+ if 'libraries' in data:
9
+ data['libraries'] = list(data['libraries'])
10
+ if 'resources' in data:
11
+ data['resources'] = list(data['resources'])
12
+
13
+ ordered = {}
14
+
15
+ for k in ['libraries', 'resources', 'tags']:
16
+ if k in data:
17
+ ordered[k] = data[k]
18
+ for k in data:
19
+ if k not in ordered and k != 'summary':
20
+ ordered[k] = data[k]
21
+
22
+ summary = data.get('summary', {})
23
+ summary_ordered = {}
24
+ summary_ordered['libraries'] = len(data.get('libraries', []))
25
+ summary_ordered['resources'] = len(data.get('resources', []))
26
+ tags = data.get('tags', {})
27
+ summary_ordered['tags'] = len(tags) if tags else 0
28
+ for k in summary:
29
+ if k not in summary_ordered:
30
+ summary_ordered[k] = summary[k]
31
+ ordered['summary'] = summary_ordered
32
+
33
+ if 'summary' in ordered:
34
+ summary_value = ordered.pop('summary')
35
+ ordered['summary'] = summary_value
36
+
37
+ with open(path, "w", encoding="utf-8") as f:
38
+ json.dump(ordered, f, indent=2, ensure_ascii=False)
@@ -0,0 +1,3 @@
1
+ from .project_scanners import PythonKeywordScanner, RobotScanner, VariableScanner
2
+
3
+ __all__ = ["RobotScanner", "PythonKeywordScanner", "VariableScanner"]
@@ -0,0 +1,228 @@
1
+ import os
2
+ import ast
3
+ from pathlib import Path
4
+ try:
5
+ import yaml as _yaml
6
+ except ImportError:
7
+ _yaml = None
8
+
9
+
10
+ def _iter_robot_files(path):
11
+ for file in iter_files(path):
12
+ if file.endswith((".robot", ".resource")):
13
+ yield file
14
+
15
+
16
+ def _split_cells(raw_line):
17
+ return [cell for cell in raw_line.replace("\t", " ").split(" ") if cell]
18
+
19
+
20
+ def _normalize_section(stripped_line):
21
+ if not (stripped_line.startswith("***") and stripped_line.endswith("***")):
22
+ return None
23
+ return stripped_line.strip("*").strip().lower()
24
+
25
+
26
+ def _suite_name(file_path):
27
+ stem = Path(file_path).stem.replace("_", " ").replace("-", " ")
28
+ return " ".join(part if part.isupper() else part.capitalize() for part in stem.split())
29
+
30
+
31
+ def _parse_robot_file(file_path):
32
+ tests = []
33
+ keywords = []
34
+ variables = []
35
+ libraries = []
36
+ resources = []
37
+ variable_files = []
38
+ tags = {}
39
+ section = None
40
+ current_test_tags = []
41
+
42
+ try:
43
+ with open(file_path, encoding="utf-8") as handle:
44
+ lines = handle.readlines()
45
+ except OSError:
46
+ return {
47
+ "tests": tests,
48
+ "keywords": keywords,
49
+ "variables": variables,
50
+ "libraries": libraries,
51
+ "resources": resources,
52
+ "tags": tags,
53
+ }
54
+
55
+ for raw_line in lines:
56
+ stripped = raw_line.strip()
57
+ if not stripped or stripped.startswith("#"):
58
+ continue
59
+
60
+ next_section = _normalize_section(stripped)
61
+ if next_section:
62
+ section = next_section
63
+ current_test_tags = []
64
+ continue
65
+
66
+ cells = _split_cells(raw_line.rstrip())
67
+ if not cells:
68
+ continue
69
+
70
+ first = cells[0]
71
+
72
+ if section == "settings":
73
+ setting = first.lower()
74
+ args = cells[2:] if len(cells) > 2 else []
75
+ if setting == "library" and len(cells) >= 2:
76
+ libraries.append({"name": cells[1], "args": args, "type": "library"})
77
+ elif setting == "resource" and len(cells) >= 2:
78
+ resources.append({"name": cells[1], "args": args, "type": "resource"})
79
+ elif setting == "variables" and len(cells) >= 2:
80
+ variable_files.append(cells[1])
81
+ continue
82
+
83
+ if section == "variables":
84
+ if raw_line[:1].isspace() or first == "...":
85
+ continue
86
+ variables.append(" = ".join(cells[:2]) if len(cells) > 1 else first)
87
+ continue
88
+
89
+ if section == "keywords":
90
+ if raw_line[:1].isspace() or first == "...":
91
+ continue
92
+
93
+ if first.startswith("["):
94
+ continue
95
+ keywords.append(first)
96
+ continue
97
+
98
+ if section == "test cases":
99
+ if raw_line[:1].isspace() or first == "...":
100
+ tag_cells = cells[1:] if first.lower() == "[tags]" else []
101
+ if tag_cells:
102
+ current_test_tags.extend(tag_cells)
103
+ continue
104
+
105
+ if first.startswith("["):
106
+ continue
107
+
108
+ if current_test_tags:
109
+ for tag in current_test_tags:
110
+ tags[tag] = tags.get(tag, 0) + 1
111
+ current_test_tags = []
112
+
113
+ tests.append(first)
114
+
115
+ if current_test_tags:
116
+ for tag in current_test_tags:
117
+ tags[tag] = tags.get(tag, 0) + 1
118
+
119
+ return {
120
+ "tests": tests,
121
+ "keywords": keywords,
122
+ "variables": variables,
123
+ "libraries": libraries,
124
+ "resources": resources,
125
+ "variable_files": variable_files,
126
+ "tags": tags,
127
+ }
128
+
129
+ def _parse_yaml_variable_file(file_path):
130
+ """Extract top-level keys from a YAML variable file as Robot Framework variables."""
131
+ if _yaml is None:
132
+ return []
133
+ try:
134
+ with open(file_path, encoding="utf-8") as handle:
135
+ data = _yaml.safe_load(handle)
136
+ except (OSError, _yaml.YAMLError):
137
+ return []
138
+ if not isinstance(data, dict):
139
+ return []
140
+ variables = []
141
+ for key, value in data.items():
142
+ if isinstance(value, dict):
143
+ items_str = ", ".join(f"{k}={v}" for k, v in value.items())
144
+ variables.append(f"&{{{key}}} = {{{items_str}}}")
145
+ elif isinstance(value, list):
146
+ variables.append(f"@{{{key}}} = {value}")
147
+ else:
148
+ variables.append(f"${{{key}}} = {value}")
149
+ return variables
150
+
151
+
152
+ def iter_files(path):
153
+ if os.path.isfile(path):
154
+ yield path
155
+ else:
156
+ for r,_,f in os.walk(path):
157
+ for x in f:
158
+ yield os.path.join(r,x)
159
+
160
+ class PythonKeywordScanner:
161
+ def scan(self, path, result):
162
+ for file in iter_files(path):
163
+ if not file.endswith(".py"):
164
+ continue
165
+ try:
166
+ tree = ast.parse(open(file,encoding="utf-8").read())
167
+ except:
168
+ continue
169
+
170
+ funcs = [n.name for n in ast.walk(tree)
171
+ if isinstance(n, ast.FunctionDef) and not n.name.startswith("_")]
172
+
173
+ if funcs:
174
+ result.files.append({"type":"keywords","file":file,"values":funcs})
175
+ result.summary["keywords"] += len(funcs)
176
+
177
+
178
+ class RobotScanner:
179
+ def scan(self, path, result):
180
+ for file in _iter_robot_files(path):
181
+ parsed = _parse_robot_file(file)
182
+
183
+ if parsed["tests"]:
184
+ result.files.append(
185
+ {"type": "suite", "name": _suite_name(file), "tests": parsed["tests"], "file": file}
186
+ )
187
+ result.summary["suites"] += 1
188
+ result.summary["tests"] += len(parsed["tests"])
189
+
190
+ if parsed["keywords"]:
191
+ result.files.append({"type": "keywords", "file": file, "values": parsed["keywords"]})
192
+ result.summary["keywords"] += len(parsed["keywords"])
193
+
194
+ for library in parsed["libraries"]:
195
+ key = (library["name"], tuple(library["args"]))
196
+ if key not in result.libraries_set:
197
+ result.libraries_set.add(key)
198
+ result.libraries.append(library)
199
+
200
+ for resource in parsed["resources"]:
201
+ key = (resource["name"], tuple(resource["args"]))
202
+ if key not in result.resources_set:
203
+ result.resources_set.add(key)
204
+ result.resources.append(resource)
205
+
206
+ for tag, count in parsed["tags"].items():
207
+ result.tags[tag] = result.tags.get(tag, 0) + count
208
+
209
+
210
+ class VariableScanner:
211
+ def scan(self, path, result):
212
+ for file in _iter_robot_files(path):
213
+ parsed = _parse_robot_file(file)
214
+ if not parsed["variables"]:
215
+ continue
216
+ result.files.append({"type": "variables", "file": file, "values": parsed["variables"]})
217
+ result.summary["variables"] += len(parsed["variables"])
218
+
219
+ for file in iter_files(path):
220
+ if not file.endswith((".yml", ".yaml")):
221
+ continue
222
+ if os.path.basename(file).startswith("."):
223
+ continue
224
+ variables = _parse_yaml_variable_file(file)
225
+ if not variables:
226
+ continue
227
+ result.files.append({"type": "variables", "file": file, "values": variables})
228
+ result.summary["variables"] += len(variables)
@@ -13,7 +13,7 @@ from rich.console import Console
13
13
 
14
14
  console = Console()
15
15
 
16
- VERSION = "1.0.0"
16
+ VERSION = "1.1.2"
17
17
 
18
18
 
19
19
  ASCII_LOGO = r"""
@@ -50,6 +50,7 @@ def print_help():
50
50
  "\n"
51
51
  " rf-explorer python <[bold magenta]module[/bold magenta]> [regex |--all]\n"
52
52
  " rf-explorer robot <[bold magenta]library[/bold magenta]> [regex | --all]\n"
53
+ " rf-explorer audit [audit-options]\n"
53
54
 
54
55
  )
55
56
 
@@ -218,6 +219,13 @@ def cli():
218
219
  except Exception as e:
219
220
  console.print("[red]FATAL ERROR in --search[/red]")
220
221
  return
222
+
223
+ # =============================================================================
224
+ # AUDIT MODE
225
+ # =============================================================================
226
+ if args[0] == "audit":
227
+ from rf_explorer.audit.cli import run_cli
228
+ raise SystemExit(run_cli(args[1:], prog="rf-explorer audit"))
221
229
 
222
230
  # =============================================================================
223
231
  # PYTHON MODE
@@ -1,7 +0,0 @@
1
-
2
- """
3
- RF Explorer package initialization.
4
- """
5
-
6
- __version__ = "1.0.0"
7
- _author__ = "Khaled LIMAM"
File without changes
File without changes