1
|
1 |
|
from plugin.core.constants import PLUGIN_IDENTIFIER |
2
|
|
|
|
3
|
1 |
|
import os |
4
|
|
|
|
5
|
|
|
|
6
|
1 |
|
class PathEnvironment(object): |
7
|
|
|
# TODO confirm validity of this on *nix and OS X |
|
|
|
|
8
|
|
|
|
9
|
1 |
|
def __init__(self, core): |
10
|
1 |
|
self._core = core |
11
|
|
|
|
12
|
1 |
|
self._plugin_support = None |
13
|
|
|
|
14
|
1 |
|
@property |
15
|
|
|
def code(self): |
16
|
1 |
|
return self._core.code_path |
17
|
|
|
|
18
|
1 |
|
@property |
19
|
|
|
def libraries(self): |
20
|
1 |
|
return os.path.abspath(os.path.join(self.code, '..', 'Libraries')) |
21
|
|
|
|
22
|
1 |
|
@property |
23
|
|
|
def plugin_caches(self): |
24
|
1 |
|
return os.path.join(self.plugin_support, 'Caches', PLUGIN_IDENTIFIER) |
25
|
|
|
|
26
|
1 |
|
@property |
27
|
|
|
def plugin_data(self): |
28
|
1 |
|
return os.path.join(self.plugin_support, 'Data', PLUGIN_IDENTIFIER) |
29
|
|
|
|
30
|
1 |
|
@property |
31
|
|
|
def plugin_database(self): |
32
|
1 |
|
return os.path.join(self.plugin_support, 'Databases', '%s.db' % PLUGIN_IDENTIFIER) |
33
|
|
|
|
34
|
1 |
|
@property |
35
|
|
|
def plugin_support(self): |
36
|
1 |
|
if self._plugin_support is not None: |
37
|
1 |
|
return self._plugin_support |
38
|
|
|
|
39
|
|
|
base_path = self.code[:self.code.index(os.path.sep + 'Plug-ins')] |
40
|
|
|
|
41
|
|
|
return os.path.join(base_path, 'Plug-in Support') |
42
|
|
|
|
43
|
1 |
|
@plugin_support.setter |
44
|
|
|
def plugin_support(self, path): |
45
|
1 |
|
self._plugin_support = path |
46
|
|
|
|
47
|
|
|
|
48
|
1 |
|
class PlatformEnvironment(object): |
49
|
1 |
|
def __init__(self, platform): |
50
|
1 |
|
self._platform = platform |
51
|
|
|
|
52
|
1 |
|
@property |
53
|
|
|
def machine_identifier(self): |
54
|
|
|
return self._platform.MachineIdentifier |
55
|
|
|
|
56
|
1 |
|
@property |
57
|
|
|
def server_version(self): |
58
|
|
|
return self._platform.ServerVersion |
59
|
|
|
|
60
|
|
|
|
61
|
1 |
|
class Environment(object): |
62
|
1 |
|
dict = None |
63
|
1 |
|
path = None |
64
|
1 |
|
platform = None |
65
|
1 |
|
prefs = None |
66
|
|
|
|
67
|
1 |
|
@classmethod |
68
|
|
|
def setup(cls, core, dict, platform, prefs): |
|
|
|
|
69
|
1 |
|
cls.path = PathEnvironment(core) |
70
|
1 |
|
cls.dict = dict |
71
|
1 |
|
cls.platform = PlatformEnvironment(platform) |
72
|
1 |
|
cls.prefs = prefs |
73
|
|
|
|
74
|
1 |
|
@classmethod |
75
|
|
|
def get_pref(cls, key): |
76
|
1 |
|
try: |
77
|
1 |
|
return cls.prefs[key] |
78
|
|
|
except: |
|
|
|
|
79
|
|
|
return None |
80
|
|
|
|