moleditpy 5.1.3__tar.gz → 5.2.1__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.
- {moleditpy-5.1.3 → moleditpy-5.2.1}/PKG-INFO +2 -2
- {moleditpy-5.1.3 → moleditpy-5.2.1}/README.md +1 -1
- {moleditpy-5.1.3 → moleditpy-5.2.1}/pyproject.toml +1 -1
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/MoleditPy.egg-info/PKG-INFO +2 -2
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/__main__.py +0 -4
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/core/project_validation.py +69 -1
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/main.py +19 -1
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/plugins/plugin_interface.py +16 -2
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/io_logic.py +9 -5
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/main_window_init.py +4 -2
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/plugin_menu_manager.py +6 -1
- {moleditpy-5.1.3 → moleditpy-5.2.1}/COPYING +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/DISTRIBUTION.md +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/LICENSE +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/LICENSING.md +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/THIRD_PARTY_NOTICES.md +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/setup.cfg +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/MoleditPy.egg-info/SOURCES.txt +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/MoleditPy.egg-info/dependency_links.txt +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/MoleditPy.egg-info/entry_points.txt +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/MoleditPy.egg-info/requires.txt +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/MoleditPy.egg-info/top_level.txt +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/__init__.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/assets/file_icon.ico +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/assets/icon.icns +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/assets/icon.ico +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/assets/icon.png +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/core/__init__.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/core/formal_charge.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/core/mol_geometry.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/core/molecular_data.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/core/stereo_check.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/plugins/__init__.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/plugins/plugin_manager.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/plugins/plugin_manager_window.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/__init__.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/about_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/align_plane_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/alignment_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/analysis_window.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/angle_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/app_state.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/atom_item.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/atom_picking.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/base_picking_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/bond_item.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/bond_length_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/calculation_worker.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/chain_mixin.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/chirality_warning_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/color_settings_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/compute_logic.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/constrained_optimization_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/custom_interactor_style.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/custom_qt_interactor.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/dialog_3d_picking_mixin.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/dialog_logic.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/dihedral_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/edit_3d_logic.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/edit_actions_logic.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/export_logic.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/geometry_base_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/main_window.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/menu_utils.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/mirror_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/molecular_scene_handler.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/molecule_scene.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/move_dialog_mixin.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/move_group_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/move_selected_atoms_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/periodic_table_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/planarize_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/preview_molecule.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/sdf_record_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/settings_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/settings_tabs/__init__.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/settings_tabs/settings_2d_cleanup_tab.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/settings_tabs/settings_2d_tab.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/settings_tabs/settings_3d_tabs.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/settings_tabs/settings_labels_tab.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/settings_tabs/settings_other_tab.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/settings_tabs/settings_tab_base.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/string_importers.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/template_preview_item.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/template_preview_view.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/translation_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/ui_manager.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/user_template_dialog.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/view_3d_logic.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/zoomable_view.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/utils/__init__.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/utils/constants.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/utils/default_settings.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/utils/finite_float.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/utils/hit_radius.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/utils/label_style.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/utils/sdf_records.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/utils/sip_isdeleted_safe.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/utils/suppress_log.py +0 -0
- {moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/utils/system_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MoleditPy
|
|
3
|
-
Version: 5.1
|
|
3
|
+
Version: 5.2.1
|
|
4
4
|
Summary: A cross-platform, simple, and intuitive molecular structure editor built in Python. It allows 2D molecular drawing and 3D structure visualization. It supports exporting structure files for input to DFT calculation software.
|
|
5
5
|
Author-email: HiroYokoyama <titech.yoko.hiro@gmail.com>
|
|
6
6
|
License-Expression: LGPL-3.0-or-later
|
|
@@ -72,7 +72,7 @@ moleditpy
|
|
|
72
72
|
|
|
73
73
|
The first launch can take a while as RDKit and the other libraries initialize. A [Windows installer](https://hiroyokoyama.github.io/python_molecular_editor/windows-installer/windows_installer), a [macOS app bundle](https://hiroyokoyama.github.io/python_molecular_editor/macos-installer/macos_installer), and a [Docker image](https://github.com/HiroYokoyama/python_molecular_editor_docker) are also available.
|
|
74
74
|
|
|
75
|
-
> **Security note:** the legacy `.pmeraw` project format uses Python pickle
|
|
75
|
+
> **Security note:** the legacy `.pmeraw` project format uses Python pickle. MoleditPy loads it with a restricted unpickler that rejects any code embedded in the file, but only open `.pmeraw` files you created yourself, and use the JSON-based `.pmeprj` format for sharing.
|
|
76
76
|
|
|
77
77
|
To install the application directly without the shortcut helper:
|
|
78
78
|
|
|
@@ -39,7 +39,7 @@ moleditpy
|
|
|
39
39
|
|
|
40
40
|
The first launch can take a while as RDKit and the other libraries initialize. A [Windows installer](https://hiroyokoyama.github.io/python_molecular_editor/windows-installer/windows_installer), a [macOS app bundle](https://hiroyokoyama.github.io/python_molecular_editor/macos-installer/macos_installer), and a [Docker image](https://github.com/HiroYokoyama/python_molecular_editor_docker) are also available.
|
|
41
41
|
|
|
42
|
-
> **Security note:** the legacy `.pmeraw` project format uses Python pickle
|
|
42
|
+
> **Security note:** the legacy `.pmeraw` project format uses Python pickle. MoleditPy loads it with a restricted unpickler that rejects any code embedded in the file, but only open `.pmeraw` files you created yourself, and use the JSON-based `.pmeprj` format for sharing.
|
|
43
43
|
|
|
44
44
|
To install the application directly without the shortcut helper:
|
|
45
45
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MoleditPy
|
|
3
|
-
Version: 5.1
|
|
3
|
+
Version: 5.2.1
|
|
4
4
|
Summary: A cross-platform, simple, and intuitive molecular structure editor built in Python. It allows 2D molecular drawing and 3D structure visualization. It supports exporting structure files for input to DFT calculation software.
|
|
5
5
|
Author-email: HiroYokoyama <titech.yoko.hiro@gmail.com>
|
|
6
6
|
License-Expression: LGPL-3.0-or-later
|
|
@@ -72,7 +72,7 @@ moleditpy
|
|
|
72
72
|
|
|
73
73
|
The first launch can take a while as RDKit and the other libraries initialize. A [Windows installer](https://hiroyokoyama.github.io/python_molecular_editor/windows-installer/windows_installer), a [macOS app bundle](https://hiroyokoyama.github.io/python_molecular_editor/macos-installer/macos_installer), and a [Docker image](https://github.com/HiroYokoyama/python_molecular_editor_docker) are also available.
|
|
74
74
|
|
|
75
|
-
> **Security note:** the legacy `.pmeraw` project format uses Python pickle
|
|
75
|
+
> **Security note:** the legacy `.pmeraw` project format uses Python pickle. MoleditPy loads it with a restricted unpickler that rejects any code embedded in the file, but only open `.pmeraw` files you created yourself, and use the JSON-based `.pmeprj` format for sharing.
|
|
76
76
|
|
|
77
77
|
To install the application directly without the shortcut helper:
|
|
78
78
|
|
|
@@ -10,10 +10,6 @@ Repo: https://github.com/HiroYokoyama/python_molecular_editor
|
|
|
10
10
|
DOI: 10.5281/zenodo.17268532
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
print("-----------------------------------------------------")
|
|
14
|
-
print("MoleditPy - A Python-based molecular editing software")
|
|
15
|
-
print("-----------------------------------------------------\n")
|
|
16
|
-
|
|
17
13
|
try:
|
|
18
14
|
from .main import main # type: ignore
|
|
19
15
|
except ImportError:
|
|
@@ -3,12 +3,17 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import base64
|
|
6
|
+
import io
|
|
6
7
|
import math
|
|
7
|
-
|
|
8
|
+
import pickle
|
|
9
|
+
import pickletools
|
|
10
|
+
from typing import Any, BinaryIO
|
|
8
11
|
|
|
9
12
|
import numpy as np
|
|
10
13
|
from rdkit import Chem
|
|
11
14
|
|
|
15
|
+
from .molecular_data import PointTuple
|
|
16
|
+
|
|
12
17
|
|
|
13
18
|
def _integer(value: Any, minimum: int = 0) -> int:
|
|
14
19
|
if not isinstance(value, int) or isinstance(value, bool) or value < minimum:
|
|
@@ -95,6 +100,69 @@ def validate_project_data(data: dict[str, Any]) -> None:
|
|
|
95
100
|
_coordinate(atom.get(axis, 0.0))
|
|
96
101
|
|
|
97
102
|
|
|
103
|
+
# The only non-builtin type a raw snapshot contains: 2D atom positions are
|
|
104
|
+
# PointTuple, a plain tuple subclass whose reconstruction runs no user code.
|
|
105
|
+
_RAW_PROJECT_CLASSES: dict[tuple[str, str], type] = {
|
|
106
|
+
("moleditpy.core.molecular_data", "PointTuple"): PointTuple,
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class _RestrictedUnpickler(pickle.Unpickler):
|
|
111
|
+
"""Unpickler that refuses every global reference except PointTuple.
|
|
112
|
+
|
|
113
|
+
A raw project snapshot is otherwise built from dicts, lists, tuples,
|
|
114
|
+
strings, bytes and numbers, none of which needs ``find_class``. Any other
|
|
115
|
+
reference is a pickle trying to import a callable, which is the
|
|
116
|
+
arbitrary-code-execution vector of the format.
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
def find_class(self, module: str, name: str) -> Any:
|
|
120
|
+
try:
|
|
121
|
+
return _RAW_PROJECT_CLASSES[(module, name)]
|
|
122
|
+
except KeyError:
|
|
123
|
+
raise pickle.UnpicklingError(
|
|
124
|
+
f"Raw project files may not reference {module}.{name}"
|
|
125
|
+
) from None
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
# Everything a snapshot needs: data, containers, memo and framing, plus the
|
|
129
|
+
# global lookup and NEWOBJ that rebuild a PointTuple. Left out on purpose are
|
|
130
|
+
# the opcodes that call or configure an object (REDUCE, BUILD, INST, OBJ,
|
|
131
|
+
# NEWOBJ_EX), persistent IDs, out-of-band buffers and the EXT opcodes: a cached
|
|
132
|
+
# copyreg extension is returned without ever reaching find_class.
|
|
133
|
+
_RAW_PROJECT_OPCODES = frozenset(
|
|
134
|
+
{
|
|
135
|
+
"PROTO", "FRAME", "STOP", "MARK", "POP", "POP_MARK", "DUP",
|
|
136
|
+
"MEMOIZE", "GET", "BINGET", "LONG_BINGET", "PUT", "BINPUT", "LONG_BINPUT",
|
|
137
|
+
"NONE", "NEWTRUE", "NEWFALSE",
|
|
138
|
+
"INT", "BININT", "BININT1", "BININT2", "LONG", "LONG1", "LONG4",
|
|
139
|
+
"FLOAT", "BINFLOAT",
|
|
140
|
+
"STRING", "BINSTRING", "SHORT_BINSTRING",
|
|
141
|
+
"UNICODE", "SHORT_BINUNICODE", "BINUNICODE", "BINUNICODE8",
|
|
142
|
+
"BINBYTES", "SHORT_BINBYTES", "BINBYTES8", "BYTEARRAY8",
|
|
143
|
+
"EMPTY_LIST", "LIST", "APPEND", "APPENDS",
|
|
144
|
+
"EMPTY_TUPLE", "TUPLE", "TUPLE1", "TUPLE2", "TUPLE3",
|
|
145
|
+
"EMPTY_DICT", "DICT", "SETITEM", "SETITEMS",
|
|
146
|
+
"EMPTY_SET", "ADDITEMS", "FROZENSET",
|
|
147
|
+
"GLOBAL", "STACK_GLOBAL", "NEWOBJ",
|
|
148
|
+
}
|
|
149
|
+
) # fmt: skip
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def load_raw_project(stream: BinaryIO) -> Any:
|
|
153
|
+
"""Unpickle a .pmeraw stream without allowing any imports or calls."""
|
|
154
|
+
data = stream.read()
|
|
155
|
+
try:
|
|
156
|
+
for opcode, _argument, _position in pickletools.genops(data):
|
|
157
|
+
if opcode.name not in _RAW_PROJECT_OPCODES:
|
|
158
|
+
raise pickle.UnpicklingError(
|
|
159
|
+
f"Raw project files may not use the {opcode.name} pickle opcode"
|
|
160
|
+
)
|
|
161
|
+
except (ValueError, OverflowError, IndexError, TypeError) as exc:
|
|
162
|
+
raise pickle.UnpicklingError(f"Malformed raw project file: {exc}") from exc
|
|
163
|
+
return _RestrictedUnpickler(io.BytesIO(data)).load()
|
|
164
|
+
|
|
165
|
+
|
|
98
166
|
def validate_raw_project_data(data: Any) -> None:
|
|
99
167
|
"""Validate legacy pickle geometry before any live state is cleared."""
|
|
100
168
|
if not isinstance(data, dict):
|
|
@@ -29,7 +29,19 @@ from .utils.constants import VERSION
|
|
|
29
29
|
from PySide6.QtCore import QtMsgType, QThread, QTimer, qInstallMessageHandler
|
|
30
30
|
from PySide6.QtWidgets import QApplication, QMessageBox
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
# MainWindow is imported lazily in main() to avoid paying its heavy UI
|
|
33
|
+
# import cost on --version/--help and --install-plugin exits.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def __getattr__(name: str) -> Any:
|
|
37
|
+
"""Lazy-import MainWindow on first access (PEP 562)."""
|
|
38
|
+
if name == "MainWindow":
|
|
39
|
+
from .ui.main_window import MainWindow
|
|
40
|
+
|
|
41
|
+
globals()["MainWindow"] = MainWindow # cache like a real import
|
|
42
|
+
return MainWindow
|
|
43
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
44
|
+
|
|
33
45
|
|
|
34
46
|
_QT_LOG_LEVEL = {
|
|
35
47
|
QtMsgType.QtDebugMsg: logging.DEBUG,
|
|
@@ -259,6 +271,10 @@ def main() -> None:
|
|
|
259
271
|
# parse_known_args so Qt's own argv flags (e.g. -platform) are passed through
|
|
260
272
|
args, remaining = parser.parse_known_args()
|
|
261
273
|
|
|
274
|
+
print("-----------------------------------------------------")
|
|
275
|
+
print("MoleditPy - A Python-based molecular editing software")
|
|
276
|
+
print("-----------------------------------------------------\n", flush=True)
|
|
277
|
+
|
|
262
278
|
if args.install_plugin:
|
|
263
279
|
plugin_path = os.path.abspath(args.install_plugin)
|
|
264
280
|
if not os.path.exists(plugin_path):
|
|
@@ -321,6 +337,8 @@ def main() -> None:
|
|
|
321
337
|
|
|
322
338
|
app = QApplication([sys.argv[0]] + remaining)
|
|
323
339
|
qInstallMessageHandler(_qt_message_handler)
|
|
340
|
+
# Resolves through __getattr__ unless monkeypatched (e.g. by launch-probe)
|
|
341
|
+
MainWindow = sys.modules[__name__].MainWindow
|
|
324
342
|
window = MainWindow(initial_file=args.file, safe_mode=args.safe)
|
|
325
343
|
window.show()
|
|
326
344
|
|
|
@@ -186,6 +186,14 @@ class PluginContext:
|
|
|
186
186
|
"""
|
|
187
187
|
return self._manager.get_main_window()
|
|
188
188
|
|
|
189
|
+
@property
|
|
190
|
+
def moleditpy_version(self) -> str:
|
|
191
|
+
"""Version of the running application, e.g. "5.2.0" (5.2.0 and later)."""
|
|
192
|
+
# Imported here: plugin test suites import this module without Qt or RDKit.
|
|
193
|
+
from ..utils.constants import VERSION
|
|
194
|
+
|
|
195
|
+
return VERSION
|
|
196
|
+
|
|
189
197
|
def show_status_message(self, message: str, timeout: int = 3000) -> None:
|
|
190
198
|
"""
|
|
191
199
|
Display a temporary message in the status bar of the main window.
|
|
@@ -308,15 +316,21 @@ class PluginContext:
|
|
|
308
316
|
)
|
|
309
317
|
|
|
310
318
|
def register_file_opener(
|
|
311
|
-
self,
|
|
319
|
+
self,
|
|
320
|
+
extension: str,
|
|
321
|
+
callback: Callable[[str], Optional[bool]],
|
|
322
|
+
priority: int = 0,
|
|
312
323
|
) -> None:
|
|
313
324
|
"""
|
|
314
325
|
Register a handler for opening a specific file extension.
|
|
315
326
|
|
|
316
327
|
Args:
|
|
317
328
|
extension: File extension including dot, e.g. ".xyz".
|
|
318
|
-
callback: Function taking (file_path) ->
|
|
329
|
+
callback: Function taking (file_path) -> Optional[bool].
|
|
319
330
|
Should load the file into the main window.
|
|
331
|
+
Return False to decline the file, so that the next
|
|
332
|
+
opener or the built-in loader is tried (5.2.0 and
|
|
333
|
+
later). Any other value, including None, means handled.
|
|
320
334
|
priority: Higher priority handlers are tried first (default 0).
|
|
321
335
|
"""
|
|
322
336
|
self._manager.register_file_opener(
|
|
@@ -50,7 +50,11 @@ from rdkit.Chem import (
|
|
|
50
50
|
|
|
51
51
|
from ..utils.sdf_records import read_sdf_records
|
|
52
52
|
from ..utils.finite_float import finite_float
|
|
53
|
-
from ..core.project_validation import
|
|
53
|
+
from ..core.project_validation import (
|
|
54
|
+
load_raw_project,
|
|
55
|
+
validate_project_data,
|
|
56
|
+
validate_raw_project_data,
|
|
57
|
+
)
|
|
54
58
|
from .sdf_record_dialog import SdfRecordDialog
|
|
55
59
|
from ..utils.constants import (
|
|
56
60
|
COVALENT_RADII,
|
|
@@ -1286,9 +1290,9 @@ class IOManager:
|
|
|
1286
1290
|
box.setText("This file is in the legacy raw (pickle) format.")
|
|
1287
1291
|
box.setInformativeText(
|
|
1288
1292
|
f"{os.path.basename(file_path)}\n\n"
|
|
1289
|
-
"Raw project files
|
|
1290
|
-
"
|
|
1291
|
-
"from a source you trust.\n\n"
|
|
1293
|
+
"Raw project files are a legacy binary format. MoleditPy refuses "
|
|
1294
|
+
"any code embedded in them, but only open .pmeraw files that you "
|
|
1295
|
+
"created yourself or received from a source you trust.\n\n"
|
|
1292
1296
|
"The .pmeprj format is safe and is recommended instead."
|
|
1293
1297
|
)
|
|
1294
1298
|
open_button = box.addButton("Open", QMessageBox.ButtonRole.AcceptRole)
|
|
@@ -1324,7 +1328,7 @@ class IOManager:
|
|
|
1324
1328
|
try:
|
|
1325
1329
|
# Unpickle before clearing, so an unreadable file keeps the document.
|
|
1326
1330
|
with open(file_path, "rb") as f:
|
|
1327
|
-
loaded_data =
|
|
1331
|
+
loaded_data = load_raw_project(f)
|
|
1328
1332
|
validate_raw_project_data(loaded_data)
|
|
1329
1333
|
if not self.host.edit_actions_manager.clear_all(skip_check=True):
|
|
1330
1334
|
return
|
|
@@ -308,8 +308,10 @@ class MainInitManager:
|
|
|
308
308
|
for opener_info in openers:
|
|
309
309
|
try:
|
|
310
310
|
callback = opener_info["callback"]
|
|
311
|
-
#
|
|
312
|
-
|
|
311
|
+
# Only an explicit False declines the file; None, the
|
|
312
|
+
# documented return of older plugins, still means handled.
|
|
313
|
+
if callback(file_path) is False:
|
|
314
|
+
continue
|
|
313
315
|
|
|
314
316
|
self.current_file_path = file_path
|
|
315
317
|
self.host.state_manager.update_window_title()
|
|
@@ -656,9 +656,14 @@ class PluginMenuManager:
|
|
|
656
656
|
ext = os.path.splitext(fpath)[1].lower()
|
|
657
657
|
if ext in m:
|
|
658
658
|
try:
|
|
659
|
-
m[ext](fpath)
|
|
659
|
+
handled = m[ext](fpath)
|
|
660
660
|
except Exception:
|
|
661
661
|
logging.exception("Plugin file opener error (%s)", n)
|
|
662
|
+
handled = False
|
|
663
|
+
if handled is False:
|
|
664
|
+
self._im.host.statusBar().showMessage(
|
|
665
|
+
f"{n} could not open {os.path.basename(fpath)}"
|
|
666
|
+
)
|
|
662
667
|
return
|
|
663
668
|
self._im.current_file_path = fpath
|
|
664
669
|
self._im.host.state_manager.update_window_title()
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{moleditpy-5.1.3 → moleditpy-5.2.1}/src/moleditpy/ui/settings_tabs/settings_2d_cleanup_tab.py
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
|
|
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
|