diff --git a/rhodecode/svn_support/__init__.py b/rhodecode/svn_support/__init__.py --- a/rhodecode/svn_support/__init__.py +++ b/rhodecode/svn_support/__init__.py @@ -25,7 +25,7 @@ from rhodecode import events from rhodecode.lib.utils2 import str2bool from .subscribers import generate_config_subscriber -from . import keys +from . import config_keys log = logging.getLogger(__name__) @@ -35,7 +35,7 @@ def includeme(config): settings = config.registry.settings _sanitize_settings_and_apply_defaults(settings) - if settings[keys.generate_config]: + if settings[config_keys.generate_config]: config.add_subscriber( generate_config_subscriber, events.RepoGroupEvent) @@ -45,25 +45,25 @@ def _sanitize_settings_and_apply_default Set defaults, convert to python types and validate settings. """ # Convert bool settings from string to bool. - settings[keys.generate_config] = str2bool( - settings.get(keys.generate_config, 'false')) - settings[keys.list_parent_path] = str2bool( - settings.get(keys.list_parent_path, 'true')) + settings[config_keys.generate_config] = str2bool( + settings.get(config_keys.generate_config, 'false')) + settings[config_keys.list_parent_path] = str2bool( + settings.get(config_keys.list_parent_path, 'true')) # Set defaults if key not present. - settings.setdefault(keys.config_file_path, None) - settings.setdefault(keys.location_root, '/') - settings.setdefault(keys.parent_path_root, None) + settings.setdefault(config_keys.config_file_path, None) + settings.setdefault(config_keys.location_root, '/') + settings.setdefault(config_keys.parent_path_root, None) # Append path separator to paths. - settings[keys.location_root] = _append_path_sep( - settings[keys.location_root]) - settings[keys.parent_path_root] = _append_path_sep( - settings[keys.parent_path_root]) + settings[config_keys.location_root] = _append_path_sep( + settings[config_keys.location_root]) + settings[config_keys.parent_path_root] = _append_path_sep( + settings[config_keys.parent_path_root]) # Validate settings. - if settings[keys.generate_config]: - assert settings[keys.config_file_path] is not None + if settings[config_keys.generate_config]: + assert settings[config_keys.config_file_path] is not None def _append_path_sep(path): diff --git a/rhodecode/svn_support/config_keys.py b/rhodecode/svn_support/config_keys.py new file mode 100644 --- /dev/null +++ b/rhodecode/svn_support/config_keys.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +# Copyright (C) 2016-2016 RhodeCode GmbH +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License, version 3 +# (only), as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# This program is dual-licensed. If you wish to learn more about the +# RhodeCode Enterprise Edition, including its added features, Support services, +# and proprietary license terms, please see https://rhodecode.com/licenses/ + + +# Definition of setting keys used to configure this module. Defined here to +# avoid repetition of keys throughout the module. +config_file_path = 'svn.proxy.config_file_path' +generate_config = 'svn.proxy.generate_config' +list_parent_path = 'svn.proxy.list_parent_path' +location_root = 'svn.proxy.location_root' +parent_path_root = 'svn.proxy.parent_path_root' diff --git a/rhodecode/svn_support/keys.py b/rhodecode/svn_support/keys.py deleted file mode 100644 --- a/rhodecode/svn_support/keys.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (C) 2016-2016 RhodeCode GmbH -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License, version 3 -# (only), as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# This program is dual-licensed. If you wish to learn more about the -# RhodeCode Enterprise Edition, including its added features, Support services, -# and proprietary license terms, please see https://rhodecode.com/licenses/ - - -# Definition of setting keys used to configure this module. Defined here to -# avoid repetition of keys throughout the module. -config_file_path = 'svn.proxy.config_file_path' -generate_config = 'svn.proxy.generate_config' -list_parent_path = 'svn.proxy.list_parent_path' -location_root = 'svn.proxy.location_root' -parent_path_root = 'svn.proxy.parent_path_root' diff --git a/rhodecode/svn_support/tests/test_mod_dav_svn_config.py b/rhodecode/svn_support/tests/test_mod_dav_svn_config.py --- a/rhodecode/svn_support/tests/test_mod_dav_svn_config.py +++ b/rhodecode/svn_support/tests/test_mod_dav_svn_config.py @@ -26,7 +26,7 @@ import tempfile from pyramid import testing -from rhodecode.svn_support import keys +from rhodecode.svn_support import config_keys from rhodecode.svn_support.utils import generate_mod_dav_svn_config @@ -60,10 +60,10 @@ class TestModDavSvnConfig(object): config_file_path = tempfile.mkstemp( suffix='mod-dav-svn.conf', dir=cls.tempdir)[1] return { - keys.config_file_path: config_file_path, - keys.location_root: '/location/root/', - keys.parent_path_root: '/parent/path/root/', - keys.list_parent_path: True, + config_keys.config_file_path: config_file_path, + config_keys.location_root: '/location/root/', + config_keys.parent_path_root: '/parent/path/root/', + config_keys.list_parent_path: True, } @classmethod @@ -86,7 +86,7 @@ class TestModDavSvnConfig(object): generate_mod_dav_svn_config(settings) # Read generated file. - with open(settings[keys.config_file_path], 'r') as file_: + with open(settings[config_keys.config_file_path], 'r') as file_: content = file_.read() # Assert that one location block exists for each repository group. @@ -109,11 +109,11 @@ class TestModDavSvnConfig(object): # Execute the method under test. settings = self.get_settings() - settings[keys.list_parent_path] = True + settings[config_keys.list_parent_path] = True generate_mod_dav_svn_config(settings) # Read generated file. - with open(settings[keys.config_file_path], 'r') as file_: + with open(settings[config_keys.config_file_path], 'r') as file_: content = file_.read() # Make assertions. @@ -126,11 +126,11 @@ class TestModDavSvnConfig(object): # Execute the method under test. settings = self.get_settings() - settings[keys.list_parent_path] = False + settings[config_keys.list_parent_path] = False generate_mod_dav_svn_config(settings) # Read generated file. - with open(settings[keys.config_file_path], 'r') as file_: + with open(settings[config_keys.config_file_path], 'r') as file_: content = file_.read() # Make assertions. diff --git a/rhodecode/svn_support/utils.py b/rhodecode/svn_support/utils.py --- a/rhodecode/svn_support/utils.py +++ b/rhodecode/svn_support/utils.py @@ -23,7 +23,7 @@ import os from pyramid.renderers import render from rhodecode.model.db import RepoGroup -from . import keys +from . import config_keys def generate_mod_dav_svn_config(settings): @@ -33,10 +33,10 @@ def generate_mod_dav_svn_config(settings available repository group because the mod_dav_svn module does not support repositories organized in sub folders. """ - filepath = settings[keys.config_file_path] - parent_path_root = settings[keys.parent_path_root] - list_parent_path = settings[keys.list_parent_path] - location_root = settings[keys.location_root] + filepath = settings[config_keys.config_file_path] + parent_path_root = settings[config_keys.parent_path_root] + list_parent_path = settings[config_keys.list_parent_path] + location_root = settings[config_keys.location_root] # Render the configuration to string. template = 'rhodecode:svn_support/templates/mod-dav-svn.conf.mako'