robotframework-mind 0.1.5__tar.gz → 0.1.6__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.
- {robotframework_mind-0.1.5/robotframework_mind.egg-info → robotframework_mind-0.1.6}/PKG-INFO +4 -1
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/README.md +3 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind.py +29 -2
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/__init__.py +1 -1
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6/robotframework_mind.egg-info}/PKG-INFO +4 -1
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robotframework_mind.egg-info/SOURCES.txt +2 -0
- robotframework_mind-0.1.6/tests/test_lookup_log.py +46 -0
- robotframework_mind-0.1.6/tests/test_missing_dependency.py +22 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/LICENSE +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/NOTICE +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/pyproject.toml +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/__main__.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/community_panel.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/editors.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/engine.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/folders.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/graph.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/graph_layout.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/graph_view.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/icons.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/lucide.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/settings.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/theme.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/widgets.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/window.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robot_mind_app/worker.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robotframework_mind.egg-info/dependency_links.txt +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robotframework_mind.egg-info/entry_points.txt +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robotframework_mind.egg-info/requires.txt +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robotframework_mind.egg-info/top_level.txt +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/setup.cfg +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/tests/test_editors.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/tests/test_graph.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/tests/test_graph_layout.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/tests/test_query.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/tests/test_ui.py +0 -0
- {robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/tests/test_where.py +0 -0
{robotframework_mind-0.1.5/robotframework_mind.egg-info → robotframework_mind-0.1.6}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: robotframework-mind
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
4
|
Summary: Exact lookups over a Robot Framework test repo: CLI and desktop UI
|
|
5
5
|
Author: Abdulwahab Isam
|
|
6
6
|
License-Expression: MIT
|
|
@@ -82,6 +82,9 @@ python path/to/robot_mind.py --root <repo> find /api/items/query
|
|
|
82
82
|
prints the hits as a JSON array (each with `kind`, `name`, `file`, `line`; a
|
|
83
83
|
`callers` hit also carries `call_line`).
|
|
84
84
|
|
|
85
|
+
Every lookup is appended to `lookups.jsonl` in the cache folder. `python robot_mind.py stats`
|
|
86
|
+
prints the lookup count, how many found something and the terms that found nothing.
|
|
87
|
+
|
|
85
88
|
## Desktop app
|
|
86
89
|
|
|
87
90
|
The same lookups in a window. Pick a repo (or a folder that holds several),
|
|
@@ -52,6 +52,9 @@ python path/to/robot_mind.py --root <repo> find /api/items/query
|
|
|
52
52
|
prints the hits as a JSON array (each with `kind`, `name`, `file`, `line`; a
|
|
53
53
|
`callers` hit also carries `call_line`).
|
|
54
54
|
|
|
55
|
+
Every lookup is appended to `lookups.jsonl` in the cache folder. `python robot_mind.py stats`
|
|
56
|
+
prints the lookup count, how many found something and the terms that found nothing.
|
|
57
|
+
|
|
55
58
|
## Desktop app
|
|
56
59
|
|
|
57
60
|
The same lookups in a window. Pick a repo (or a folder that holds several),
|
|
@@ -10,11 +10,13 @@ from __future__ import annotations
|
|
|
10
10
|
|
|
11
11
|
import argparse
|
|
12
12
|
import hashlib
|
|
13
|
+
import io
|
|
13
14
|
import json
|
|
14
15
|
import os
|
|
15
16
|
import re
|
|
16
17
|
import sys
|
|
17
18
|
from dataclasses import asdict, dataclass, field
|
|
19
|
+
from datetime import datetime, timezone
|
|
18
20
|
from pathlib import Path
|
|
19
21
|
|
|
20
22
|
ROBOT_EXTS = {".robot", ".resource"}
|
|
@@ -193,6 +195,8 @@ def parse_json(path: Path, rel: str) -> list[Entry]:
|
|
|
193
195
|
def parse_file(path: Path, rel: str) -> list[Entry]:
|
|
194
196
|
try:
|
|
195
197
|
return parse_json(path, rel) if path.suffix == ".json" else parse_robot(path, rel)
|
|
198
|
+
except ImportError:
|
|
199
|
+
raise
|
|
196
200
|
except Exception as exc: # one broken file must not hide the rest of the index
|
|
197
201
|
return [Entry("error", type(exc).__name__, rel, value=str(exc)[:VALUE_WIDTH])]
|
|
198
202
|
|
|
@@ -418,8 +422,29 @@ def query(root: Path, command: str, term: str, cache_dir: Path | None = None) ->
|
|
|
418
422
|
return to_hits(lookup(load_index(root, cache_dir or default_cache()), command, term))
|
|
419
423
|
|
|
420
424
|
|
|
425
|
+
def log_lookup(cache_dir: Path, command: str, term: str, hits: int) -> None:
|
|
426
|
+
"""Append one lookup to lookups.jsonl so answered and missed questions can be counted."""
|
|
427
|
+
row = {"at": datetime.now(timezone.utc).isoformat(timespec="seconds"),
|
|
428
|
+
"command": command, "term": term, "hits": hits}
|
|
429
|
+
cache_dir.mkdir(parents=True, exist_ok=True)
|
|
430
|
+
with (cache_dir / "lookups.jsonl").open("a", encoding="utf-8") as log:
|
|
431
|
+
log.write(json.dumps(row, ensure_ascii=False) + "\n")
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
def lookup_stats(cache_dir: Path) -> str:
|
|
435
|
+
"""JSON with the lookup count, how many found something, and the terms that found nothing."""
|
|
436
|
+
path = cache_dir / "lookups.jsonl"
|
|
437
|
+
lines = path.read_text(encoding="utf-8").splitlines() if path.exists() else []
|
|
438
|
+
rows = [json.loads(line) for line in lines]
|
|
439
|
+
missed = [{"command": r["command"], "term": r["term"]} for r in rows if not r["hits"]]
|
|
440
|
+
return json.dumps({"lookups": len(rows), "answered": len(rows) - len(missed), "missed": missed},
|
|
441
|
+
ensure_ascii=False)
|
|
442
|
+
|
|
443
|
+
|
|
421
444
|
def run(argv: list[str], root: Path | None = None, cache_dir: Path | None = None) -> str:
|
|
422
|
-
|
|
445
|
+
if argv == ["stats"]:
|
|
446
|
+
return lookup_stats(cache_dir or default_cache())
|
|
447
|
+
p = argparse.ArgumentParser(prog="robot_mind", description=(__doc__ or "").split("\n")[0])
|
|
423
448
|
p.add_argument("--root", type=Path, default=root or Path.cwd())
|
|
424
449
|
p.add_argument("command", choices=["ticket", "kw", "callers", "tag", "find"])
|
|
425
450
|
p.add_argument("term")
|
|
@@ -427,6 +452,7 @@ def run(argv: list[str], root: Path | None = None, cache_dir: Path | None = None
|
|
|
427
452
|
p.add_argument("--json", action="store_true", help="print hits as a JSON array")
|
|
428
453
|
a = p.parse_args(argv)
|
|
429
454
|
hits = query(a.root, a.command, a.term, cache_dir=cache_dir)
|
|
455
|
+
log_lookup(cache_dir or default_cache(), a.command, a.term, len(hits))
|
|
430
456
|
if a.json:
|
|
431
457
|
return json.dumps([asdict(h) for h in hits[: a.limit]], ensure_ascii=False)
|
|
432
458
|
lines = [fmt_hit(h) for h in hits]
|
|
@@ -438,5 +464,6 @@ def run(argv: list[str], root: Path | None = None, cache_dir: Path | None = None
|
|
|
438
464
|
|
|
439
465
|
|
|
440
466
|
if __name__ == "__main__":
|
|
441
|
-
sys.stdout.
|
|
467
|
+
if isinstance(sys.stdout, io.TextIOWrapper):
|
|
468
|
+
sys.stdout.reconfigure(encoding="utf-8")
|
|
442
469
|
print(run(sys.argv[1:]))
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""Robot Framework Mind desktop app."""
|
|
2
|
-
__version__ = "0.1.
|
|
2
|
+
__version__ = "0.1.6"
|
{robotframework_mind-0.1.5 → robotframework_mind-0.1.6/robotframework_mind.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: robotframework-mind
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
4
|
Summary: Exact lookups over a Robot Framework test repo: CLI and desktop UI
|
|
5
5
|
Author: Abdulwahab Isam
|
|
6
6
|
License-Expression: MIT
|
|
@@ -82,6 +82,9 @@ python path/to/robot_mind.py --root <repo> find /api/items/query
|
|
|
82
82
|
prints the hits as a JSON array (each with `kind`, `name`, `file`, `line`; a
|
|
83
83
|
`callers` hit also carries `call_line`).
|
|
84
84
|
|
|
85
|
+
Every lookup is appended to `lookups.jsonl` in the cache folder. `python robot_mind.py stats`
|
|
86
|
+
prints the lookup count, how many found something and the terms that found nothing.
|
|
87
|
+
|
|
85
88
|
## Desktop app
|
|
86
89
|
|
|
87
90
|
The same lookups in a window. Pick a repo (or a folder that holds several),
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Every CLI lookup is logged, and the log gives a hit rate and the missed terms."""
|
|
2
|
+
import json
|
|
3
|
+
import shutil
|
|
4
|
+
import tempfile
|
|
5
|
+
import unittest
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import robot_mind
|
|
9
|
+
|
|
10
|
+
FIXTURE = Path(__file__).parent / "fixture"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class LookupLogTests(unittest.TestCase):
|
|
14
|
+
def setUp(self):
|
|
15
|
+
self.tmp = Path(tempfile.mkdtemp())
|
|
16
|
+
self.cache = self.tmp / "cache"
|
|
17
|
+
self.root = self.tmp / "repo"
|
|
18
|
+
shutil.copytree(FIXTURE, self.root)
|
|
19
|
+
|
|
20
|
+
def tearDown(self):
|
|
21
|
+
shutil.rmtree(self.tmp, ignore_errors=True)
|
|
22
|
+
|
|
23
|
+
def lookup(self, command: str, term: str) -> str:
|
|
24
|
+
return robot_mind.run(["--root", str(self.root), command, term], cache_dir=self.cache)
|
|
25
|
+
|
|
26
|
+
def test_each_lookup_appends_one_line(self):
|
|
27
|
+
self.lookup("ticket", "PROJ-2120")
|
|
28
|
+
self.lookup("kw", "no such keyword anywhere")
|
|
29
|
+
lines = (self.cache / "lookups.jsonl").read_text(encoding="utf-8").splitlines()
|
|
30
|
+
rows = [json.loads(line) for line in lines]
|
|
31
|
+
self.assertEqual([(r["command"], r["hits"] > 0) for r in rows], [("ticket", True), ("kw", False)])
|
|
32
|
+
|
|
33
|
+
def test_stats_reports_rate_and_misses(self):
|
|
34
|
+
self.lookup("ticket", "PROJ-2120")
|
|
35
|
+
self.lookup("kw", "no such keyword anywhere")
|
|
36
|
+
stats = json.loads(robot_mind.run(["stats"], cache_dir=self.cache))
|
|
37
|
+
self.assertEqual((stats["lookups"], stats["answered"], stats["missed"]),
|
|
38
|
+
(2, 1, [{"command": "kw", "term": "no such keyword anywhere"}]))
|
|
39
|
+
|
|
40
|
+
def test_stats_without_log_is_zero(self):
|
|
41
|
+
stats = json.loads(robot_mind.run(["stats"], cache_dir=self.cache))
|
|
42
|
+
self.assertEqual((stats["lookups"], stats["answered"]), (0, 0))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
unittest.main()
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""A missing robotframework fails the run instead of filling the index with error entries."""
|
|
2
|
+
import unittest
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from unittest import mock
|
|
5
|
+
|
|
6
|
+
import robot_mind
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class MissingDependencyTests(unittest.TestCase):
|
|
10
|
+
def test_import_error_is_raised(self):
|
|
11
|
+
with mock.patch.object(robot_mind, "parse_robot", side_effect=ModuleNotFoundError("robot")):
|
|
12
|
+
with self.assertRaises(ModuleNotFoundError):
|
|
13
|
+
robot_mind.parse_file(Path("a.robot"), "a.robot")
|
|
14
|
+
|
|
15
|
+
def test_broken_file_still_yields_error_entry(self):
|
|
16
|
+
with mock.patch.object(robot_mind, "parse_robot", side_effect=ValueError("bad")):
|
|
17
|
+
entries = robot_mind.parse_file(Path("a.robot"), "a.robot")
|
|
18
|
+
self.assertEqual([e.kind for e in entries], ["error"])
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
if __name__ == "__main__":
|
|
22
|
+
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robotframework_mind.egg-info/requires.txt
RENAMED
|
File without changes
|
{robotframework_mind-0.1.5 → robotframework_mind-0.1.6}/robotframework_mind.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|