##// END OF EJS Templates
svn-support: Delete last traces of removed setting.
Martin Bornhold -
r828:0ce964ac default
parent child Browse files
Show More
@@ -1,75 +1,72 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2016-2016 RhodeCode GmbH
4 4 #
5 5 # This program is free software: you can redistribute it and/or modify
6 6 # it under the terms of the GNU Affero General Public License, version 3
7 7 # (only), as published by the Free Software Foundation.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU Affero General Public License
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16 #
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21 import logging
22 22 import os
23 23
24 24 from rhodecode import events
25 25 from rhodecode.lib.utils2 import str2bool
26 26
27 27 from .subscribers import generate_config_subscriber
28 28 from . import config_keys
29 29
30 30
31 31 log = logging.getLogger(__name__)
32 32
33 33
34 34 def includeme(config):
35 35 settings = config.registry.settings
36 36 _sanitize_settings_and_apply_defaults(settings)
37 37
38 38 if settings[config_keys.generate_config]:
39 39 config.add_subscriber(
40 40 generate_config_subscriber, events.RepoGroupEvent)
41 41
42 42
43 43 def _sanitize_settings_and_apply_defaults(settings):
44 44 """
45 45 Set defaults, convert to python types and validate settings.
46 46 """
47 47 # Convert bool settings from string to bool.
48 48 settings[config_keys.generate_config] = str2bool(
49 49 settings.get(config_keys.generate_config, 'false'))
50 50 settings[config_keys.list_parent_path] = str2bool(
51 51 settings.get(config_keys.list_parent_path, 'true'))
52 52
53 53 # Set defaults if key not present.
54 54 settings.setdefault(config_keys.config_file_path, None)
55 55 settings.setdefault(config_keys.location_root, '/')
56 settings.setdefault(config_keys.parent_path_root, None)
57 56
58 57 # Append path separator to paths.
59 58 settings[config_keys.location_root] = _append_path_sep(
60 59 settings[config_keys.location_root])
61 settings[config_keys.parent_path_root] = _append_path_sep(
62 settings[config_keys.parent_path_root])
63 60
64 61 # Validate settings.
65 62 if settings[config_keys.generate_config]:
66 63 assert settings[config_keys.config_file_path] is not None
67 64
68 65
69 66 def _append_path_sep(path):
70 67 """
71 68 Append the path separator if missing.
72 69 """
73 70 if isinstance(path, basestring) and not path.endswith(os.path.sep):
74 71 path += os.path.sep
75 72 return path
General Comments 0
You need to be logged in to leave comments. Login now