resrijan 0.6.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.
- resrijan/__init__.py +17 -0
- resrijan/__main__.py +3 -0
- resrijan/_platform.py +54 -0
- resrijan/_winlaunch.py +92 -0
- resrijan/analysis.py +662 -0
- resrijan/anomaly.py +83 -0
- resrijan/cli.py +731 -0
- resrijan/curvefit.py +606 -0
- resrijan/detect/__init__.py +0 -0
- resrijan/detect/axes.py +378 -0
- resrijan/detect/calibration.py +269 -0
- resrijan/detect/ocr.py +290 -0
- resrijan/detect/vector.py +640 -0
- resrijan/extract/__init__.py +0 -0
- resrijan/extract/bars.py +318 -0
- resrijan/extract/curves.py +658 -0
- resrijan/extract/heatmap.py +416 -0
- resrijan/extract/imagefig.py +1452 -0
- resrijan/extract/micrograph.py +286 -0
- resrijan/extract/vector_series.py +431 -0
- resrijan/gui/__init__.py +48 -0
- resrijan/gui/assets/down.svg +1 -0
- resrijan/gui/assets/resrijan-icon-512.png +0 -0
- resrijan/gui/assets/resrijan-icon.svg +29 -0
- resrijan/gui/assets/resrijan-logo-dark-calligraphic.svg +34 -0
- resrijan/gui/assets/up.svg +1 -0
- resrijan/gui/desktop.py +49 -0
- resrijan/gui/editor.py +658 -0
- resrijan/gui/icons.py +77 -0
- resrijan/gui/jobs.py +128 -0
- resrijan/gui/mainwindow.py +338 -0
- resrijan/gui/pages/__init__.py +0 -0
- resrijan/gui/pages/analyze.py +496 -0
- resrijan/gui/pages/base.py +112 -0
- resrijan/gui/pages/compose.py +244 -0
- resrijan/gui/pages/digitize.py +673 -0
- resrijan/gui/pages/fit.py +544 -0
- resrijan/gui/pages/inspect.py +143 -0
- resrijan/gui/pages/plot.py +392 -0
- resrijan/gui/pages/settings.py +168 -0
- resrijan/gui/pages/templates.py +234 -0
- resrijan/gui/prefs.py +57 -0
- resrijan/gui/project.py +76 -0
- resrijan/gui/render.py +98 -0
- resrijan/gui/style.py +278 -0
- resrijan/gui/templates_io.py +110 -0
- resrijan/gui/textedit.py +278 -0
- resrijan/gui/theme.py +159 -0
- resrijan/gui/widgets.py +492 -0
- resrijan/io/__init__.py +0 -0
- resrijan/io/loader.py +290 -0
- resrijan/pipeline.py +1403 -0
- resrijan/plot/__init__.py +0 -0
- resrijan/plot/engine.py +786 -0
- resrijan/plot/layout.py +97 -0
- resrijan/plot/templates.py +159 -0
- resrijan/report.py +273 -0
- resrijan/templates/acs.yaml +25 -0
- resrijan/templates/aps.yaml +24 -0
- resrijan/templates/jcp.yaml +30 -0
- resrijan/templates/natchem.yaml +24 -0
- resrijan/templates/pnas.yaml +23 -0
- resrijan/templates/presentation.yaml +22 -0
- resrijan/templates/rsc.yaml +23 -0
- resrijan/templates/science.yaml +24 -0
- resrijan-0.6.0.dist-info/METADATA +313 -0
- resrijan-0.6.0.dist-info/RECORD +71 -0
- resrijan-0.6.0.dist-info/WHEEL +5 -0
- resrijan-0.6.0.dist-info/entry_points.txt +5 -0
- resrijan-0.6.0.dist-info/licenses/LICENSE +244 -0
- resrijan-0.6.0.dist-info/top_level.txt +1 -0
resrijan/__init__.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""ReSrijan (पुनःसृजन, "re-creation") – digitise, analyse, fit and redraw scientific figures in journal style."""
|
|
2
|
+
__version__ = "0.6.0"
|
|
3
|
+
|
|
4
|
+
from ._platform import setup_bundled_tools as _setup_tools # noqa: E402
|
|
5
|
+
|
|
6
|
+
_setup_tools() # Windows installer: bundled Tesseract / Ghostscript
|
|
7
|
+
|
|
8
|
+
__all__ = ["digitize", "write_outputs", "__version__"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def __getattr__(name):
|
|
12
|
+
"""``resrijan.digitize`` / ``resrijan.write_outputs`` are imported on first use, so that
|
|
13
|
+
``import resrijan`` (the GUI launcher, ``--version``) stays light and cannot fail on a library."""
|
|
14
|
+
if name in ("digitize", "write_outputs"):
|
|
15
|
+
from . import pipeline
|
|
16
|
+
return getattr(pipeline, name)
|
|
17
|
+
raise AttributeError(f"module 'resrijan' has no attribute {name!r}")
|
resrijan/__main__.py
ADDED
resrijan/_platform.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Platform helpers: run external programs without console windows on Windows, and find the
|
|
2
|
+
Tesseract and Ghostscript copies that the Windows installer ships next to ReSrijan."""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import subprocess
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
WINDOWS = sys.platform.startswith("win")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def run(cmd, **kw) -> subprocess.CompletedProcess:
|
|
14
|
+
"""subprocess.run that never opens a console window on Windows (the GUI has none)."""
|
|
15
|
+
if WINDOWS:
|
|
16
|
+
kw.setdefault("creationflags", getattr(subprocess, "CREATE_NO_WINDOW", 0x08000000))
|
|
17
|
+
return subprocess.run(cmd, **kw)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _tool_roots():
|
|
21
|
+
env = os.environ.get("RESRIJAN_TOOLS")
|
|
22
|
+
if env:
|
|
23
|
+
yield Path(env)
|
|
24
|
+
exe = Path(sys.executable).resolve().parent
|
|
25
|
+
for base in (exe, exe.parent): # pynsist: <app>\\Python\\python.exe, tools in <app>\\tools
|
|
26
|
+
yield base / "tools"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def setup_bundled_tools() -> None:
|
|
30
|
+
"""Put bundled Tesseract/Ghostscript on PATH (only if a 'tools' folder exists, i.e. in the
|
|
31
|
+
Windows installation, or when RESRIJAN_TOOLS points to one)."""
|
|
32
|
+
for root in _tool_roots():
|
|
33
|
+
if not root.is_dir():
|
|
34
|
+
continue
|
|
35
|
+
extra = []
|
|
36
|
+
tess = root / "tesseract"
|
|
37
|
+
if (tess / ("tesseract.exe" if WINDOWS else "tesseract")).exists():
|
|
38
|
+
extra.append(str(tess))
|
|
39
|
+
if (tess / "tessdata").is_dir():
|
|
40
|
+
os.environ.setdefault("TESSDATA_PREFIX", str(tess / "tessdata"))
|
|
41
|
+
gs = root / "gs" / "bin"
|
|
42
|
+
if gs.is_dir():
|
|
43
|
+
extra.append(str(gs))
|
|
44
|
+
if extra:
|
|
45
|
+
os.environ["PATH"] = os.pathsep.join(extra + [os.environ.get("PATH", "")])
|
|
46
|
+
return
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def user_config_dir() -> Path:
|
|
50
|
+
"""Folder for the user's own files (journal templates): %APPDATA%\\resrijan on Windows,
|
|
51
|
+
$XDG_CONFIG_HOME/resrijan or ~/.config/resrijan elsewhere."""
|
|
52
|
+
if WINDOWS and os.environ.get("APPDATA"):
|
|
53
|
+
return Path(os.environ["APPDATA"]) / "resrijan"
|
|
54
|
+
return Path(os.environ.get("XDG_CONFIG_HOME") or os.path.expanduser("~/.config")) / "resrijan"
|
resrijan/_winlaunch.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""Start the GUI from a Windows shortcut.
|
|
2
|
+
|
|
3
|
+
Shortcuts run ``pythonw.exe``, which has no console: an error during start-up would close the
|
|
4
|
+
program silently. This launcher writes everything (Python errors, Qt messages and even native
|
|
5
|
+
crashes) to ``%LOCALAPPDATA%\\ReSrijan\\logs\\gui.log`` and shows a message box with the error
|
|
6
|
+
and the log's location when ReSrijan cannot start.
|
|
7
|
+
|
|
8
|
+
Only the standard library is imported before the log is open.
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import datetime
|
|
13
|
+
import faulthandler
|
|
14
|
+
import os
|
|
15
|
+
import platform
|
|
16
|
+
import sys
|
|
17
|
+
import traceback
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def log_dir() -> Path:
|
|
22
|
+
base = os.environ.get("LOCALAPPDATA") or os.environ.get("XDG_STATE_HOME") or str(Path.home() / ".local" / "state")
|
|
23
|
+
d = Path(base) / "ReSrijan" / "logs"
|
|
24
|
+
d.mkdir(parents=True, exist_ok=True)
|
|
25
|
+
return d
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _message_box(title: str, text: str):
|
|
29
|
+
if sys.platform.startswith("win"):
|
|
30
|
+
try:
|
|
31
|
+
import ctypes
|
|
32
|
+
ctypes.windll.user32.MessageBoxW(None, text, title, 0x10 | 0x10000) # error icon, foreground
|
|
33
|
+
return
|
|
34
|
+
except Exception: # noqa: BLE001
|
|
35
|
+
pass
|
|
36
|
+
sys.__stderr__ and sys.__stderr__.write(f"{title}\n{text}\n")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def main(argv=None) -> int:
|
|
40
|
+
argv = list(sys.argv[1:] if argv is None else argv)
|
|
41
|
+
path = log_dir() / "gui.log"
|
|
42
|
+
log = open(path, "w", encoding="utf-8", buffering=1) # noqa: SIM115 – open for the whole session
|
|
43
|
+
if sys.stdout is None:
|
|
44
|
+
sys.stdout = log
|
|
45
|
+
if sys.stderr is None:
|
|
46
|
+
sys.stderr = log
|
|
47
|
+
faulthandler.enable(log) # native crashes (DLLs, Qt) end up in the log
|
|
48
|
+
log.write(f"ReSrijan GUI start {datetime.datetime.now().isoformat(timespec='seconds')}\n"
|
|
49
|
+
f"python {sys.version}\nexecutable {sys.executable}\nprefix {sys.prefix}\n"
|
|
50
|
+
f"platform {platform.platform()}\ncwd {os.getcwd()}\nargs {argv}\n"
|
|
51
|
+
f"QT_PLUGIN_PATH={os.environ.get('QT_PLUGIN_PATH', '')}\n"
|
|
52
|
+
f"PATH (first entries)={os.pathsep.join(os.environ.get('PATH', '').split(os.pathsep)[:6])}\n\n")
|
|
53
|
+
try:
|
|
54
|
+
try:
|
|
55
|
+
from PySide6.QtCore import qInstallMessageHandler
|
|
56
|
+
|
|
57
|
+
def qt_msg(kind, ctx, msg):
|
|
58
|
+
log.write(f"[Qt {int(kind) if hasattr(kind, '__int__') else kind}] {msg}\n")
|
|
59
|
+
qInstallMessageHandler(qt_msg)
|
|
60
|
+
except Exception: # noqa: BLE001 – reported by the import below
|
|
61
|
+
pass
|
|
62
|
+
from resrijan.gui import main as gui_main
|
|
63
|
+
rc = gui_main(argv)
|
|
64
|
+
log.write(f"\nexit code {rc}\n")
|
|
65
|
+
if rc:
|
|
66
|
+
log.flush()
|
|
67
|
+
_message_box("ReSrijan could not start",
|
|
68
|
+
_tail(path) + f"\n\nThe full log is in:\n{path}")
|
|
69
|
+
return rc or 0
|
|
70
|
+
except SystemExit as exc:
|
|
71
|
+
return int(exc.code or 0) if not isinstance(exc.code, str) else 1
|
|
72
|
+
except BaseException: # noqa: BLE001 – show every start-up failure
|
|
73
|
+
tb = traceback.format_exc()
|
|
74
|
+
log.write("\n" + tb)
|
|
75
|
+
log.flush()
|
|
76
|
+
_message_box("ReSrijan could not start",
|
|
77
|
+
tb.strip().splitlines()[-1] + "\n\n" + _tail(path, 25) +
|
|
78
|
+
f"\n\nThe full log is in:\n{path}\n\nPlease send this file to the ReSrijan team. "
|
|
79
|
+
"The Start-menu entry 'ReSrijan – troubleshoot' shows more.")
|
|
80
|
+
return 1
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _tail(path: Path, n: int = 15) -> str:
|
|
84
|
+
try:
|
|
85
|
+
lines = path.read_text(encoding="utf-8", errors="replace").splitlines()
|
|
86
|
+
return "\n".join(lines[-n:])
|
|
87
|
+
except OSError:
|
|
88
|
+
return ""
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
if __name__ == "__main__":
|
|
92
|
+
sys.exit(main())
|