| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
import re, os |
| 7 |
|
| 8 |
from PyQt6 import QtWidgets, QtGui, QtCore, uic |
| 9 |
|
| 10 |
from PyQt6.QtWidgets import * |
| 11 |
from PyQt6.QtGui import * |
| 12 |
from PyQt6.QtCore import * |
| 13 |
|
| 14 |
fc_plugins = [] |
| 15 |
fc_dict = {} |
| 16 |
|
| 17 |
def _load_plugins(module, directory): |
| 18 |
pluginImports = __import__(module, globals(), locals()) |
| 19 |
print('Scanning for view plugins...') |
| 20 |
plist = [] |
| 21 |
pdict = {} |
| 22 |
for i in sorted(os.listdir(directory)): |
| 23 |
path = os.path.join( directory, i, '__init__.py' ) |
| 24 |
if os.path.isfile( path ): |
| 25 |
p = __import__( '%s.%s' % (module, i), globals(), locals(), ['*'] ) |
| 26 |
plist.append(p) |
| 27 |
pdict[p.name()] = p |
| 28 |
if not hasattr(p, 'priority'): |
| 29 |
p.priority = 0 |
| 30 |
plist = sorted(plist, key=lambda p: p.priority, reverse=True) |
| 31 |
for p in plist: |
| 32 |
print('\t', p.name()) |
| 33 |
return (plist, pdict) |
| 34 |
|
| 35 |
def load_plugins(): |
| 36 |
global fc_plugins, fc_dict |
| 37 |
(fc_plugins, fc_dict) = _load_plugins('view.filecontext.plugins', 'view/filecontext/plugins') |
| 38 |
|
| 39 |
def run_plugins(filename, parent): |
| 40 |
for p in fc_plugins: |
| 41 |
if not hasattr(p, 'cmd_name'): |
| 42 |
p.run_plugin(filename, parent) |
| 43 |
|