-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathallzparkconfig.py
More file actions
213 lines (140 loc) · 5.07 KB
/
allzparkconfig.py
File metadata and controls
213 lines (140 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
"""The Allzpark configuration file
Copy this onto your local drive and make modifications.
Anything not specified in your copy is inherited from here.
ALLZPARK_CONFIG_FILE=/path/to/allzparkconfig.py
"""
import os as __os
# Load this profile on startup.
# Defaults to the first available from `profiles`
startup_profile = "" # (optional)
# Pre-select this application in the list of applications,
# if it exists in the startup profile.
startup_application = "" # (optional)
# Default filter, editable via the Preferences page
exclude_filter = "*.beta"
# Where to go when clicking the logo
help_url = "https://allzpark.com"
def profiles():
"""Return list of profiles
This function is called asynchronously, and is suitable
for making complex filesystem or database queries.
Can also be a variable of type tuple or list
"""
try:
return __os.listdir(__os.path.expanduser("~/profiles"))
except IOError:
return []
def applications():
"""Return list of applications
Applications are typically provided by the profile,
this function is called when "Show all apps" is enabled.
"""
return []
def applications_from_package(variant):
"""Return applications relative `variant`
Returns:
list of strings: E.g. ['appA', 'appB==2019']
"""
from . import _rezapi as rez
# May not be defined
requirements = variant.requires or []
apps = list(
str(req)
for req in requirements
if req.weak
)
return apps
def metadata_from_package(variant):
"""Return metadata relative `variant`
Blocking call, during change of profile.
IMPORTANT: this function must return at least the
members part of the original function, else the program
will not function. Very few safeguards are put in place
in favour of performance.
Arguments:
variant (rez.packages_.Variant): Package from which to retrieve data
Returns:
dict: See function for values and types
"""
data = getattr(variant, "_data", {})
return dict(data, **{
# Guaranteed keys, with default values
"label": data.get("label", variant.name),
"background": data.get("background"),
"icon": data.get("icon", ""),
"hidden": data.get("hidden", False),
})
def protected_preferences():
"""Protect preference settings
Prevent clueless one from touching danger settings.
Following is a list of preference names that you may lock:
* showAllApps (bool)
* showHiddenApps (bool)
* showAllVersions (bool)
* patchWithFilter (bool)
* clearCacheTimeout (int)
* exclusionFilter (str)
This should return a preference name and default value paired
dict. For example: {"showAllVersions": False}
Returns:
dict
"""
return dict()
def themes():
"""Allzpark GUI theme list provider
This will only be called once on startup.
Each theme in list is a dict object, for example:
{
"name": "theme_name",
"source": "my_style.css",
"keywords": {"base-tone": "red", "res": "path-to-icons"},
}
* `name` is the theme name, this is required.
* `source` can be a file path or plain css code, this is required.
* `keywords` is optional, must be dict type if provided, will be
used to string format the css code.
Returns:
list
"""
return []
def application_parent_environment():
"""Application's launching environment
You may want to set this so the application won't be inheriting current
environment which is used to launch Allzpark. E.g. when Allzaprk is
launched from a Rez resolved context.
But if using bleeding-rez, and `config.inherit_parent_environment` is
set to False, config will be respected and this will be ignored.
Returns:
dict
"""
return None
def subprocess_encoding():
"""Codec that should be used to decode subprocess stdout/stderr
See https://docs.python.org/3/library/codecs.html#standard-encodings
Returns:
str: name of codec
"""
# nerdvegas/rez sets `encoding='utf-8'` when `universal_newlines=True` and
# `encoding` is not in Popen kwarg.
return "utf-8"
def unicode_decode_error_handler():
"""Error handler for handling UnicodeDecodeError in subprocess
See https://docs.python.org/3/library/codecs.html#error-handlers
Returns:
str: name of registered error handler
"""
import codecs
import locale
def decode_with_preferred_encoding(exception):
encoding = locale.getpreferredencoding(do_setlocale=False)
invalid_bytes = exception.object[exception.start:]
text = invalid_bytes.decode(encoding,
# second fallback
errors="backslashreplace")
return text, len(exception.object)
handler_name = "decode_with_preferred_encoding"
try:
codecs.lookup_error(handler_name)
except LookupError:
codecs.register_error(handler_name, decode_with_preferred_encoding)
return handler_name