| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
import os |
| 7 |
import sys |
| 8 |
import re |
| 9 |
|
| 10 |
backend_plugins = [] |
| 11 |
backend_dict = {} |
| 12 |
|
| 13 |
def _load_plugins(module, directory): |
| 14 |
pluginImports = __import__(module, globals(), locals()) |
| 15 |
print('Scanning for backend plugins...') |
| 16 |
plist = [] |
| 17 |
pdict = {} |
| 18 |
for i in sorted(os.listdir(directory)): |
| 19 |
path = os.path.join( directory, i, '__init__.py' ) |
| 20 |
if os.path.isfile( path ): |
| 21 |
p = __import__( '%s.%s' % (module, i), globals(), locals(), ['*'] ) |
| 22 |
plist.append(p) |
| 23 |
pdict[p.name()] = p |
| 24 |
if not hasattr(p, 'priority'): |
| 25 |
p.priority = 0 |
| 26 |
plist = sorted(plist, key=lambda p: p.priority, reverse=True) |
| 27 |
for p in plist: |
| 28 |
print('\t', p.name()) |
| 29 |
return (plist, pdict) |
| 30 |
|
| 31 |
def load_plugins(): |
| 32 |
global backend_plugins, backend_dict |
| 33 |
(backend_plugins, backend_dict) = _load_plugins('backend.plugins', 'backend/plugins') |
| 34 |
|
| 35 |
def plugin_list(): |
| 36 |
return backend_plugins |
| 37 |
|
| 38 |
|
| 39 |
prj = None |
| 40 |
|
| 41 |
def proj_new_open_app_cb(): |
| 42 |
prj.prj_feature_setup() |
| 43 |
|
| 44 |
def proj_close_app_cb(): |
| 45 |
pass |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
def _proj_new_open(): |
| 50 |
proj_new_open_app_cb() |
| 51 |
|
| 52 |
def proj_new(bname, proj_args): |
| 53 |
b = backend_dict[bname] |
| 54 |
|
| 55 |
global prj |
| 56 |
assert not prj |
| 57 |
prj = b.project_class().prj_new(proj_args) |
| 58 |
|
| 59 |
if prj: |
| 60 |
_proj_new_open() |
| 61 |
return prj != None |
| 62 |
|
| 63 |
def plugin_guess(proj_path): |
| 64 |
bi = [] |
| 65 |
for p in backend_plugins: |
| 66 |
if p.is_your_prj(proj_path): |
| 67 |
bi.append(p.name()) |
| 68 |
return bi |
| 69 |
|
| 70 |
def proj_open(proj_path, proj_type): |
| 71 |
b = backend_dict[proj_type] |
| 72 |
|
| 73 |
global prj |
| 74 |
prj = b.project_class().prj_open(proj_path) |
| 75 |
|
| 76 |
if prj: |
| 77 |
_proj_new_open() |
| 78 |
return prj != None |
| 79 |
|
| 80 |
def proj_close(): |
| 81 |
global prj |
| 82 |
prj.prj_close() |
| 83 |
prj = None |
| 84 |
|
| 85 |
from .plugins import CtagsCache |
| 86 |
CtagsCache.flush() |
| 87 |
|
| 88 |
proj_close_app_cb |
| 89 |
|
| 90 |
def proj_is_open(): |
| 91 |
return prj != None |
| 92 |
|
| 93 |
def proj_name(): |
| 94 |
return prj.prj_name() if prj else None |
| 95 |
|
| 96 |
def proj_dir(): |
| 97 |
return prj.prj_dir() if prj else None |
| 98 |
|
| 99 |
def proj_src_files(): |
| 100 |
return prj.prj_src_files() |
| 101 |
|
| 102 |
def proj_conf(): |
| 103 |
return prj.prj_conf() |
| 104 |
|
| 105 |
def proj_settings_get(): |
| 106 |
return prj.prj_settings_get() |
| 107 |
|
| 108 |
def proj_settings_update(proj_args): |
| 109 |
return prj.prj_settings_update(proj_args) |
| 110 |
|
| 111 |
def proj_is_ready(): |
| 112 |
return prj.prj_is_ready() |
| 113 |
|
| 114 |
def proj_query(rquery): |
| 115 |
return prj.prj_query(rquery) |
| 116 |
|
| 117 |
def proj_rebuild(): |
| 118 |
return prj.prj_rebuild() |
| 119 |
|
| 120 |
def proj_query_fl(): |
| 121 |
return prj.prj_query_fl() |
| 122 |
|
| 123 |
def proj_type(): |
| 124 |
return prj.prj_type() |
| 125 |
|
| 126 |
def proj_feature(): |
| 127 |
return prj.prj_feature() |