# HG changeset patch # User RhodeCode Admin # Date 2024-10-22 16:22:37 # Node ID 9cc7dfc4cd193367a091226ce951c0309e7ec9bd # Parent 457e9d20e77db1d6dd54a812c34b392950c2de35 fix: remove rhodecode import added by accident diff --git a/vcsserver/__init__.py b/vcsserver/__init__.py --- a/vcsserver/__init__.py +++ b/vcsserver/__init__.py @@ -36,6 +36,35 @@ def get_version(): # link to config for pyramid CONFIG = {} + +class ConfigGet: + NotGiven = object() + + def _get_val_or_missing(self, key, missing): + if key not in CONFIG: + if missing == self.NotGiven: + return missing + # we don't get key, we don't get missing value, return nothing similar as config.get(key) + return None + else: + val = CONFIG[key] + return val + + def get_str(self, key, missing=NotGiven): + from vcsserver.lib.str_utils import safe_str + val = self._get_val_or_missing(key, missing) + return safe_str(val) + + def get_int(self, key, missing=NotGiven): + from vcsserver.lib.str_utils import safe_int + val = self._get_val_or_missing(key, missing) + return safe_int(val) + + def get_bool(self, key, missing=NotGiven): + from vcsserver.lib.type_utils import str2bool + val = self._get_val_or_missing(key, missing) + return str2bool(val) + # Populated with the settings dictionary from application init in # PYRAMID_SETTINGS = {} diff --git a/vcsserver/remote/git_remote.py b/vcsserver/remote/git_remote.py --- a/vcsserver/remote/git_remote.py +++ b/vcsserver/remote/git_remote.py @@ -38,7 +38,7 @@ from dulwich.errors import ( UnexpectedCommandError) from dulwich.repo import Repo as DulwichRepo -import rhodecode +import vcsserver from vcsserver import exceptions, settings, subprocessio from vcsserver.lib.str_utils import safe_str, safe_int, safe_bytes, ascii_bytes, convert_to_str, splitnewlines from vcsserver.base import RepoFactory, obfuscate_qs, ArchiveNode, store_archive_in_cache, BytesEnvelope, BinaryEnvelope @@ -1403,7 +1403,7 @@ class GitRemote(RemoteBase): @reraise_safe_exceptions def run_git_command(self, wire, cmd, **opts): path = wire.get('path', None) - debug_mode = rhodecode.ConfigGet().get_bool('debug') + debug_mode = vcsserver.ConfigGet().get_bool('debug') if path and os.path.isdir(path): opts['cwd'] = path diff --git a/vcsserver/remote/svn_remote.py b/vcsserver/remote/svn_remote.py --- a/vcsserver/remote/svn_remote.py +++ b/vcsserver/remote/svn_remote.py @@ -35,7 +35,7 @@ import svn.diff # noqa import svn.fs # noqa import svn.repos # noqa -import rhodecode +import vcsserver from vcsserver import svn_diff, exceptions, subprocessio, settings from vcsserver.base import ( RepoFactory, @@ -566,7 +566,7 @@ class SvnRemote(RemoteBase): @reraise_safe_exceptions def run_svn_command(self, wire, cmd, **opts): path = wire.get('path', None) - debug_mode = rhodecode.ConfigGet().get_bool('debug') + debug_mode = vcsserver.ConfigGet().get_bool('debug') if path and os.path.isdir(path): opts['cwd'] = path