MoleditPy 2.0.0__py3-none-any.whl → 2.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.
- moleditpy/modules/constants.py +1 -1
- moleditpy/modules/main_window_main_init.py +38 -2
- moleditpy/modules/plugin_manager.py +64 -29
- {moleditpy-2.0.0.dist-info → moleditpy-2.1.0.dist-info}/METADATA +1 -1
- {moleditpy-2.0.0.dist-info → moleditpy-2.1.0.dist-info}/RECORD +9 -9
- {moleditpy-2.0.0.dist-info → moleditpy-2.1.0.dist-info}/WHEEL +0 -0
- {moleditpy-2.0.0.dist-info → moleditpy-2.1.0.dist-info}/entry_points.txt +0 -0
- {moleditpy-2.0.0.dist-info → moleditpy-2.1.0.dist-info}/licenses/LICENSE +0 -0
- {moleditpy-2.0.0.dist-info → moleditpy-2.1.0.dist-info}/top_level.txt +0 -0
moleditpy/modules/constants.py
CHANGED
|
@@ -1214,6 +1214,8 @@ class MainWindowMainInit(object):
|
|
|
1214
1214
|
reload_plugins_action = QAction("Reload Plugins", self)
|
|
1215
1215
|
reload_plugins_action.triggered.connect(lambda: self.update_plugin_menu(plugin_menu))
|
|
1216
1216
|
plugin_menu.addAction(reload_plugins_action)
|
|
1217
|
+
|
|
1218
|
+
|
|
1217
1219
|
|
|
1218
1220
|
plugin_menu.addSeparator()
|
|
1219
1221
|
|
|
@@ -1723,19 +1725,53 @@ class MainWindowMainInit(object):
|
|
|
1723
1725
|
reload_plugins_action = QAction("Reload Plugins", self)
|
|
1724
1726
|
reload_plugins_action.triggered.connect(lambda: self.update_plugin_menu(plugin_menu))
|
|
1725
1727
|
plugin_menu.addAction(reload_plugins_action)
|
|
1728
|
+
|
|
1729
|
+
explore_plugins_action = QAction("Explore Plugins", self)
|
|
1730
|
+
explore_plugins_action.triggered.connect(
|
|
1731
|
+
lambda: QDesktopServices.openUrl(QUrl("https://github.com/HiroYokoyama/moleditpy-plugins"))
|
|
1732
|
+
)
|
|
1733
|
+
plugin_menu.addAction(explore_plugins_action)
|
|
1726
1734
|
|
|
1727
1735
|
plugin_menu.addSeparator()
|
|
1728
1736
|
|
|
1729
1737
|
# Add dynamic plugin actions
|
|
1730
1738
|
plugins = self.plugin_manager.discover_plugins(self)
|
|
1739
|
+
|
|
1731
1740
|
if not plugins:
|
|
1732
1741
|
no_plugin_action = QAction("(No plugins found)", self)
|
|
1733
1742
|
no_plugin_action.setEnabled(False)
|
|
1734
1743
|
plugin_menu.addAction(no_plugin_action)
|
|
1735
1744
|
else:
|
|
1745
|
+
# Sort plugins: directories first (to create menus), then alphabetical by name
|
|
1746
|
+
# Actually simple sort by rel_folder, name is fine
|
|
1747
|
+
plugins.sort(key=lambda x: (x.get('rel_folder', ''), x['name']))
|
|
1748
|
+
|
|
1749
|
+
# Dictionary to keep track of created submenus: path -> QMenu
|
|
1750
|
+
menus = { "": plugin_menu }
|
|
1751
|
+
|
|
1736
1752
|
for p in plugins:
|
|
1737
|
-
|
|
1753
|
+
rel_folder = p.get('rel_folder', "")
|
|
1754
|
+
|
|
1755
|
+
# Get or create the parent menu for this plugin
|
|
1756
|
+
parent_menu = menus.get("") # Start at root
|
|
1757
|
+
|
|
1758
|
+
if rel_folder:
|
|
1759
|
+
# Split path and traverse/create submenus
|
|
1760
|
+
parts = rel_folder.split(os.sep)
|
|
1761
|
+
current_path = ""
|
|
1762
|
+
for part in parts:
|
|
1763
|
+
new_path = os.path.join(current_path, part) if current_path else part
|
|
1764
|
+
|
|
1765
|
+
if new_path not in menus:
|
|
1766
|
+
# Create new submenu
|
|
1767
|
+
sub_menu = parent_menu.addMenu(part)
|
|
1768
|
+
menus[new_path] = sub_menu
|
|
1769
|
+
|
|
1770
|
+
parent_menu = menus[new_path]
|
|
1771
|
+
current_path = new_path
|
|
1772
|
+
|
|
1773
|
+
# Add action to the resolved parent_menu
|
|
1738
1774
|
action = QAction(p['name'], self)
|
|
1739
1775
|
action.triggered.connect(lambda checked, mod=p['module']: self.plugin_manager.run_plugin(mod, self.mw if hasattr(self, 'mw') else self))
|
|
1740
|
-
|
|
1776
|
+
parent_menu.addAction(action)
|
|
1741
1777
|
|
|
@@ -34,7 +34,8 @@ class PluginManager:
|
|
|
34
34
|
|
|
35
35
|
def discover_plugins(self, parent=None):
|
|
36
36
|
"""
|
|
37
|
-
|
|
37
|
+
Recursively scans the plugin directory for .py files and attempts to import them.
|
|
38
|
+
Ignores __pycache__ and other directories starting with "__".
|
|
38
39
|
Returns a list of valid loaded plugins.
|
|
39
40
|
"""
|
|
40
41
|
self.ensure_plugin_dir()
|
|
@@ -43,35 +44,69 @@ class PluginManager:
|
|
|
43
44
|
if not os.path.exists(self.plugin_dir):
|
|
44
45
|
return []
|
|
45
46
|
|
|
46
|
-
for
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
for root, dirs, files in os.walk(self.plugin_dir):
|
|
48
|
+
# Modify dirs in-place to skip hidden directories and __pycache__
|
|
49
|
+
dirs[:] = [d for d in dirs if not d.startswith('__') and d != '__pycache__']
|
|
50
|
+
|
|
51
|
+
for filename in files:
|
|
52
|
+
if filename.endswith(".py") and not filename.startswith("__"):
|
|
53
|
+
filepath = os.path.join(root, filename)
|
|
54
|
+
|
|
55
|
+
# Calculate relative folder path for menu structure
|
|
56
|
+
# equivalent to: rel_path = os.path.relpath(root, self.plugin_dir)
|
|
57
|
+
# if root is plugin_dir, rel_path is '.'
|
|
58
|
+
rel_folder = os.path.relpath(root, self.plugin_dir)
|
|
59
|
+
if rel_folder == '.':
|
|
60
|
+
rel_folder = ""
|
|
61
|
+
|
|
62
|
+
try:
|
|
63
|
+
# Unique module name based on file path to avoid conflicts
|
|
64
|
+
# e.g. plugins.subdir.myplugin
|
|
65
|
+
module_name = os.path.splitext(os.path.relpath(filepath, self.plugin_dir))[0].replace(os.sep, '.')
|
|
59
66
|
|
|
60
|
-
|
|
61
|
-
if
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
spec = importlib.util.spec_from_file_location(module_name, filepath)
|
|
68
|
+
if spec and spec.loader:
|
|
69
|
+
module = importlib.util.module_from_spec(spec)
|
|
70
|
+
sys.modules[spec.name] = module
|
|
71
|
+
spec.loader.exec_module(module)
|
|
72
|
+
|
|
73
|
+
# Check for required attributes
|
|
74
|
+
plugin_name = getattr(module, 'PLUGIN_NAME', filename[:-3])
|
|
75
|
+
|
|
76
|
+
# Valid plugin if it has 'run' OR 'autorun'
|
|
77
|
+
has_run = hasattr(module, 'run') and callable(module.run)
|
|
78
|
+
has_autorun = hasattr(module, 'autorun') and callable(module.autorun)
|
|
79
|
+
|
|
80
|
+
if has_run:
|
|
81
|
+
self.plugins.append({
|
|
82
|
+
'name': plugin_name,
|
|
83
|
+
'module': module,
|
|
84
|
+
'rel_folder': rel_folder
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
if has_autorun:
|
|
88
|
+
try:
|
|
89
|
+
if parent:
|
|
90
|
+
module.autorun(parent)
|
|
91
|
+
else:
|
|
92
|
+
print(f"Skipping autorun for {plugin_name}: parent not provided.")
|
|
93
|
+
except Exception as e:
|
|
94
|
+
print(f"Error executing autorun for {filename}: {e}")
|
|
95
|
+
traceback.print_exc()
|
|
96
|
+
|
|
97
|
+
if not has_run and not has_autorun:
|
|
98
|
+
print(f"Plugin {filename} skipped: Missing 'run(main_window)' or 'autorun(main_window)' function.")
|
|
99
|
+
|
|
100
|
+
except Exception as e:
|
|
101
|
+
# Robust error handling
|
|
102
|
+
msg = f"Failed to load plugin {filename}:\n{e}"
|
|
103
|
+
print(msg)
|
|
104
|
+
traceback.print_exc()
|
|
105
|
+
if parent:
|
|
106
|
+
# Use print/status bar instead of popups for non-critical failures during bulk load?
|
|
107
|
+
# For now, keep it visible but maybe less intrusive if many fail?
|
|
108
|
+
# sticking to original logic just in catch block
|
|
109
|
+
pass
|
|
75
110
|
|
|
76
111
|
return self.plugins
|
|
77
112
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MoleditPy
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.0
|
|
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: GNU GENERAL PUBLIC LICENSE
|
|
@@ -12,7 +12,7 @@ moleditpy/modules/bond_item.py,sha256=eVkEeKvM4igYI67DYxpey3FllqDyt_iWDo4VPYMhaP
|
|
|
12
12
|
moleditpy/modules/bond_length_dialog.py,sha256=k5x_DhK9Q8CSwouKhEo_kLRRdaYHDaK84KDNmuDNLvY,14868
|
|
13
13
|
moleditpy/modules/calculation_worker.py,sha256=KiGQY7i-QCQofEoE0r65KoQgpEGFcbhmxWv6egfkUdc,42324
|
|
14
14
|
moleditpy/modules/color_settings_dialog.py,sha256=Ow44BhCOLo0AFb6klO001k6B4drOgKX9DeNBQhZLp5o,15474
|
|
15
|
-
moleditpy/modules/constants.py,sha256=
|
|
15
|
+
moleditpy/modules/constants.py,sha256=oZuMoNzSH87-nWDMDeJ8pi5WxslbauU2b5LTAtM3u1k,4702
|
|
16
16
|
moleditpy/modules/constrained_optimization_dialog.py,sha256=IEdNVhFoNSEMeA5ABpUH9Q88-YzDXFloQM2gwnPwnHY,30150
|
|
17
17
|
moleditpy/modules/custom_interactor_style.py,sha256=NjsXE2a43IDNEanZBlcG9eR4ZIERT1MsQC6lbfesapQ,38453
|
|
18
18
|
moleditpy/modules/custom_qt_interactor.py,sha256=MFaTuDh-FPeFBS4303CqxsxmsOIOW4QXUz6USwI8PHQ,2451
|
|
@@ -25,7 +25,7 @@ moleditpy/modules/main_window_dialog_manager.py,sha256=S1ROCWqzB2uVSKHY4o5CbTtJA
|
|
|
25
25
|
moleditpy/modules/main_window_edit_3d.py,sha256=uY203adPg3CLyAdbG2NCThG2Am0WduzPDan9rXAlc14,19841
|
|
26
26
|
moleditpy/modules/main_window_edit_actions.py,sha256=lUFxNFTUQzeXN8CNlb4_4S9j4M1EEq8kpJmh9dCzM3M,64818
|
|
27
27
|
moleditpy/modules/main_window_export.py,sha256=e0HA_jeaokIOBunQqGxUn5QKdniCmE8GrsE1Igy6zm8,38351
|
|
28
|
-
moleditpy/modules/main_window_main_init.py,sha256=
|
|
28
|
+
moleditpy/modules/main_window_main_init.py,sha256=brmB2zwiW58SFNDxFDqCxXlIdj77fMP5FGarflp7Am0,79797
|
|
29
29
|
moleditpy/modules/main_window_molecular_parsers.py,sha256=Ex4-urYsKf6PyHp4XToOhgXzuYWa_n7q--QmHci4OCU,48401
|
|
30
30
|
moleditpy/modules/main_window_project_io.py,sha256=q1vEmWQDqla32HVkmk8-j0OY9ut5TI5NJ4ikahewkEo,17259
|
|
31
31
|
moleditpy/modules/main_window_string_importers.py,sha256=mQVDv2Dj4MwnPgMRe2IqdAAKnB_quE6QfYeAgCjfv28,10892
|
|
@@ -38,7 +38,7 @@ moleditpy/modules/molecule_scene.py,sha256=c5GNL7LrzerXYWshmpY_6Rg-2cBlF7xUt_orx
|
|
|
38
38
|
moleditpy/modules/move_group_dialog.py,sha256=65HVXTJSaQ9lp03XFhI1l7OzUsXmH_aqd8OgwjpjfGg,27174
|
|
39
39
|
moleditpy/modules/periodic_table_dialog.py,sha256=ItEZUts1XCietz9paY-spvbzxh6SXak3GnikwqkHZCw,4006
|
|
40
40
|
moleditpy/modules/planarize_dialog.py,sha256=yY8o-SxT8vGEHVWnjDTXecRv5NUaEejEsXH-836Xk8g,8681
|
|
41
|
-
moleditpy/modules/plugin_manager.py,sha256=
|
|
41
|
+
moleditpy/modules/plugin_manager.py,sha256=2GwuJurN09VVmPYjnr5GhrBf4JSxqLFVeVbqoKo5T24,5570
|
|
42
42
|
moleditpy/modules/settings_dialog.py,sha256=Nr7yE8UmYRi3VObWvRlrnv0DnjSjmYXbvqryZ02O12k,65348
|
|
43
43
|
moleditpy/modules/template_preview_item.py,sha256=Ks3C35pYFuLT5G4fsloI7ljE6ESXoYyGvLkM22qcmt0,6673
|
|
44
44
|
moleditpy/modules/template_preview_view.py,sha256=4OCHZDO51BvJpKdfrBWJ4_4WfLfFSKxsVIyf7I-Kj2E,3350
|
|
@@ -48,9 +48,9 @@ moleditpy/modules/zoomable_view.py,sha256=hjwljui13QpvjvxJHY4Evot4jMQvxRBQUNH5HU
|
|
|
48
48
|
moleditpy/modules/assets/icon.icns,sha256=wD5R6-Vw7K662tVKhu2E1ImN0oUuyAP4youesEQsn9c,139863
|
|
49
49
|
moleditpy/modules/assets/icon.ico,sha256=RfgFcx7-dHY_2STdsOQCQziY5SNhDr3gPnjO6jzEDPI,147975
|
|
50
50
|
moleditpy/modules/assets/icon.png,sha256=kCFN1WacYIdy0GN6SFEbNA00ef39pCczBnFdkkBI8Bs,147110
|
|
51
|
-
moleditpy-2.
|
|
52
|
-
moleditpy-2.
|
|
53
|
-
moleditpy-2.
|
|
54
|
-
moleditpy-2.
|
|
55
|
-
moleditpy-2.
|
|
56
|
-
moleditpy-2.
|
|
51
|
+
moleditpy-2.1.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
52
|
+
moleditpy-2.1.0.dist-info/METADATA,sha256=Krcn6qc1Izh90Ffad_oc2BY3Ih8N3cycPfh0sB9qpKk,58985
|
|
53
|
+
moleditpy-2.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
54
|
+
moleditpy-2.1.0.dist-info/entry_points.txt,sha256=yH1h9JjALhok1foXT3-hYrC4ufoZt8b7oiBcsdnGNNM,54
|
|
55
|
+
moleditpy-2.1.0.dist-info/top_level.txt,sha256=ARICrS4ihlPXqywlKl6o-oJa3Qz3gZRWu_VZsQ3_c44,10
|
|
56
|
+
moleditpy-2.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|