annotate src/core/constants.py @ 942:598fc223cf59

core: more organisation in constants.py
author Goffi <goffi@goffi.org>
date Fri, 28 Mar 2014 18:07:13 +0100
parents cbf4122baae7
children 71926ec2114d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
914
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
3
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # SàT: a XMPP client
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org)
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
6
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
11
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
16
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
19
930
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
20 import os.path
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
21 from xdg import BaseDirectory
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
22
914
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
23
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
24 class Const(object):
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
25
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
26 ## Application ##
923
e77948faaef3 core: removed default_config:
Goffi <goffi@goffi.org>
parents: 919
diff changeset
27 APP_NAME = u'Salut à Toi'
e77948faaef3 core: removed default_config:
Goffi <goffi@goffi.org>
parents: 919
diff changeset
28 APP_NAME_SHORT = u'SàT'
e77948faaef3 core: removed default_config:
Goffi <goffi@goffi.org>
parents: 919
diff changeset
29 APP_NAME_FULL = u'%s (%s)' % (APP_NAME_SHORT, APP_NAME)
e77948faaef3 core: removed default_config:
Goffi <goffi@goffi.org>
parents: 919
diff changeset
30 APP_VERSION = u'0.4.1D' # Please add 'D' at the end for dev versions
e77948faaef3 core: removed default_config:
Goffi <goffi@goffi.org>
parents: 919
diff changeset
31
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
32
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
33 ## Parameters ##
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
34 NO_SECURITY_LIMIT = -1
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
35 INDIVIDUAL = "individual"
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
36 GENERAL = "general"
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
37
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
38
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
39 ## Profile and entities ##
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
40 PROF_KEY_NONE = '@NONE@'
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
41 PROF_KEY_DEFAULT = '@DEFAULT@'
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
42 ENTITY_ALL = '@ALL@'
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
43
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
44
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
45 ## Configuration ##
923
e77948faaef3 core: removed default_config:
Goffi <goffi@goffi.org>
parents: 919
diff changeset
46 DEFAULT_CONFIG = {
e77948faaef3 core: removed default_config:
Goffi <goffi@goffi.org>
parents: 919
diff changeset
47 'media_dir': '/usr/share/sat/media',
930
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
48 'pid_dir': '/tmp',
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
49 'log_dir': BaseDirectory.save_data_path('sat'),
923
e77948faaef3 core: removed default_config:
Goffi <goffi@goffi.org>
parents: 919
diff changeset
50 }
e77948faaef3 core: removed default_config:
Goffi <goffi@goffi.org>
parents: 919
diff changeset
51
930
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
52 # XXX: tmp update code, will be removed in the future
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
53 # When you remove this, please add that in DEFAULT_CONFIG:
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
54 # 'local_dir': BaseDirectory.save_data_path('sat'),
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
55 # and also remove sat.memory.memory.Memory.__fixLocalDir
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
56 DEFAULT_LOCAL_DIR = BaseDirectory.save_data_path('sat')
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
57
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
58 # List of the configuration filenames sorted by ascending priority
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
59 CONFIG_FILES = [(os.path.expanduser(path) + 'sat.conf') for path in \
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
60 ['/etc/', '~/', '~/.', '', '.'] + \
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
61 ['%s/' % path for path in list(BaseDirectory.load_config_paths('sat'))]
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
62 ]
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
63
926
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 923
diff changeset
64
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
65 ## Plugins ##
926
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 923
diff changeset
66 # names of widely used plugins
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 923
diff changeset
67 TEXT_CMDS = 'TEXT-COMMANDS'
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
68
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
69
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
70 ## Misc ##
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
71 SAVEFILE_DATABASE = "sat.db"
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
72 IQ_SET = '/iq[@type="set"]'