naja-schematic 0.1.0__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.
- naja_schematic/__init__.py +21 -0
- naja_schematic/__main__.py +3 -0
- naja_schematic/_bundle.py +31 -0
- naja_schematic/protocol.py +711 -0
- naja_schematic/server.py +269 -0
- naja_schematic/static/index.html +34 -0
- naja_schematic/static/naja-schematic.js +2 -0
- naja_schematic/static/widget.js +81 -0
- naja_schematic/widget.py +92 -0
- naja_schematic-0.1.0.dist-info/METADATA +80 -0
- naja_schematic-0.1.0.dist-info/RECORD +14 -0
- naja_schematic-0.1.0.dist-info/WHEEL +4 -0
- naja_schematic-0.1.0.dist-info/entry_points.txt +2 -0
- naja_schematic-0.1.0.dist-info/licenses/LICENSE +204 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""naja-schematic: interactive schematic viewer for najaeda netlists.
|
|
2
|
+
|
|
3
|
+
- In a notebook (Jupyter, Colab, VSCode): ``naja_schematic.show()`` displays
|
|
4
|
+
the design currently loaded with najaeda.
|
|
5
|
+
- From a shell: ``naja-schematic --verilog design.v --open`` serves the
|
|
6
|
+
viewer page and opens it in a browser.
|
|
7
|
+
"""
|
|
8
|
+
__version__ = "0.1.0"
|
|
9
|
+
|
|
10
|
+
from .protocol import diagnosis_response, handle_request
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def show(height=600, diagnosis=None):
|
|
14
|
+
"""Display a view of the loaded design in the current notebook; see
|
|
15
|
+
naja_schematic.widget.show()."""
|
|
16
|
+
# Imported lazily: the CLI/server path doesn't need anywidget/IPython.
|
|
17
|
+
from .widget import show as _show
|
|
18
|
+
return _show(height=height, diagnosis=diagnosis)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
__all__ = ["__version__", "show", "handle_request", "diagnosis_response"]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Locating the viewer files shipped in static/.
|
|
2
|
+
|
|
3
|
+
naja-schematic.js is the WASM viewer built as a single-file, modularized
|
|
4
|
+
Emscripten bundle (-DNAJA_SCHEMATIC_WASM_MODULE=ON); release wheels carry it
|
|
5
|
+
in static/, but it is a build product and not checked in. For a development
|
|
6
|
+
checkout, point NAJA_SCHEMATIC_BUNDLE at a locally built one instead.
|
|
7
|
+
"""
|
|
8
|
+
import os
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
STATIC_DIR = Path(__file__).parent / "static"
|
|
12
|
+
BUNDLE_NAME = "naja-schematic.js"
|
|
13
|
+
|
|
14
|
+
# The only files the HTTP server hands out (no path traversal to worry about).
|
|
15
|
+
_SERVED = {"index.html", BUNDLE_NAME}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def bundle_path():
|
|
19
|
+
"""Path of the viewer bundle, or None if this install has none."""
|
|
20
|
+
override = os.environ.get("NAJA_SCHEMATIC_BUNDLE")
|
|
21
|
+
path = Path(override) if override else STATIC_DIR / BUNDLE_NAME
|
|
22
|
+
return path if path.is_file() else None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def static_file(name):
|
|
26
|
+
if name not in _SERVED:
|
|
27
|
+
return None
|
|
28
|
+
if name == BUNDLE_NAME:
|
|
29
|
+
return bundle_path()
|
|
30
|
+
path = STATIC_DIR / name
|
|
31
|
+
return path if path.is_file() else None
|