raedir 0.1.0__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.
- raedir-0.1.0/.gitignore +14 -0
- raedir-0.1.0/LICENSE +21 -0
- raedir-0.1.0/PKG-INFO +73 -0
- raedir-0.1.0/README.md +59 -0
- raedir-0.1.0/pyproject.toml +26 -0
- raedir-0.1.0/src/raedir/__init__.py +3 -0
- raedir-0.1.0/src/raedir/__main__.py +83 -0
- raedir-0.1.0/src/raedir/accessibility.py +131 -0
- raedir-0.1.0/src/raedir/app.py +583 -0
- raedir-0.1.0/src/raedir/config.py +90 -0
- raedir-0.1.0/src/raedir/downloader.py +144 -0
- raedir-0.1.0/src/raedir/kicad_paths.py +223 -0
- raedir-0.1.0/src/raedir/kicad_session.py +720 -0
- raedir-0.1.0/src/raedir/lib_tables.py +95 -0
- raedir-0.1.0/src/raedir/library.py +190 -0
- raedir-0.1.0/src/raedir/place_schematic.py +387 -0
- raedir-0.1.0/src/raedir/setup_wizard.py +64 -0
- raedir-0.1.0/src/raedir/theme.py +140 -0
- raedir-0.1.0/src/raedir/util.py +25 -0
- raedir-0.1.0/tests/test_library.py +30 -0
raedir-0.1.0/.gitignore
ADDED
raedir-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Raedir contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
raedir-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: raedir
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Terminal GUI for downloading JLCPCB/LCSC parts into KiCad via easyeda2kicad
|
|
5
|
+
Project-URL: Homepage, https://github.com/raedir/raedir
|
|
6
|
+
Author: Raedir
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: easyeda,jlcpcb,kicad,lcsc,tui
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Requires-Dist: easyeda2kicad>=1.0.0
|
|
12
|
+
Requires-Dist: textual>=1.0.0
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# Raedir
|
|
16
|
+
|
|
17
|
+
Terminal GUI for pulling JLCPCB / LCSC parts into KiCad — wrap `easyeda2kicad`, browse your library, and optionally restart KiCad so new parts show up immediately.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Recommended (isolated CLI on your PATH):
|
|
21
|
+
pipx install raedir
|
|
22
|
+
|
|
23
|
+
# Or from a clone:
|
|
24
|
+
cd ~/Projects/Raedir
|
|
25
|
+
pipx install -e .
|
|
26
|
+
|
|
27
|
+
# Dev install in a venv:
|
|
28
|
+
python3 -m venv .venv && source .venv/bin/activate
|
|
29
|
+
pip install -e .
|
|
30
|
+
|
|
31
|
+
raedir
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## What it does
|
|
35
|
+
|
|
36
|
+
- **Add parts** — paste an LCSC id (`C2040`) and download symbol + footprint + 3D
|
|
37
|
+
- **Browse library** — search your `easyeda2kicad` library, sort by recently added / similar footprints
|
|
38
|
+
- **Find KiCad** — locates KiCad’s Python, `easyeda2kicad`, and the parts folder on any machine
|
|
39
|
+
- **Reload KiCad** — saves open work, quits, reopens the same project, restores window layout (macOS)
|
|
40
|
+
|
|
41
|
+
## First-time setup
|
|
42
|
+
|
|
43
|
+
1. Install Raedir (`pip install raedir` or `pipx install raedir`)
|
|
44
|
+
2. Run `raedir` — on first launch it will:
|
|
45
|
+
- search for KiCad / `easyeda2kicad`
|
|
46
|
+
- offer to install `easyeda2kicad` into KiCad’s Python if missing
|
|
47
|
+
- create `~/Documents/KiCad/easyeda2kicad/` if needed
|
|
48
|
+
- ensure the library is registered in KiCad’s global lib tables
|
|
49
|
+
3. Type `raedir` anytime from a terminal
|
|
50
|
+
|
|
51
|
+
## UI
|
|
52
|
+
|
|
53
|
+
Left panel buttons:
|
|
54
|
+
|
|
55
|
+
- **Add part** — download by LCSC id / URL
|
|
56
|
+
- **Place on schematic** — drop the selected part onto the open KiCad schematic
|
|
57
|
+
- **Open datasheet** — open the selected part’s datasheet
|
|
58
|
+
- **Open in Finder / Explorer** — opens the parts library folder
|
|
59
|
+
- **Reload KiCad** — save → quit → reopen editors + restore windows
|
|
60
|
+
|
|
61
|
+
Click any column header to sort ascending/descending. Theme follows system light/dark.
|
|
62
|
+
|
|
63
|
+
## Config
|
|
64
|
+
|
|
65
|
+
Stored in `~/.config/raedir/config.json` (paths, auto-reload preference, history).
|
|
66
|
+
|
|
67
|
+
## macOS notes
|
|
68
|
+
|
|
69
|
+
**Place on schematic** and **Reload KiCad** need Accessibility (Assistive Access). If permission is missing, Raedir opens a prompt with an **Open Settings** button.
|
|
70
|
+
|
|
71
|
+
Enable the app that runs `raedir` under **System Settings → Privacy & Security → Accessibility** (Terminal, iTerm, Cursor, etc.), then retry.
|
|
72
|
+
|
|
73
|
+
Reload reopens the same project **and** any Schematic / PCB editor windows that were open, then restores their positions.
|
raedir-0.1.0/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Raedir
|
|
2
|
+
|
|
3
|
+
Terminal GUI for pulling JLCPCB / LCSC parts into KiCad — wrap `easyeda2kicad`, browse your library, and optionally restart KiCad so new parts show up immediately.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# Recommended (isolated CLI on your PATH):
|
|
7
|
+
pipx install raedir
|
|
8
|
+
|
|
9
|
+
# Or from a clone:
|
|
10
|
+
cd ~/Projects/Raedir
|
|
11
|
+
pipx install -e .
|
|
12
|
+
|
|
13
|
+
# Dev install in a venv:
|
|
14
|
+
python3 -m venv .venv && source .venv/bin/activate
|
|
15
|
+
pip install -e .
|
|
16
|
+
|
|
17
|
+
raedir
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## What it does
|
|
21
|
+
|
|
22
|
+
- **Add parts** — paste an LCSC id (`C2040`) and download symbol + footprint + 3D
|
|
23
|
+
- **Browse library** — search your `easyeda2kicad` library, sort by recently added / similar footprints
|
|
24
|
+
- **Find KiCad** — locates KiCad’s Python, `easyeda2kicad`, and the parts folder on any machine
|
|
25
|
+
- **Reload KiCad** — saves open work, quits, reopens the same project, restores window layout (macOS)
|
|
26
|
+
|
|
27
|
+
## First-time setup
|
|
28
|
+
|
|
29
|
+
1. Install Raedir (`pip install raedir` or `pipx install raedir`)
|
|
30
|
+
2. Run `raedir` — on first launch it will:
|
|
31
|
+
- search for KiCad / `easyeda2kicad`
|
|
32
|
+
- offer to install `easyeda2kicad` into KiCad’s Python if missing
|
|
33
|
+
- create `~/Documents/KiCad/easyeda2kicad/` if needed
|
|
34
|
+
- ensure the library is registered in KiCad’s global lib tables
|
|
35
|
+
3. Type `raedir` anytime from a terminal
|
|
36
|
+
|
|
37
|
+
## UI
|
|
38
|
+
|
|
39
|
+
Left panel buttons:
|
|
40
|
+
|
|
41
|
+
- **Add part** — download by LCSC id / URL
|
|
42
|
+
- **Place on schematic** — drop the selected part onto the open KiCad schematic
|
|
43
|
+
- **Open datasheet** — open the selected part’s datasheet
|
|
44
|
+
- **Open in Finder / Explorer** — opens the parts library folder
|
|
45
|
+
- **Reload KiCad** — save → quit → reopen editors + restore windows
|
|
46
|
+
|
|
47
|
+
Click any column header to sort ascending/descending. Theme follows system light/dark.
|
|
48
|
+
|
|
49
|
+
## Config
|
|
50
|
+
|
|
51
|
+
Stored in `~/.config/raedir/config.json` (paths, auto-reload preference, history).
|
|
52
|
+
|
|
53
|
+
## macOS notes
|
|
54
|
+
|
|
55
|
+
**Place on schematic** and **Reload KiCad** need Accessibility (Assistive Access). If permission is missing, Raedir opens a prompt with an **Open Settings** button.
|
|
56
|
+
|
|
57
|
+
Enable the app that runs `raedir` under **System Settings → Privacy & Security → Accessibility** (Terminal, iTerm, Cursor, etc.), then retry.
|
|
58
|
+
|
|
59
|
+
Reload reopens the same project **and** any Schematic / PCB editor windows that were open, then restores their positions.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "raedir"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Terminal GUI for downloading JLCPCB/LCSC parts into KiCad via easyeda2kicad"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [{ name = "Raedir" }]
|
|
13
|
+
keywords = ["kicad", "jlcpcb", "lcsc", "easyeda", "tui"]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"textual>=1.0.0",
|
|
16
|
+
"easyeda2kicad>=1.0.0",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.scripts]
|
|
20
|
+
raedir = "raedir.__main__:main"
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Homepage = "https://github.com/raedir/raedir"
|
|
24
|
+
|
|
25
|
+
[tool.hatch.build.targets.wheel]
|
|
26
|
+
packages = ["src/raedir"]
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""CLI entry: `python -m raedir` / `raedir`."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main(argv: list[str] | None = None) -> int:
|
|
10
|
+
parser = argparse.ArgumentParser(
|
|
11
|
+
prog="raedir",
|
|
12
|
+
description="Terminal GUI for downloading JLCPCB/LCSC parts into KiCad",
|
|
13
|
+
)
|
|
14
|
+
parser.add_argument(
|
|
15
|
+
"--setup",
|
|
16
|
+
action="store_true",
|
|
17
|
+
help="Run path discovery / easyeda2kicad install and exit",
|
|
18
|
+
)
|
|
19
|
+
parser.add_argument(
|
|
20
|
+
"--add",
|
|
21
|
+
metavar="LCSC_ID",
|
|
22
|
+
help="Download a part without opening the TUI",
|
|
23
|
+
)
|
|
24
|
+
parser.add_argument(
|
|
25
|
+
"--no-reload",
|
|
26
|
+
action="store_true",
|
|
27
|
+
help="Skip KiCad reload after --add",
|
|
28
|
+
)
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
"--version",
|
|
31
|
+
action="store_true",
|
|
32
|
+
help="Print version and exit",
|
|
33
|
+
)
|
|
34
|
+
args = parser.parse_args(argv)
|
|
35
|
+
|
|
36
|
+
if args.version:
|
|
37
|
+
from raedir import __version__
|
|
38
|
+
|
|
39
|
+
print(__version__)
|
|
40
|
+
return 0
|
|
41
|
+
|
|
42
|
+
from raedir.config import load_config, save_config
|
|
43
|
+
from raedir.setup_wizard import ensure_ready
|
|
44
|
+
|
|
45
|
+
config = load_config()
|
|
46
|
+
status = ensure_ready(
|
|
47
|
+
config,
|
|
48
|
+
interactive=sys.stdin.isatty(),
|
|
49
|
+
verbose=bool(args.setup),
|
|
50
|
+
)
|
|
51
|
+
save_config(config)
|
|
52
|
+
|
|
53
|
+
if not status.ok:
|
|
54
|
+
print(status.message, file=sys.stderr)
|
|
55
|
+
return 1
|
|
56
|
+
|
|
57
|
+
if args.setup:
|
|
58
|
+
print(status.message or "Ready.")
|
|
59
|
+
return 0
|
|
60
|
+
|
|
61
|
+
if args.add:
|
|
62
|
+
from raedir.downloader import download_part
|
|
63
|
+
from raedir.kicad_session import reload_kicad
|
|
64
|
+
|
|
65
|
+
result = download_part(args.add, config)
|
|
66
|
+
print(result.message)
|
|
67
|
+
if not result.ok:
|
|
68
|
+
return 1
|
|
69
|
+
if not args.no_reload and config.auto_reload_kicad:
|
|
70
|
+
reload = reload_kicad()
|
|
71
|
+
print(reload.message)
|
|
72
|
+
return 0 if reload.ok else 2
|
|
73
|
+
return 0
|
|
74
|
+
|
|
75
|
+
from raedir.app import run_app
|
|
76
|
+
|
|
77
|
+
run_app(config)
|
|
78
|
+
save_config(config)
|
|
79
|
+
return 0
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
if __name__ == "__main__":
|
|
83
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"""macOS Accessibility (assistive access) checks and prompts."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import platform
|
|
6
|
+
import subprocess
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
ACCESSIBILITY_ERROR_MARKERS = (
|
|
11
|
+
"not allowed assistive access",
|
|
12
|
+
"not authorized to send keystrokes",
|
|
13
|
+
"osascript is not allowed",
|
|
14
|
+
"assistive access",
|
|
15
|
+
"1002", # error code often seen for AX denial
|
|
16
|
+
"-1719",
|
|
17
|
+
"-25211",
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass
|
|
22
|
+
class AccessibilityStatus:
|
|
23
|
+
trusted: bool
|
|
24
|
+
detail: str = ""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def is_accessibility_error(message: str) -> bool:
|
|
28
|
+
lower = message.lower()
|
|
29
|
+
return any(marker in lower for marker in ACCESSIBILITY_ERROR_MARKERS)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def check_accessibility() -> AccessibilityStatus:
|
|
33
|
+
"""Return whether this process can control other apps via System Events."""
|
|
34
|
+
if platform.system() != "Darwin":
|
|
35
|
+
return AccessibilityStatus(True, "not macOS")
|
|
36
|
+
|
|
37
|
+
# Prefer the official AX API when available
|
|
38
|
+
try:
|
|
39
|
+
from ApplicationServices import AXIsProcessTrusted # type: ignore
|
|
40
|
+
|
|
41
|
+
trusted = bool(AXIsProcessTrusted())
|
|
42
|
+
return AccessibilityStatus(trusted, "AXIsProcessTrusted")
|
|
43
|
+
except Exception:
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
try:
|
|
47
|
+
import ctypes
|
|
48
|
+
import ctypes.util
|
|
49
|
+
|
|
50
|
+
path = ctypes.util.find_library("ApplicationServices") or ctypes.util.find_library(
|
|
51
|
+
"CoreFoundation"
|
|
52
|
+
)
|
|
53
|
+
if path:
|
|
54
|
+
lib = ctypes.cdll.LoadLibrary(path)
|
|
55
|
+
if hasattr(lib, "AXIsProcessTrusted"):
|
|
56
|
+
lib.AXIsProcessTrusted.restype = ctypes.c_bool
|
|
57
|
+
trusted = bool(lib.AXIsProcessTrusted())
|
|
58
|
+
return AccessibilityStatus(trusted, "ctypes AXIsProcessTrusted")
|
|
59
|
+
except Exception:
|
|
60
|
+
pass
|
|
61
|
+
|
|
62
|
+
# Probe System Events — fails loudly without Accessibility
|
|
63
|
+
proc = subprocess.run(
|
|
64
|
+
[
|
|
65
|
+
"osascript",
|
|
66
|
+
"-e",
|
|
67
|
+
'tell application "System Events" to get name of first process',
|
|
68
|
+
],
|
|
69
|
+
capture_output=True,
|
|
70
|
+
text=True,
|
|
71
|
+
check=False,
|
|
72
|
+
)
|
|
73
|
+
if proc.returncode == 0 and proc.stdout.strip():
|
|
74
|
+
return AccessibilityStatus(True, "System Events probe ok")
|
|
75
|
+
|
|
76
|
+
err = (proc.stderr or proc.stdout or "System Events probe failed").strip()
|
|
77
|
+
if is_accessibility_error(err) or proc.returncode != 0:
|
|
78
|
+
return AccessibilityStatus(False, err)
|
|
79
|
+
return AccessibilityStatus(False, err)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def open_accessibility_settings() -> bool:
|
|
83
|
+
"""Open System Settings to the Accessibility privacy pane."""
|
|
84
|
+
if platform.system() != "Darwin":
|
|
85
|
+
return False
|
|
86
|
+
|
|
87
|
+
urls = [
|
|
88
|
+
# Sequoia / Sonoma style
|
|
89
|
+
"x-apple.systempreferences:com.apple.settings.PrivacySecurity.extension?Privacy_Accessibility",
|
|
90
|
+
# Older macOS
|
|
91
|
+
"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility",
|
|
92
|
+
]
|
|
93
|
+
for url in urls:
|
|
94
|
+
proc = subprocess.run(["open", url], capture_output=True, check=False)
|
|
95
|
+
if proc.returncode == 0:
|
|
96
|
+
return True
|
|
97
|
+
|
|
98
|
+
# Last resort: open Privacy & Security root
|
|
99
|
+
subprocess.run(
|
|
100
|
+
["open", "/System/Library/PreferencePanes/Security.prefPane"],
|
|
101
|
+
check=False,
|
|
102
|
+
)
|
|
103
|
+
return True
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def terminal_app_hint() -> str:
|
|
107
|
+
"""Best-effort name of the host terminal for the permission prompt."""
|
|
108
|
+
import os
|
|
109
|
+
|
|
110
|
+
term_program = os.environ.get("TERM_PROGRAM", "")
|
|
111
|
+
mapping = {
|
|
112
|
+
"Apple_Terminal": "Terminal",
|
|
113
|
+
"iTerm.app": "iTerm",
|
|
114
|
+
"WarpTerminal": "Warp",
|
|
115
|
+
"ghostty": "Ghostty",
|
|
116
|
+
"WezTerm": "WezTerm",
|
|
117
|
+
"alacritty": "Alacritty",
|
|
118
|
+
"vscode": "Cursor",
|
|
119
|
+
"Cursor": "Cursor",
|
|
120
|
+
}
|
|
121
|
+
if term_program in mapping:
|
|
122
|
+
return mapping[term_program]
|
|
123
|
+
# Cursor / VS Code embedded terminals often omit TERM_PROGRAM
|
|
124
|
+
env_blob = " ".join(
|
|
125
|
+
f"{k}={v}" for k, v in os.environ.items() if "CURSOR" in k.upper() or k.startswith("VSCODE")
|
|
126
|
+
)
|
|
127
|
+
if "CURSOR" in env_blob.upper() or os.environ.get("CURSOR_TRACE_ID"):
|
|
128
|
+
return "Cursor"
|
|
129
|
+
if os.environ.get("VSCODE_INJECTION") or os.environ.get("TERM_PROGRAM_VERSION"):
|
|
130
|
+
return "Cursor"
|
|
131
|
+
return "Terminal (or Cursor, if you launch Raedir from there)"
|