def set_vcs_config(config): """ Patch VCS config with some Kallithea specific stuff :param config: kallithea.CONFIG """ settings.BACKENDS = { 'hg': 'kallithea.lib.vcs.backends.hg.MercurialRepository', 'git': 'kallithea.lib.vcs.backends.git.GitRepository', } settings.GIT_EXECUTABLE_PATH = config.get('git_path', 'git') settings.GIT_REV_FILTER = config.get('git_rev_filter', '--all').strip() settings.DEFAULT_ENCODINGS = aslist(config.get('default_encoding', 'utf-8'), sep=',')
def set_vcs_config(config): """ Patch VCS config with some Kallithea specific stuff :param config: kallithea.CONFIG """ from kallithea.lib.vcs import conf from kallithea.lib.utils2 import aslist conf.settings.BACKENDS = { 'hg': 'kallithea.lib.vcs.backends.hg.MercurialRepository', 'git': 'kallithea.lib.vcs.backends.git.GitRepository', } conf.settings.GIT_EXECUTABLE_PATH = config.get('git_path', 'git') conf.settings.GIT_REV_FILTER = config.get('git_rev_filter', '--all').strip() conf.settings.DEFAULT_ENCODINGS = aslist(config.get('default_encoding', 'utf8'), sep=',')
def allowed_api_access(controller_name, whitelist=None, api_key=None): """ Check if given controller_name is in whitelist API access """ if not whitelist: from kallithea import CONFIG whitelist = aslist(CONFIG.get('api_access_controllers_whitelist'), sep=',') log.debug('whitelist of API access is: %s' % (whitelist)) api_access_valid = controller_name in whitelist if api_access_valid: log.debug('controller:%s is in API whitelist' % (controller_name)) else: msg = 'controller: %s is *NOT* in API whitelist' % (controller_name) if api_key: #if we use API key and don't have access it's a warning log.warning(msg) else: log.debug(msg) return api_access_valid
def allowed_api_access(controller_name, whitelist=None, api_key=None): """ Check if given controller_name is in whitelist API access """ if not whitelist: from kallithea import CONFIG whitelist = aslist(CONFIG.get('api_access_controllers_whitelist'), sep=',') log.debug('whitelist of API access is: %s', whitelist) api_access_valid = controller_name in whitelist if api_access_valid: log.debug('controller:%s is in API whitelist', controller_name) else: msg = 'controller: %s is *NOT* in API whitelist' % (controller_name) if api_key: #if we use API key and don't have access it's a warning log.warning(msg) else: log.debug(msg) return api_access_valid
def _to_python(self, value, state): value = aslist(value, ',') seen = set() return [c for c in value if not (c in seen or seen.add(c))]
def _to_python(self, value, state): value = aslist(value, ',') seen = set() return [c for c in value if not (c in seen or seen.add(c))]