def _build_values(self, settings: typing.Mapping) -> None: """Build up self._values from the values in the given dict.""" errors = [] for name, yaml_values in settings.items(): if not isinstance(yaml_values, dict): errors.append(configexc.ConfigErrorDesc( "While parsing {!r}".format(name), "value is not a dict")) continue values = configutils.Values(configdata.DATA[name]) if 'global' in yaml_values: values.add(yaml_values.pop('global')) for pattern, value in yaml_values.items(): if not isinstance(pattern, str): errors.append(configexc.ConfigErrorDesc( "While parsing {!r}".format(name), "pattern is not of type string")) continue try: urlpattern = urlmatch.UrlPattern(pattern) except urlmatch.ParseError as e: errors.append(configexc.ConfigErrorDesc( "While parsing pattern {!r} for {!r}" .format(pattern, name), e)) continue values.add(value, urlpattern) self._values[name] = values if errors: raise configexc.ConfigFileErrors('autoconfig.yml', errors)
def __init__(self, parent: QObject = None) -> None: super().__init__(parent) self._filename = os.path.join(standarddir.config(auto=True), 'autoconfig.yml') self._dirty = False self._values = {} # type: typing.Dict[str, configutils.Values] for name, opt in configdata.DATA.items(): self._values[name] = configutils.Values(opt)
def __init__(self, parent=None): super().__init__(parent) self._filename = os.path.join(standarddir.config(auto=True), 'autoconfig.yml') self._dirty = None self._values = {} for name, opt in configdata.DATA.items(): self._values[name] = configutils.Values(opt)
def _init_values(self) -> None: """Populate the self._values dict.""" self._values: Mapping = {} for name, opt in configdata.DATA.items(): self._values[name] = configutils.Values(opt)
def empty_values(opt): return configutils.Values(opt)
def values(opt, pattern): scoped_values = [ configutils.ScopedValue('global value', None), configutils.ScopedValue('example value', pattern) ] return configutils.Values(opt, scoped_values)
def mixed_values(opt, pattern): scoped_values = [ configutils.ScopedValue('global value', None), configutils.ScopedValue('example value', pattern, hide_userconfig=True) ] return configutils.Values(opt, scoped_values)
def test_no_pattern_support(func, opt, pattern): opt.supports_pattern = False values = configutils.Values(opt, []) with pytest.raises(configexc.NoPatternError): func(values, pattern)