robotframework-mind 0.1.1__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.
@@ -0,0 +1,100 @@
1
+ """Slow work off the UI thread: a queued job worker, a coalesced refresh, and a newest-value-only handoff."""
2
+ import itertools
3
+ import threading
4
+ import time
5
+
6
+ from PySide6.QtCore import QObject, QThread, Signal, Slot
7
+
8
+
9
+ class Worker(QObject):
10
+ """Runs jobs on its own thread, one at a time, in the order they were submitted.
11
+
12
+ The UI takes a job id with reserve(), shows a pending row for it, then calls submit(); it fills the row in
13
+ when `finished` or `failed` arrives with that id. Reserving first means even a job that ends at once
14
+ (a direct connection, a cache hit) finds its row. Everything that touches one slow resource (a device,
15
+ a socket, a database file) goes through one worker, so calls never interleave."""
16
+
17
+ request = Signal(int, object) # (job id, callable)
18
+ finished = Signal(int, object) # (job id, result)
19
+ failed = Signal(int, str) # (job id, error text)
20
+ timed = Signal(int, float) # (job id, seconds the call took): measure, never guess, latency
21
+ poll = Signal()
22
+ refreshed = Signal(object)
23
+
24
+ def __init__(self, refresh=None):
25
+ super().__init__()
26
+ self._ids = itertools.count(1)
27
+ self._refresh, self._poll_queued = refresh, False
28
+ self.request.connect(self._run)
29
+ self.poll.connect(self._polled)
30
+
31
+ def reserve(self):
32
+ return next(self._ids)
33
+
34
+ def submit(self, call, job=None):
35
+ """Queues `call()` on the worker thread; returns its job id (safe to call from the UI thread)."""
36
+ job = self.reserve() if job is None else job
37
+ self.request.emit(job, call)
38
+ return job
39
+
40
+ @Slot(int, object)
41
+ def _run(self, job, call):
42
+ start = time.perf_counter()
43
+ try:
44
+ result = call()
45
+ except Exception as err: # a job failure is shown to the user, never raised into Qt
46
+ self.failed.emit(job, str(err) or type(err).__name__)
47
+ else:
48
+ self.finished.emit(job, result)
49
+ finally:
50
+ self.timed.emit(job, time.perf_counter() - start)
51
+
52
+ def request_poll(self):
53
+ """Queues one refresh unless one is already waiting: refreshes queued faster than they run would hold
54
+ every user action back behind them."""
55
+ if self._refresh and not self._poll_queued:
56
+ self._poll_queued = True
57
+ self.poll.emit()
58
+
59
+ @Slot()
60
+ def _polled(self):
61
+ self._poll_queued = False
62
+ try:
63
+ self.refreshed.emit(self._refresh())
64
+ except Exception as err:
65
+ self.failed.emit(0, f"Refresh failed: {err}")
66
+
67
+
68
+ def start(worker):
69
+ """Moves `worker` to a new running thread; call stop() with the result before the app quits."""
70
+ thread = QThread()
71
+ worker.moveToThread(thread)
72
+ thread.start()
73
+ return thread
74
+
75
+
76
+ def stop(thread, wait_ms=5000):
77
+ thread.quit()
78
+ thread.wait(wait_ms)
79
+
80
+
81
+ class Latest:
82
+ """Producer-to-UI handoff that keeps only the newest value, so a slow UI shows the latest, not a backlog.
83
+
84
+ The producer thread calls put(); it returns True only for the first value since the last take(), which is
85
+ when the producer should emit its "ready" signal. The UI slot calls take()."""
86
+
87
+ def __init__(self):
88
+ self._lock = threading.Lock()
89
+ self._value, self._signalled, self.at = None, False, 0.0
90
+
91
+ def put(self, value):
92
+ with self._lock:
93
+ self._value, self.at = value, time.monotonic()
94
+ first, self._signalled = not self._signalled, True
95
+ return first
96
+
97
+ def take(self):
98
+ with self._lock:
99
+ value, self._value, self._signalled = self._value, None, False
100
+ return value
@@ -0,0 +1,123 @@
1
+ Metadata-Version: 2.4
2
+ Name: robotframework-mind
3
+ Version: 0.1.1
4
+ Summary: Exact lookups over a Robot Framework test repo: CLI and desktop UI
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ License-File: NOTICE
8
+ Requires-Dist: robotframework>=7
9
+ Provides-Extra: gui
10
+ Requires-Dist: PySide6-Essentials>=6.12.0; extra == "gui"
11
+ Provides-Extra: dev
12
+ Requires-Dist: pytest>=9; extra == "dev"
13
+ Dynamic: license-file
14
+
15
+ # robotframework-mind
16
+
17
+ Exact lookups over a Robot Framework test repo, for people and scripts. Ask
18
+ which tests cover a ticket, who calls a keyword or where an endpoint is used,
19
+ and get one line per hit with its `file:line` instead of reading whole suites.
20
+
21
+ It indexes:
22
+
23
+ - tests: name, tags (`bug:PROJ-123`, `role:...`, `op:GET /api/...`), first doc line, keyword calls
24
+ - user keywords: name, arguments, first doc line, calls, variables used
25
+ - variables from `*** Variables ***` and inline `VAR` statements, with their values
26
+ - suite and test setup/teardown calls
27
+ - JSON files under `docs/`, one entry per object key
28
+
29
+ ## Requirements
30
+
31
+ Python 3.10+ and `robotframework` (the repo's own venv already has it). No
32
+ other packages.
33
+
34
+ ## Run
35
+
36
+ From the test repo's venv:
37
+
38
+ ```bash
39
+ python path/to/robot_mind.py --root <repo> ticket PROJ-123
40
+ python path/to/robot_mind.py --root <repo> kw "Open Profile Browser"
41
+ python path/to/robot_mind.py --root <repo> callers "Open Profile Browser"
42
+ python path/to/robot_mind.py --root <repo> tag role:role_quality_control
43
+ python path/to/robot_mind.py --root <repo> find /api/items/query
44
+ ```
45
+
46
+ | Command | Returns |
47
+ |---|---|
48
+ | `ticket KEY` | tests and keywords whose tags, name or doc mention the key |
49
+ | `kw NAME` | every definition, matched the way Robot matches names (case, spaces and underscores ignored) |
50
+ | `callers NAME` | each call site: keyword, test or suite fixture, at the call line; falls back to substring when no exact name matches |
51
+ | `tag TAG` | tests with that tag; `role:*` matches a prefix |
52
+ | `find TEXT` | names, tags, docs, args, values and JSON entries containing the text, then the keywords that use a matching variable |
53
+
54
+ `--limit N` caps the lines (default 20). No hit prints `no match`. `--json`
55
+ prints the hits as a JSON array (each with `kind`, `name`, `file`, `line`; a
56
+ `callers` hit also carries `call_line`).
57
+
58
+ ## Desktop app
59
+
60
+ The same lookups in a window. Pick a repo (or a folder that holds several),
61
+ choose what to search for, and get the hits as a table or as a graph of what
62
+ they call, use and hit. Open takes you to the file at the line in your editor.
63
+
64
+ ![Results table](docs/screenshots/table.png)
65
+
66
+ ![Graph of who calls a keyword, coloured by repo](docs/screenshots/graph.png)
67
+
68
+ Download a build from the releases page, or run it from source:
69
+
70
+ ```bash
71
+ pip install -e .[gui]
72
+ python -m robot_mind_app
73
+ ```
74
+
75
+ ## How it compares
76
+
77
+ Five questions on a real API test repo (553 Robot and JSON files, 9,930
78
+ indexed entries), answered three ways: this tool, a plain `grep -rn` over the
79
+ same files, and graphify 0.9.102 (`graphify update`, then `graphify query`
80
+ with the question in words). Sizes are characters of output; "files" is how
81
+ many of the files that hold the answer the output names.
82
+
83
+ | Question | robotframework-mind | grep | grep, then open the matched files | graphify query |
84
+ |---|---|---|---|---|
85
+ | tests for a ticket (7 hits in 2 files) | 1,570 chars, 2 of 2 files | 2,181, 2 of 2 | 18,611 | 17,328, 0 of 2 |
86
+ | where a keyword is defined (1) | 167, 1 of 1 | 3,290, 1 of 1 | 346,452 | 6,804, 1 of 1 |
87
+ | who calls that keyword (30 calls in 10 files) | 3,411, 10 of 10 | 3,290, 10 of 10 | 346,452 | 6,802, 3 of 10 |
88
+ | tests with a tag (60 in 27 files) | 41,107, 27 of 27 | 38,363, 27 of 27 | 136,226 | 6,704, 0 of 27 |
89
+ | where an endpoint is used (8 in 6 files) | 2,879, 6 of 6 | 1,935, 6 of 6 | 2,642,809 | 6,838, 0 of 6 |
90
+
91
+ grep finds the same files and its matched lines are about as short, but a
92
+ matched line is the tag or the call, not the test or keyword around it, so
93
+ the next step is opening the files: that is the third column. graphify's
94
+ `explain` does better on keywords (all 10 caller files in 3,564 characters)
95
+ but found nothing for the ticket, the tag or the endpoint.
96
+
97
+ Building the index took 2.3 s the first time and 0.25 s after that; the
98
+ graphify build of the same repo took 44.9 s.
99
+
100
+ ## How it stays current
101
+
102
+ The index lives in `~/.cache/robotframework-mind/`, one file per repo, never
103
+ in the repo. Each call compares file times and sizes and parses only changed
104
+ files. It reads each `.gitignore` on the way down (and `.git/info/exclude`)
105
+ itself, without calling git, so ignored probes and results stay out; a nested
106
+ repo follows only its own rules. Hidden folders, `node_modules`, `results` and
107
+ virtualenvs are skipped too. A file git tracks but a rule ignores is left out
108
+ as well. Files over the size cap are skipped: 5 MB for `docs/` JSON, 50 MB for
109
+ `.robot` and `.resource`.
110
+
111
+ ## Tests
112
+
113
+ ```bash
114
+ python -m unittest tests.test_where
115
+ ```
116
+
117
+ ## Credits
118
+
119
+ The parsing approach follows the Robot Framework extractor in
120
+ [graphify](https://github.com/Graphify-Labs/graphify) by Safi Shamsi
121
+ (Apache-2.0): Robot's own `robot.api` parser with a `ModelVisitor`, and
122
+ keyword names normalized the way Robot resolves them. No graphify code is
123
+ copied. See `NOTICE`.
@@ -0,0 +1,23 @@
1
+ robot_mind.py,sha256=Iu08M_lMIOtvGSrbSjb-8rqLXGaIbgf5J8oOxKnug00,17871
2
+ robot_mind_app/__init__.py,sha256=ADuDfiw_g7I_3e-_F2JtbaN8gUbxfHtjv-Yg2m8lrm4,62
3
+ robot_mind_app/__main__.py,sha256=sCZs-UJOjla-ZjuZH9sAkK7HdadIRHOQL73-7CzLjLQ,4558
4
+ robot_mind_app/community_panel.py,sha256=QR_9d7fgzUrKi4EfGN-ZkHo2KzDzhxC1UThPQXQUGUQ,4128
5
+ robot_mind_app/editors.py,sha256=oYaF_9FhVIW6LEqXyLkNGM6aFzGPByT0l-Lbu5ZjhVo,2545
6
+ robot_mind_app/engine.py,sha256=Teq1zSp5rS35TSY-qoZpc-U0gx_-dU6OA-6_ueD-aes,954
7
+ robot_mind_app/folders.py,sha256=bhTqAqMhHfKWtL4jJxrMHuOm8R1PrRlaWVuYBbs1ZPI,2185
8
+ robot_mind_app/graph.py,sha256=LvJu7RO23df-0mXbGs8ZnCzO2fn7gbx7qSNjWDbEHrY,4612
9
+ robot_mind_app/graph_layout.py,sha256=4cenuaxjNSyYTxkt34RUUeF0C1JdYAMMIrmiS5KBW0M,3910
10
+ robot_mind_app/graph_view.py,sha256=d7HIu-gWSNsSOUnM2m7gdtbw0ZCd09iQtcLvAEHAzxs,10729
11
+ robot_mind_app/icons.py,sha256=mdYNL39dOawEo9EHP4qwjnktIyiEJ5I2klDX509iMmo,6353
12
+ robot_mind_app/lucide.py,sha256=_G5kEoInhiCDpJWKgUo0Nng4ujjzZwsN45U5X1iTDQ8,6114
13
+ robot_mind_app/settings.py,sha256=WBzSUrfY9PolPu1yuH2F0650AXFK4XslWbg1ZlvDZ50,3424
14
+ robot_mind_app/theme.py,sha256=kfI_xCgNpuBBp0_iqlo0TSgH7LjRz0x23hC4hOSpLNU,13505
15
+ robot_mind_app/widgets.py,sha256=qeioI9pejp--u42Ehg0606VMoBRx-UtjZEF0N9JYJok,6088
16
+ robot_mind_app/window.py,sha256=yqlv2h2MDLYYjaIk95yVUUC1BJHSepayL24vzrA6aXs,28543
17
+ robot_mind_app/worker.py,sha256=_SjE1zcY7aLhzN6nshCSj4rCEjh18QD1tD0bH_a7Y34,3666
18
+ robotframework_mind-0.1.1.dist-info/licenses/NOTICE,sha256=H_UohxHhANaHM3lBUNmaixryllmdY6xS8MR4l-egDgw,426
19
+ robotframework_mind-0.1.1.dist-info/METADATA,sha256=Ic9qGEyaC52TvtcuRXcWg6RLlf-00GzVJqJmP_k1wHk,5371
20
+ robotframework_mind-0.1.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
21
+ robotframework_mind-0.1.1.dist-info/entry_points.txt,sha256=pPWXeniMUQCE1SnO2Td7EAl8N49IkPXtPdfkq43CyDQ,60
22
+ robotframework_mind-0.1.1.dist-info/top_level.txt,sha256=DKkp7vaziCQHrxdOmImRbs9V2fssUKmayho8EznzAKw,26
23
+ robotframework_mind-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [gui_scripts]
2
+ robot-mind-gui = robot_mind_app.__main__:main
@@ -0,0 +1,9 @@
1
+ robotframework-mind
2
+
3
+ Inspired by graphify (https://github.com/Graphify-Labs/graphify),
4
+ Copyright (c) 2026 Safi Shamsi, licensed under the Apache License 2.0.
5
+
6
+ The Robot Framework parsing approach (robot.api ModelVisitor over the
7
+ suite and resource models, keyword names normalized case-, space- and
8
+ underscore-insensitively) follows graphify's extractors/robot.py.
9
+ No source code from graphify is included in this repository.
@@ -0,0 +1,2 @@
1
+ robot_mind
2
+ robot_mind_app