Mercurial > libervia-backend
comparison sat/core/constants.py @ 2624:56f94936df1e
code style reformatting using black
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 27 Jun 2018 20:14:46 +0200 |
parents | 5b26033c49a8 |
children | 779351da2c13 |
comparison
equal
deleted
inserted
replaced
2623:49533de4540b | 2624:56f94936df1e |
---|---|
26 | 26 |
27 | 27 |
28 class Const(object): | 28 class Const(object): |
29 | 29 |
30 ## Application ## | 30 ## Application ## |
31 APP_NAME = u'Salut à Toi' | 31 APP_NAME = u"Salut à Toi" |
32 APP_NAME_SHORT = u'SàT' | 32 APP_NAME_SHORT = u"SàT" |
33 APP_NAME_FILE = u'sat' | 33 APP_NAME_FILE = u"sat" |
34 APP_NAME_FULL = u'{name_short} ({name})'.format(name_short=APP_NAME_SHORT, | 34 APP_NAME_FULL = u"{name_short} ({name})".format( |
35 name=APP_NAME) | 35 name_short=APP_NAME_SHORT, name=APP_NAME |
36 APP_VERSION = sat.__version__ # Please add 'D' at the end of version in sat/VERSION for dev versions | 36 ) |
37 APP_RELEASE_NAME = u'La Commune' | 37 APP_VERSION = ( |
38 APP_URL = u'https://salut-a-toi.org' | 38 sat.__version__ |
39 | 39 ) # Please add 'D' at the end of version in sat/VERSION for dev versions |
40 APP_RELEASE_NAME = u"La Commune" | |
41 APP_URL = u"https://salut-a-toi.org" | |
40 | 42 |
41 ## Runtime ## | 43 ## Runtime ## |
42 PLUGIN_EXT = "py" | 44 PLUGIN_EXT = "py" |
43 HISTORY_SKIP = u'skip' | 45 HISTORY_SKIP = u"skip" |
44 | 46 |
45 ## Main config ## | 47 ## Main config ## |
46 DEFAULT_BRIDGE = 'dbus' | 48 DEFAULT_BRIDGE = "dbus" |
47 | |
48 | 49 |
49 ## Protocol ## | 50 ## Protocol ## |
50 XMPP_C2S_PORT = 5222 | 51 XMPP_C2S_PORT = 5222 |
51 XMPP_KEEP_ALIFE = 180 | 52 XMPP_KEEP_ALIFE = 180 |
52 XMPP_MAX_RETRIES = 2 | 53 XMPP_MAX_RETRIES = 2 |
53 # default port used on Prosody, may differ on other servers | 54 # default port used on Prosody, may differ on other servers |
54 XMPP_COMPONENT_PORT = 5347 | 55 XMPP_COMPONENT_PORT = 5347 |
55 | 56 |
56 | |
57 ## Parameters ## | 57 ## Parameters ## |
58 NO_SECURITY_LIMIT = -1 # FIXME: to rename | 58 NO_SECURITY_LIMIT = -1 # FIXME: to rename |
59 SECURITY_LIMIT_MAX = 0 | 59 SECURITY_LIMIT_MAX = 0 |
60 INDIVIDUAL = "individual" | 60 INDIVIDUAL = "individual" |
61 GENERAL = "general" | 61 GENERAL = "general" |
62 # General parameters | 62 # General parameters |
63 HISTORY_LIMIT = "History" | 63 HISTORY_LIMIT = "History" |
65 SHOW_EMPTY_GROUPS = "Empty groups" | 65 SHOW_EMPTY_GROUPS = "Empty groups" |
66 # Parameters related to connection | 66 # Parameters related to connection |
67 FORCE_SERVER_PARAM = "Force server" | 67 FORCE_SERVER_PARAM = "Force server" |
68 FORCE_PORT_PARAM = "Force port" | 68 FORCE_PORT_PARAM = "Force port" |
69 # Parameters related to encryption | 69 # Parameters related to encryption |
70 PROFILE_PASS_PATH = ('General', 'Password') | 70 PROFILE_PASS_PATH = ("General", "Password") |
71 MEMORY_CRYPTO_NAMESPACE = 'crypto' # for the private persistent binary dict | 71 MEMORY_CRYPTO_NAMESPACE = "crypto" # for the private persistent binary dict |
72 MEMORY_CRYPTO_KEY = 'personal_key' | 72 MEMORY_CRYPTO_KEY = "personal_key" |
73 # Parameters for static blog pages | 73 # Parameters for static blog pages |
74 # FIXME: blog constants should not be in core constants | 74 # FIXME: blog constants should not be in core constants |
75 STATIC_BLOG_KEY = "Blog page" | 75 STATIC_BLOG_KEY = "Blog page" |
76 STATIC_BLOG_PARAM_TITLE = "Title" | 76 STATIC_BLOG_PARAM_TITLE = "Title" |
77 STATIC_BLOG_PARAM_BANNER = "Banner" | 77 STATIC_BLOG_PARAM_BANNER = "Banner" |
78 STATIC_BLOG_PARAM_KEYWORDS = "Keywords" | 78 STATIC_BLOG_PARAM_KEYWORDS = "Keywords" |
79 STATIC_BLOG_PARAM_DESCRIPTION = "Description" | 79 STATIC_BLOG_PARAM_DESCRIPTION = "Description" |
80 | |
81 | 80 |
82 ## Menus ## | 81 ## Menus ## |
83 MENU_GLOBAL = "GLOBAL" | 82 MENU_GLOBAL = "GLOBAL" |
84 MENU_ROOM = "ROOM" | 83 MENU_ROOM = "ROOM" |
85 MENU_SINGLE = "SINGLE" | 84 MENU_SINGLE = "SINGLE" |
86 MENU_JID_CONTEXT = "JID_CONTEXT" | 85 MENU_JID_CONTEXT = "JID_CONTEXT" |
87 MENU_ROSTER_JID_CONTEXT = "ROSTER_JID_CONTEXT" | 86 MENU_ROSTER_JID_CONTEXT = "ROSTER_JID_CONTEXT" |
88 MENU_ROSTER_GROUP_CONTEXT = "MENU_ROSTER_GROUP_CONTEXT" | 87 MENU_ROSTER_GROUP_CONTEXT = "MENU_ROSTER_GROUP_CONTEXT" |
89 MENU_ROOM_OCCUPANT_CONTEXT = "MENU_ROOM_OCCUPANT_CONTEXT" | 88 MENU_ROOM_OCCUPANT_CONTEXT = "MENU_ROOM_OCCUPANT_CONTEXT" |
90 | 89 |
91 | |
92 ## Profile and entities ## | 90 ## Profile and entities ## |
93 PROF_KEY_NONE = '@NONE@' | 91 PROF_KEY_NONE = "@NONE@" |
94 PROF_KEY_DEFAULT = '@DEFAULT@' | 92 PROF_KEY_DEFAULT = "@DEFAULT@" |
95 PROF_KEY_ALL = '@ALL@' | 93 PROF_KEY_ALL = "@ALL@" |
96 ENTITY_ALL = '@ALL@' | 94 ENTITY_ALL = "@ALL@" |
97 ENTITY_ALL_RESOURCES = '@ALL_RESOURCES@' | 95 ENTITY_ALL_RESOURCES = "@ALL_RESOURCES@" |
98 ENTITY_MAIN_RESOURCE = '@MAIN_RESOURCE@' | 96 ENTITY_MAIN_RESOURCE = "@MAIN_RESOURCE@" |
99 ENTITY_CAP_HASH = 'CAP_HASH' | 97 ENTITY_CAP_HASH = "CAP_HASH" |
100 ENTITY_TYPE = 'TYPE' | 98 ENTITY_TYPE = "TYPE" |
101 | |
102 | 99 |
103 ## Roster jids selection ## | 100 ## Roster jids selection ## |
104 PUBLIC = 'PUBLIC' | 101 PUBLIC = "PUBLIC" |
105 ALL = 'ALL' # ALL means all known contacts, while PUBLIC means everybody, known or not | 102 ALL = ( |
106 GROUP = 'GROUP' | 103 "ALL" |
107 JID = 'JID' | 104 ) # ALL means all known contacts, while PUBLIC means everybody, known or not |
108 | 105 GROUP = "GROUP" |
106 JID = "JID" | |
109 | 107 |
110 ## Messages ## | 108 ## Messages ## |
111 MESS_TYPE_INFO = 'info' | 109 MESS_TYPE_INFO = "info" |
112 MESS_TYPE_CHAT = 'chat' | 110 MESS_TYPE_CHAT = "chat" |
113 MESS_TYPE_ERROR = 'error' | 111 MESS_TYPE_ERROR = "error" |
114 MESS_TYPE_GROUPCHAT = 'groupchat' | 112 MESS_TYPE_GROUPCHAT = "groupchat" |
115 MESS_TYPE_HEADLINE = 'headline' | 113 MESS_TYPE_HEADLINE = "headline" |
116 MESS_TYPE_NORMAL = 'normal' | 114 MESS_TYPE_NORMAL = "normal" |
117 MESS_TYPE_AUTO = 'auto' # magic value to let the backend guess the type | 115 MESS_TYPE_AUTO = "auto" # magic value to let the backend guess the type |
118 MESS_TYPE_STANDARD = (MESS_TYPE_CHAT, MESS_TYPE_ERROR, MESS_TYPE_GROUPCHAT, MESS_TYPE_HEADLINE, MESS_TYPE_NORMAL) | 116 MESS_TYPE_STANDARD = ( |
117 MESS_TYPE_CHAT, | |
118 MESS_TYPE_ERROR, | |
119 MESS_TYPE_GROUPCHAT, | |
120 MESS_TYPE_HEADLINE, | |
121 MESS_TYPE_NORMAL, | |
122 ) | |
119 MESS_TYPE_ALL = MESS_TYPE_STANDARD + (MESS_TYPE_INFO, MESS_TYPE_AUTO) | 123 MESS_TYPE_ALL = MESS_TYPE_STANDARD + (MESS_TYPE_INFO, MESS_TYPE_AUTO) |
120 | 124 |
121 MESS_EXTRA_INFO = "info_type" | 125 MESS_EXTRA_INFO = "info_type" |
122 | 126 |
123 | |
124 ## Chat ## | 127 ## Chat ## |
125 CHAT_ONE2ONE = 'one2one' | 128 CHAT_ONE2ONE = "one2one" |
126 CHAT_GROUP = 'group' | 129 CHAT_GROUP = "group" |
127 | |
128 | 130 |
129 ## Presence ## | 131 ## Presence ## |
130 PRESENCE_UNAVAILABLE = 'unavailable' | 132 PRESENCE_UNAVAILABLE = "unavailable" |
131 PRESENCE_SHOW_AWAY = 'away' | 133 PRESENCE_SHOW_AWAY = "away" |
132 PRESENCE_SHOW_CHAT = 'chat' | 134 PRESENCE_SHOW_CHAT = "chat" |
133 PRESENCE_SHOW_DND = 'dnd' | 135 PRESENCE_SHOW_DND = "dnd" |
134 PRESENCE_SHOW_XA = 'xa' | 136 PRESENCE_SHOW_XA = "xa" |
135 PRESENCE_SHOW = 'show' | 137 PRESENCE_SHOW = "show" |
136 PRESENCE_STATUSES = 'statuses' | 138 PRESENCE_STATUSES = "statuses" |
137 PRESENCE_STATUSES_DEFAULT = 'default' | 139 PRESENCE_STATUSES_DEFAULT = "default" |
138 PRESENCE_PRIORITY = 'priority' | 140 PRESENCE_PRIORITY = "priority" |
139 | |
140 | 141 |
141 ## Common namespaces ## | 142 ## Common namespaces ## |
142 NS_XML = 'http://www.w3.org/XML/1998/namespace' | 143 NS_XML = "http://www.w3.org/XML/1998/namespace" |
143 NS_CLIENT = 'jabber:client' | 144 NS_CLIENT = "jabber:client" |
144 NS_FORWARD = 'urn:xmpp:forward:0' | 145 NS_FORWARD = "urn:xmpp:forward:0" |
145 NS_DELAY = 'urn:xmpp:delay' | 146 NS_DELAY = "urn:xmpp:delay" |
146 NS_XHTML = 'http://www.w3.org/1999/xhtml' | 147 NS_XHTML = "http://www.w3.org/1999/xhtml" |
147 | 148 |
148 ## Common XPath ## | 149 ## Common XPath ## |
149 | 150 |
150 IQ_GET = '/iq[@type="get"]' | 151 IQ_GET = '/iq[@type="get"]' |
151 IQ_SET = '/iq[@type="set"]' | 152 IQ_SET = '/iq[@type="set"]' |
152 | 153 |
153 ## Directories ## | 154 ## Directories ## |
154 | 155 |
155 # directory for components specific data | 156 # directory for components specific data |
156 COMPONENTS_DIR = u'components' | 157 COMPONENTS_DIR = u"components" |
157 CACHE_DIR = u'cache' | 158 CACHE_DIR = u"cache" |
158 # files in file dir are stored for long term | 159 # files in file dir are stored for long term |
159 # files dir is global, i.e. for all profiles | 160 # files dir is global, i.e. for all profiles |
160 FILES_DIR = u'files' | 161 FILES_DIR = u"files" |
161 # FILES_LINKS_DIR is a directory where files owned by a specific profile | 162 # FILES_LINKS_DIR is a directory where files owned by a specific profile |
162 # are linked to the global files directory. This way the directory can be | 163 # are linked to the global files directory. This way the directory can be |
163 # shared per profiles while keeping global directory where identical files | 164 # shared per profiles while keeping global directory where identical files |
164 # shared between different profiles are not duplicated. | 165 # shared between different profiles are not duplicated. |
165 FILES_LINKS_DIR = u'files_links' | 166 FILES_LINKS_DIR = u"files_links" |
166 # FILES_TMP_DIR is where profile's partially transfered files are put. | 167 # FILES_TMP_DIR is where profile's partially transfered files are put. |
167 # Once transfer is completed, they are moved to FILES_DIR | 168 # Once transfer is completed, they are moved to FILES_DIR |
168 FILES_TMP_DIR = u'files_tmp' | 169 FILES_TMP_DIR = u"files_tmp" |
169 | |
170 | 170 |
171 ## Configuration ## | 171 ## Configuration ## |
172 if BaseDirectory: # skipped when xdg module is not available (should not happen in backend) | 172 if ( |
173 BaseDirectory | |
174 ): # skipped when xdg module is not available (should not happen in backend) | |
173 if "org.goffi.cagou.cagou" in BaseDirectory.__file__: | 175 if "org.goffi.cagou.cagou" in BaseDirectory.__file__: |
174 # FIXME: hack to make config read from the right location on Android | 176 # FIXME: hack to make config read from the right location on Android |
175 # TODO: fix it in a more proper way | 177 # TODO: fix it in a more proper way |
176 | 178 |
177 # we need to use Android API to get downloads directory | 179 # we need to use Android API to get downloads directory |
178 import os.path | 180 import os.path |
179 from jnius import autoclass | 181 from jnius import autoclass |
182 | |
180 Environment = autoclass("android.os.Environment") | 183 Environment = autoclass("android.os.Environment") |
181 | 184 |
182 BaseDirectory = None | 185 BaseDirectory = None |
183 DEFAULT_CONFIG = { | 186 DEFAULT_CONFIG = { |
184 'local_dir': '/data/data/org.goffi.cagou.cagou/app', | 187 "local_dir": "/data/data/org.goffi.cagou.cagou/app", |
185 'media_dir': '/data/data/org.goffi.cagou.cagou/files/app/media', | 188 "media_dir": "/data/data/org.goffi.cagou.cagou/files/app/media", |
186 # FIXME: temporary location for downloads, need to call API properly | 189 # FIXME: temporary location for downloads, need to call API properly |
187 'downloads_dir': os.path.join(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(), APP_NAME_FILE), | 190 "downloads_dir": os.path.join( |
188 'pid_dir': '%(local_dir)s', | 191 Environment.getExternalStoragePublicDirectory( |
189 'log_dir': '%(local_dir)s', | 192 Environment.DIRECTORY_DOWNLOADS |
193 ).getAbsolutePath(), | |
194 APP_NAME_FILE, | |
195 ), | |
196 "pid_dir": "%(local_dir)s", | |
197 "log_dir": "%(local_dir)s", | |
190 } | 198 } |
191 CONFIG_FILES = ['/data/data/org.goffi.cagou.cagou/files/app/android/' + APP_NAME_FILE + '.conf'] | 199 CONFIG_FILES = [ |
200 "/data/data/org.goffi.cagou.cagou/files/app/android/" | |
201 + APP_NAME_FILE | |
202 + ".conf" | |
203 ] | |
192 else: | 204 else: |
193 | 205 |
194 ## Configuration ## | 206 ## Configuration ## |
195 DEFAULT_CONFIG = { | 207 DEFAULT_CONFIG = { |
196 'media_dir': '/usr/share/' + APP_NAME_FILE + '/media', | 208 "media_dir": "/usr/share/" + APP_NAME_FILE + "/media", |
197 'local_dir': BaseDirectory.save_data_path(APP_NAME_FILE), | 209 "local_dir": BaseDirectory.save_data_path(APP_NAME_FILE), |
198 'downloads_dir': '~/Downloads/' + APP_NAME_FILE, | 210 "downloads_dir": "~/Downloads/" + APP_NAME_FILE, |
199 'pid_dir': '%(local_dir)s', | 211 "pid_dir": "%(local_dir)s", |
200 'log_dir': '%(local_dir)s', | 212 "log_dir": "%(local_dir)s", |
201 } | 213 } |
202 | 214 |
203 # List of the configuration filenames sorted by ascending priority | 215 # List of the configuration filenames sorted by ascending priority |
204 CONFIG_FILES = [realpath(expanduser(path) + APP_NAME_FILE + '.conf') for path in | 216 CONFIG_FILES = [ |
205 ['/etc/', '~/', '~/.', '', '.'] + | 217 realpath(expanduser(path) + APP_NAME_FILE + ".conf") |
206 ['%s/' % path for path in list(BaseDirectory.load_config_paths(APP_NAME_FILE))] | 218 for path in ["/etc/", "~/", "~/.", "", "."] |
207 ] | 219 + [ |
220 "%s/" % path | |
221 for path in list(BaseDirectory.load_config_paths(APP_NAME_FILE)) | |
222 ] | |
223 ] | |
208 | 224 |
209 ## Templates ## | 225 ## Templates ## |
210 TEMPLATE_THEME_DEFAULT = u'default' | 226 TEMPLATE_THEME_DEFAULT = u"default" |
211 TEMPLATE_STATIC_DIR = u'static' | 227 TEMPLATE_STATIC_DIR = u"static" |
212 | |
213 | 228 |
214 ## Plugins ## | 229 ## Plugins ## |
215 | 230 |
216 # PLUGIN_INFO keys | 231 # PLUGIN_INFO keys |
217 # XXX: we use PI instead of PLUG_INFO which would normally be used | 232 # XXX: we use PI instead of PLUG_INFO which would normally be used |
218 # to make the header more readable | 233 # to make the header more readable |
219 PI_NAME = u'name' | 234 PI_NAME = u"name" |
220 PI_IMPORT_NAME = u'import_name' | 235 PI_IMPORT_NAME = u"import_name" |
221 PI_MAIN = u'main' | 236 PI_MAIN = u"main" |
222 PI_HANDLER = u'handler' | 237 PI_HANDLER = u"handler" |
223 PI_TYPE = u'type' # FIXME: should be types, and should handle single unicode type or tuple of types (e.g. "blog" and "import") | 238 PI_TYPE = ( |
224 PI_MODES = u'modes' | 239 u"type" |
225 PI_PROTOCOLS = u'protocols' | 240 ) # FIXME: should be types, and should handle single unicode type or tuple of types (e.g. "blog" and "import") |
226 PI_DEPENDENCIES = u'dependencies' | 241 PI_MODES = u"modes" |
227 PI_RECOMMENDATIONS = u'recommendations' | 242 PI_PROTOCOLS = u"protocols" |
228 PI_DESCRIPTION = u'description' | 243 PI_DEPENDENCIES = u"dependencies" |
229 PI_USAGE = u'usage' | 244 PI_RECOMMENDATIONS = u"recommendations" |
245 PI_DESCRIPTION = u"description" | |
246 PI_USAGE = u"usage" | |
230 | 247 |
231 # Types | 248 # Types |
232 PLUG_TYPE_XEP = "XEP" | 249 PLUG_TYPE_XEP = "XEP" |
233 PLUG_TYPE_MISC = "MISC" | 250 PLUG_TYPE_MISC = "MISC" |
234 PLUG_TYPE_EXP = "EXP" | 251 PLUG_TYPE_EXP = "EXP" |
243 PLUG_MODE_COMPONENT = "component" | 260 PLUG_MODE_COMPONENT = "component" |
244 PLUG_MODE_DEFAULT = (PLUG_MODE_CLIENT,) | 261 PLUG_MODE_DEFAULT = (PLUG_MODE_CLIENT,) |
245 PLUG_MODE_BOTH = (PLUG_MODE_CLIENT, PLUG_MODE_COMPONENT) | 262 PLUG_MODE_BOTH = (PLUG_MODE_CLIENT, PLUG_MODE_COMPONENT) |
246 | 263 |
247 # names of widely used plugins | 264 # names of widely used plugins |
248 TEXT_CMDS = 'TEXT-COMMANDS' | 265 TEXT_CMDS = "TEXT-COMMANDS" |
249 | 266 |
250 # PubSub event categories | 267 # PubSub event categories |
251 PS_PEP = "PEP" | 268 PS_PEP = "PEP" |
252 PS_MICROBLOG = "MICROBLOG" | 269 PS_MICROBLOG = "MICROBLOG" |
253 | 270 |
254 # PubSub | 271 # PubSub |
255 PS_PUBLISH = "publish" | 272 PS_PUBLISH = "publish" |
256 PS_RETRACT = "retract" # used for items | 273 PS_RETRACT = "retract" # used for items |
257 PS_DELETE = "delete" # used for nodes | 274 PS_DELETE = "delete" # used for nodes |
258 PS_ITEM = "item" | 275 PS_ITEM = "item" |
259 PS_ITEMS = "items" # Can contain publish and retract items | 276 PS_ITEMS = "items" # Can contain publish and retract items |
260 PS_EVENTS = (PS_ITEMS, PS_DELETE) | 277 PS_EVENTS = (PS_ITEMS, PS_DELETE) |
261 | 278 |
262 | |
263 ## XMLUI ## | 279 ## XMLUI ## |
264 XMLUI_WINDOW = 'window' | 280 XMLUI_WINDOW = "window" |
265 XMLUI_POPUP = 'popup' | 281 XMLUI_POPUP = "popup" |
266 XMLUI_FORM = 'form' | 282 XMLUI_FORM = "form" |
267 XMLUI_PARAM = 'param' | 283 XMLUI_PARAM = "param" |
268 XMLUI_DIALOG = 'dialog' | 284 XMLUI_DIALOG = "dialog" |
269 XMLUI_DIALOG_CONFIRM = "confirm" | 285 XMLUI_DIALOG_CONFIRM = "confirm" |
270 XMLUI_DIALOG_MESSAGE = "message" | 286 XMLUI_DIALOG_MESSAGE = "message" |
271 XMLUI_DIALOG_NOTE = "note" | 287 XMLUI_DIALOG_NOTE = "note" |
272 XMLUI_DIALOG_FILE = "file" | 288 XMLUI_DIALOG_FILE = "file" |
273 XMLUI_DATA_ANSWER = "answer" | 289 XMLUI_DATA_ANSWER = "answer" |
282 XMLUI_DATA_LVLS = (XMLUI_DATA_LVL_INFO, XMLUI_DATA_LVL_WARNING, XMLUI_DATA_LVL_ERROR) | 298 XMLUI_DATA_LVLS = (XMLUI_DATA_LVL_INFO, XMLUI_DATA_LVL_WARNING, XMLUI_DATA_LVL_ERROR) |
283 XMLUI_DATA_BTNS_SET = "buttons_set" | 299 XMLUI_DATA_BTNS_SET = "buttons_set" |
284 XMLUI_DATA_BTNS_SET_OKCANCEL = "ok/cancel" | 300 XMLUI_DATA_BTNS_SET_OKCANCEL = "ok/cancel" |
285 XMLUI_DATA_BTNS_SET_YESNO = "yes/no" | 301 XMLUI_DATA_BTNS_SET_YESNO = "yes/no" |
286 XMLUI_DATA_BTNS_SET_DEFAULT = XMLUI_DATA_BTNS_SET_OKCANCEL | 302 XMLUI_DATA_BTNS_SET_DEFAULT = XMLUI_DATA_BTNS_SET_OKCANCEL |
287 XMLUI_DATA_FILETYPE = 'filetype' | 303 XMLUI_DATA_FILETYPE = "filetype" |
288 XMLUI_DATA_FILETYPE_FILE = "file" | 304 XMLUI_DATA_FILETYPE_FILE = "file" |
289 XMLUI_DATA_FILETYPE_DIR = "dir" | 305 XMLUI_DATA_FILETYPE_DIR = "dir" |
290 XMLUI_DATA_FILETYPE_DEFAULT = XMLUI_DATA_FILETYPE_FILE | 306 XMLUI_DATA_FILETYPE_DEFAULT = XMLUI_DATA_FILETYPE_FILE |
291 | 307 |
292 | |
293 ## Logging ## | 308 ## Logging ## |
294 LOG_LVL_DEBUG = 'DEBUG' | 309 LOG_LVL_DEBUG = "DEBUG" |
295 LOG_LVL_INFO = 'INFO' | 310 LOG_LVL_INFO = "INFO" |
296 LOG_LVL_WARNING = 'WARNING' | 311 LOG_LVL_WARNING = "WARNING" |
297 LOG_LVL_ERROR = 'ERROR' | 312 LOG_LVL_ERROR = "ERROR" |
298 LOG_LVL_CRITICAL = 'CRITICAL' | 313 LOG_LVL_CRITICAL = "CRITICAL" |
299 LOG_LEVELS = (LOG_LVL_DEBUG, LOG_LVL_INFO, LOG_LVL_WARNING, LOG_LVL_ERROR, LOG_LVL_CRITICAL) | 314 LOG_LEVELS = ( |
300 LOG_BACKEND_STANDARD = 'standard' | 315 LOG_LVL_DEBUG, |
301 LOG_BACKEND_TWISTED = 'twisted' | 316 LOG_LVL_INFO, |
302 LOG_BACKEND_BASIC = 'basic' | 317 LOG_LVL_WARNING, |
303 LOG_BACKEND_CUSTOM = 'custom' | 318 LOG_LVL_ERROR, |
304 LOG_BASE_LOGGER = 'root' | 319 LOG_LVL_CRITICAL, |
305 LOG_TWISTED_LOGGER = 'twisted' | 320 ) |
306 LOG_OPT_SECTION = 'DEFAULT' # section of sat.conf where log options should be | 321 LOG_BACKEND_STANDARD = "standard" |
307 LOG_OPT_PREFIX = 'log_' | 322 LOG_BACKEND_TWISTED = "twisted" |
323 LOG_BACKEND_BASIC = "basic" | |
324 LOG_BACKEND_CUSTOM = "custom" | |
325 LOG_BASE_LOGGER = "root" | |
326 LOG_TWISTED_LOGGER = "twisted" | |
327 LOG_OPT_SECTION = "DEFAULT" # section of sat.conf where log options should be | |
328 LOG_OPT_PREFIX = "log_" | |
308 # (option_name, default_value) tuples | 329 # (option_name, default_value) tuples |
309 LOG_OPT_COLORS = ('colors', 'true') # true for auto colors, force to have colors even if stdout is not a tty, false for no color | 330 LOG_OPT_COLORS = ( |
310 LOG_OPT_TAINTS_DICT = ('levels_taints_dict', { | 331 "colors", |
311 LOG_LVL_DEBUG: ('cyan',), | 332 "true", |
312 LOG_LVL_INFO: (), | 333 ) # true for auto colors, force to have colors even if stdout is not a tty, false for no color |
313 LOG_LVL_WARNING: ('yellow',), | 334 LOG_OPT_TAINTS_DICT = ( |
314 LOG_LVL_ERROR: ('red', 'blink', r'/!\ ', 'blink_off'), | 335 "levels_taints_dict", |
315 LOG_LVL_CRITICAL: ('bold', 'red', 'Guru Meditation ', 'normal_weight') | 336 { |
316 }) | 337 LOG_LVL_DEBUG: ("cyan",), |
317 LOG_OPT_LEVEL = ('level', 'info') | 338 LOG_LVL_INFO: (), |
318 LOG_OPT_FORMAT = ('fmt', '%(message)s') # similar to logging format. | 339 LOG_LVL_WARNING: ("yellow",), |
319 LOG_OPT_LOGGER = ('logger', '') # regex to filter logger name | 340 LOG_LVL_ERROR: ("red", "blink", r"/!\ ", "blink_off"), |
320 LOG_OPT_OUTPUT_SEP = '//' | 341 LOG_LVL_CRITICAL: ("bold", "red", "Guru Meditation ", "normal_weight"), |
321 LOG_OPT_OUTPUT_DEFAULT = 'default' | 342 }, |
322 LOG_OPT_OUTPUT_MEMORY = 'memory' | 343 ) |
344 LOG_OPT_LEVEL = ("level", "info") | |
345 LOG_OPT_FORMAT = ("fmt", "%(message)s") # similar to logging format. | |
346 LOG_OPT_LOGGER = ("logger", "") # regex to filter logger name | |
347 LOG_OPT_OUTPUT_SEP = "//" | |
348 LOG_OPT_OUTPUT_DEFAULT = "default" | |
349 LOG_OPT_OUTPUT_MEMORY = "memory" | |
323 LOG_OPT_OUTPUT_MEMORY_LIMIT = 50 | 350 LOG_OPT_OUTPUT_MEMORY_LIMIT = 50 |
324 LOG_OPT_OUTPUT_FILE = 'file' # file is implicit if only output | 351 LOG_OPT_OUTPUT_FILE = "file" # file is implicit if only output |
325 LOG_OPT_OUTPUT = ('output', LOG_OPT_OUTPUT_SEP + LOG_OPT_OUTPUT_DEFAULT) # //default = normal output (stderr or a file with twistd), path/to/file for a file (must be the first if used), //memory for memory (options can be put in parenthesis, e.g.: //memory(500) for a 500 lines memory) | 352 LOG_OPT_OUTPUT = ( |
326 | 353 "output", |
354 LOG_OPT_OUTPUT_SEP + LOG_OPT_OUTPUT_DEFAULT, | |
355 ) # //default = normal output (stderr or a file with twistd), path/to/file for a file (must be the first if used), //memory for memory (options can be put in parenthesis, e.g.: //memory(500) for a 500 lines memory) | |
327 | 356 |
328 ## action constants ## | 357 ## action constants ## |
329 META_TYPE_FILE = "file" | 358 META_TYPE_FILE = "file" |
330 META_TYPE_OVERWRITE = "overwrite" | 359 META_TYPE_OVERWRITE = "overwrite" |
331 | 360 |
332 | |
333 ## HARD-CODED ACTIONS IDS (generated with uuid.uuid4) ## | 361 ## HARD-CODED ACTIONS IDS (generated with uuid.uuid4) ## |
334 AUTHENTICATE_PROFILE_ID = u'b03bbfa8-a4ae-4734-a248-06ce6c7cf562' | 362 AUTHENTICATE_PROFILE_ID = u"b03bbfa8-a4ae-4734-a248-06ce6c7cf562" |
335 CHANGE_XMPP_PASSWD_ID = u'878b9387-de2b-413b-950f-e424a147bcd0' | 363 CHANGE_XMPP_PASSWD_ID = u"878b9387-de2b-413b-950f-e424a147bcd0" |
336 | |
337 | 364 |
338 ## Text values ## | 365 ## Text values ## |
339 BOOL_TRUE = "true" | 366 BOOL_TRUE = "true" |
340 BOOL_FALSE = "false" | 367 BOOL_FALSE = "false" |
341 | 368 |
342 | |
343 ## Special values used in bridge methods calls ## | 369 ## Special values used in bridge methods calls ## |
344 HISTORY_LIMIT_DEFAULT = -1 | 370 HISTORY_LIMIT_DEFAULT = -1 |
345 HISTORY_LIMIT_NONE = -2 | 371 HISTORY_LIMIT_NONE = -2 |
346 | 372 |
347 | |
348 ## Progress error special values ## | 373 ## Progress error special values ## |
349 PROGRESS_ERROR_DECLINED = u'declined' # session has been declined by peer user | 374 PROGRESS_ERROR_DECLINED = u"declined" # session has been declined by peer user |
350 | |
351 | 375 |
352 ## Files ## | 376 ## Files ## |
353 FILE_TYPE_DIRECTORY = 'directory' | 377 FILE_TYPE_DIRECTORY = "directory" |
354 FILE_TYPE_FILE = 'file' | 378 FILE_TYPE_FILE = "file" |
355 | |
356 | 379 |
357 ## Permissions management ## | 380 ## Permissions management ## |
358 ACCESS_PERM_READ = u'read' | 381 ACCESS_PERM_READ = u"read" |
359 ACCESS_PERM_WRITE = u'write' | 382 ACCESS_PERM_WRITE = u"write" |
360 ACCESS_PERMS = {ACCESS_PERM_READ, ACCESS_PERM_WRITE} | 383 ACCESS_PERMS = {ACCESS_PERM_READ, ACCESS_PERM_WRITE} |
361 ACCESS_TYPE_PUBLIC = u'public' | 384 ACCESS_TYPE_PUBLIC = u"public" |
362 ACCESS_TYPE_WHITELIST = u'whitelist' | 385 ACCESS_TYPE_WHITELIST = u"whitelist" |
363 ACCESS_TYPES = (ACCESS_TYPE_PUBLIC, ACCESS_TYPE_WHITELIST) | 386 ACCESS_TYPES = (ACCESS_TYPE_PUBLIC, ACCESS_TYPE_WHITELIST) |
364 | 387 |
365 | |
366 ## Common data keys ## | 388 ## Common data keys ## |
367 KEY_THUMBNAILS = u'thumbnails' | 389 KEY_THUMBNAILS = u"thumbnails" |
368 KEY_PROGRESS_ID = u'progress_id' | 390 KEY_PROGRESS_ID = u"progress_id" |
369 | 391 |
370 | 392 # internationalisation |
371 #internationalisation | 393 DEFAULT_LOCALE = u"en_GB" |
372 DEFAULT_LOCALE = u'en_GB' | |
373 | |
374 | 394 |
375 ## Misc ## | 395 ## Misc ## |
376 SAVEFILE_DATABASE = APP_NAME_FILE + ".db" | 396 SAVEFILE_DATABASE = APP_NAME_FILE + ".db" |
377 IQ_SET = '/iq[@type="set"]' | 397 IQ_SET = '/iq[@type="set"]' |
378 ENV_PREFIX = 'SAT_' # Prefix used for environment variables | 398 ENV_PREFIX = "SAT_" # Prefix used for environment variables |
379 IGNORE = 'ignore' | 399 IGNORE = "ignore" |
380 NO_LIMIT = -1 # used in bridge when a integer value is expected | 400 NO_LIMIT = -1 # used in bridge when a integer value is expected |
381 DEFAULT_MAX_AGE = 1209600 # default max age of cached files, in seconds | 401 DEFAULT_MAX_AGE = 1209600 # default max age of cached files, in seconds |
382 HASH_SHA1_EMPTY = 'da39a3ee5e6b4b0d3255bfef95601890afd80709' | 402 HASH_SHA1_EMPTY = "da39a3ee5e6b4b0d3255bfef95601890afd80709" |
383 | 403 |
384 @classmethod | 404 @classmethod |
385 def LOG_OPTIONS(cls): | 405 def LOG_OPTIONS(cls): |
386 """Return options checked for logs""" | 406 """Return options checked for logs""" |
387 # XXX: we use a classmethod so we can use Const inheritance to change default options | 407 # XXX: we use a classmethod so we can use Const inheritance to change default options |
388 return(cls.LOG_OPT_COLORS, cls.LOG_OPT_TAINTS_DICT, cls.LOG_OPT_LEVEL, cls.LOG_OPT_FORMAT, cls.LOG_OPT_LOGGER, cls.LOG_OPT_OUTPUT) | 408 return ( |
409 cls.LOG_OPT_COLORS, | |
410 cls.LOG_OPT_TAINTS_DICT, | |
411 cls.LOG_OPT_LEVEL, | |
412 cls.LOG_OPT_FORMAT, | |
413 cls.LOG_OPT_LOGGER, | |
414 cls.LOG_OPT_OUTPUT, | |
415 ) | |
389 | 416 |
390 @classmethod | 417 @classmethod |
391 def bool(cls, value): | 418 def bool(cls, value): |
392 """@return (bool): bool value for associated constant""" | 419 """@return (bool): bool value for associated constant""" |
393 assert isinstance(value, basestring) | 420 assert isinstance(value, basestring) |