Get the settings associated to the specified keyword or, if
     keyword is None, get all the settings.

    :param keyword: settings to be retrieved
    :return: dictionary with the settings plus a key to identify from which
    keyword where retrieved.
3097
def get_settings_by_keyword(keyword=None):
    
    settings = []
    if keyword is None:
        # iterate over all the schemas to return all settings
        for key, ischemas in CONTROLPANEL_INTERFACE_MAPPING.items():
            settings_from_ifaces = map(get_settings_from_interface, ischemas)
            settings_from_key = {k: v for d in settings_from_ifaces for k, v in d.items()}
            settings.append({key: settings_from_key,
                             "api_url": url_for("senaite.jsonapi.v1.settings", key=key)})
        return settings
    # if keyword has value then get only the settings associated to the key
    settings_from_ifaces = map(get_settings_from_interface, CONTROLPANEL_INTERFACE_MAPPING[keyword])
    settings_from_key = {k: v for d in settings_from_ifaces for k, v in d.items()}
    settings.append({keyword: settings_from_key,
                     "api_url": url_for("senaite.jsonapi.v1.settings", key=keyword)})
    return settings
1307188
def get_settings(self):
        
        settings = {}
        for name in REMOTE_SETTINGS:
            settings[name] = self.get_option(name)

        # dataframe_format is stored without percent sign in config
        # to avoid interference with ConfigParser's interpolation
        name = 'dataframe_format'
        settings[name] = '%{0}'.format(self.get_option(name))
        return settings
334352
def keywords(self):
        
        return [x[0] for x in self.session.query(models.Keyword.name).all()]
678884
def iter_settings(mixed: Settings) -> Iterator[Tuple[str, Any]]:
    
    if isinstance(mixed, types.ModuleType):
        for attr in dir(mixed):
            if not is_setting_key(attr):
                continue
            yield (attr, getattr(mixed, attr))
    else:
        yield from filter(lambda item: is_setting_key(item[0]), mixed.items())
752302
def get_keyword_query(self, **kw):
        
        query = dict()

        # Only known indexes get observed
        indexes = self.catalog.get_indexes()

        # Handle additional keyword parameters
        for k, v in kw.iteritems():
            # handle uid in keywords
            if k.lower() == "uid":
                k = "UID"
            # handle portal_type in keywords
            if k.lower() == "portal_type":
                if v:
                    v = _.to_list(v)
            if k not in indexes:
                logger.warn("Skipping unknown keyword parameter '%s=%s'" % (k, v))
                continue
            if v is None:
                logger.warn("Skip None value in kw parameter '%s=%s'" % (k, v))
                continue
            logger.debug("Adding '%s=%s' to query" % (k, v))
            query[k] = v

        return query
1060567
def getKeyConfig(self, keyID=None):
        
        k = keyID if keyID is not None else self._keyID
        if not k or k not in self._data['keys']:
            raise ConfigException('request key does not exist: %s' % k)
        return self._data['keys'][k]
418803
def as_dict(config):
    
    settings = defaultdict(lambda: {})
    for section in config.sections():
        for key, val in config.items(section):
            settings[section][key] = val
    return settings
715273
def settings(self):
        
        settings_file = os.path.join(os.getcwd(), 'settings', self.module.lower() + '.ini')

        # Loads the settings file once.
        if (not hasattr(self, '_settings') or self._settings is None) and os.path.isfile(settings_file):
            config = ConfigParser.ConfigParser()
            config.read(settings_file)

            settings = dict(config._sections)
            for key in settings:
                settings[key] = dict(config.defaults(), **settings[key])
                settings[key].pop('__name__', None)

            self._settings = SettingsDict(self, settings.get(self.name, {}))

        elif not hasattr(self, '_settings'):
            self._settings = SettingsDict(self, {})

        return self._settings
939257
def _marshal_settings(self):
        
        result = {}
        for key in dir(settings):
            if any(map(key.startswith, ['FLOW_', 'RESOLWE_', 'CELERY_'])):
                result[key] = getattr(settings, key)
        return result
809881
def get_settings(self, link):
        
        return reverse(
            'servicesettings-detail', kwargs={'uuid': link.service.settings.uuid}, request=self.context['request'])
306386
def settings(self):
        
        if self._settings is None:
            self._settings = SettingsList(self._version, )
        return self._settings
536614
def extract_keywords(cls, line, items):
        
        unprocessed = list(reversed(line.split('=')))
        while unprocessed:
            chunk = unprocessed.pop()
            key = None
            if chunk.strip() in cls.allowed:
                key = chunk.strip()
            else:
                raise SyntaxError("Invalid keyword: %s" % chunk.strip())
            # The next chunk may end in a subsequent keyword
            value = unprocessed.pop().strip()
            if len(unprocessed) != 0:
                # Check if a new keyword has begun
                for option in cls.allowed:
                    if value.endswith(option):
                        value = value[:-len(option)].strip()
                        unprocessed.append(option)
                        break
                else:
                    raise SyntaxError("Invalid keyword: %s" % value.split()[-1])
            keyword = '%s=%s' % (key, value)
            try:
                items.update(eval('dict(%s)' % keyword))
            except:
                raise SyntaxError("Could not evaluate keyword: %s" % keyword)
        return items
530552
def match_keyword(token, keywords):
    
    if not token:
        return False
    if not token.is_keyword:
        return False

    return token.value.upper() in keywords
1095153
def get_setting_from_keyring(self, setting_identifier, keyring_backend=None):
        
        # If a custom keyring backend has been defined, use it.
        if keyring_backend:
            return keyring_backend.get_password(setting_identifier, getpass.getuser())

        # Otherwise try and use default keyring.
        try:
            import keyring
        except ImportError:
            pass
        else:
            return keyring.get_password(setting_identifier, getpass.getuser())
938905
def _filter_settings(settings, prefix):
    
    ret = {}
    for skey in settings.keys():
        if skey.startswith(prefix):
            key = skey[len(prefix):]
            ret[key] = settings[skey]
    return ret
127096
def get_setting(name):
    
    dh = getattr(settings, 'DJANGO_HISTORY_SETTINGS', {})
    result = None
    for k in name.split('.'):
        if dh is None:
            continue
        result = dh.get(k, None)
        dh = result
    return result
1342343
def _get_context(argspec, kwargs):
    
    if argspec.keywords is not None:
        return kwargs
    return dict((arg, kwargs[arg]) for arg in argspec.args if arg in kwargs)