f1b2851db198fbb69e870f934259c2131d5e1328
[tiramisu.git] / tiramisu / config.py
1 # -*- coding: utf-8 -*-
2 "options handler global entry point"
3 # Copyright (C) 2012-2013 Team tiramisu (see AUTHORS for all contributors)
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 #
19 # The original `Config` design model is unproudly borrowed from
20 # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
21 # the whole pypy projet is under MIT licence
22 # ____________________________________________________________
23 import weakref
24 from tiramisu.error import PropertiesOptionError, ConfigError
25 from tiramisu.option import OptionDescription, Option, SymLinkOption
26 from tiramisu.setting import groups, Settings, default_encoding
27 from tiramisu.storage import get_storages, get_storage, set_storage, \
28     _impl_getstate_setting
29 from tiramisu.value import Values, Multi
30 from tiramisu.i18n import _
31
32
33 class SubConfig(object):
34     "sub configuration management entry"
35     __slots__ = ('_impl_context', '_impl_descr', '_impl_path')
36
37     def __init__(self, descr, context, subpath=None):
38         """ Configuration option management master class
39
40         :param descr: describes the configuration schema
41         :type descr: an instance of ``option.OptionDescription``
42         :param context: the current root config
43         :type context: `Config`
44         :type subpath: `str` with the path name
45         """
46         # main option description
47         if not isinstance(descr, OptionDescription):
48             raise TypeError(_('descr must be an optiondescription, not {0}'
49                               ).format(type(descr)))
50         self._impl_descr = descr
51         # sub option descriptions
52         if not isinstance(context, weakref.ReferenceType):
53             raise ValueError('context must be a Weakref')
54         self._impl_context = context
55         self._impl_path = subpath
56
57     def cfgimpl_reset_cache(self, only_expired=False, only=('values',
58                                                             'settings')):
59         self._cfgimpl_get_context().cfgimpl_reset_cache(only_expired, only)
60
61     def cfgimpl_get_home_by_path(self, path, force_permissive=False,
62                                  force_properties=None):
63         """:returns: tuple (config, name)"""
64         path = path.split('.')
65         for step in path[:-1]:
66             self = self._getattr(step,
67                                  force_permissive=force_permissive,
68                                  force_properties=force_properties)
69         return self, path[-1]
70
71     def __hash__(self):
72         return hash(self.cfgimpl_get_description().impl_getkey(self))
73
74     def __eq__(self, other):
75         "Config's comparison"
76         if not isinstance(other, Config):
77             return False
78         return self.cfgimpl_get_description().impl_getkey(self) == \
79             other.cfgimpl_get_description().impl_getkey(other)
80
81     def __ne__(self, other):
82         "Config's comparison"
83         if not isinstance(other, Config):
84             return True
85         return not self == other
86
87     # ______________________________________________________________________
88     def __iter__(self):
89         """Pythonesque way of parsing group's ordered options.
90         iteration only on Options (not OptionDescriptions)"""
91         for child in self.cfgimpl_get_description().impl_getchildren():
92             if not isinstance(child, OptionDescription):
93                 try:
94                     yield child._name, getattr(self, child._name)
95                 except GeneratorExit:
96                     raise StopIteration
97                 except PropertiesOptionError:
98                     pass  # option with properties
99
100     def iter_all(self):
101         """A way of parsing options **and** groups.
102         iteration on Options and OptionDescriptions."""
103         for child in self.cfgimpl_get_description().impl_getchildren():
104             try:
105                 yield child._name, getattr(self, child._name)
106             except GeneratorExit:
107                 raise StopIteration
108             except PropertiesOptionError:
109                 pass  # option with properties
110
111     def iter_groups(self, group_type=None):
112         """iteration on groups objects only.
113         All groups are returned if `group_type` is `None`, otherwise the groups
114         can be filtered by categories (families, or whatever).
115
116         :param group_type: if defined, is an instance of `groups.GroupType`
117                            or `groups.MasterGroupType` that lives in
118                            `setting.groups`
119         """
120         if group_type is not None and not isinstance(group_type,
121                                                      groups.GroupType):
122             raise TypeError(_("unknown group_type: {0}").format(group_type))
123         for child in self.cfgimpl_get_description().impl_getchildren():
124             if isinstance(child, OptionDescription):
125                 try:
126                     if group_type is None or (group_type is not None and
127                                               child.impl_get_group_type()
128                                               == group_type):
129                         yield child._name, getattr(self, child._name)
130                 except GeneratorExit:
131                     raise StopIteration
132                 except PropertiesOptionError:
133                     pass
134     # ______________________________________________________________________
135
136     def __str__(self):
137         "Config's string representation"
138         lines = []
139         for name, grp in self.iter_groups():
140             lines.append("[{0}]".format(name))
141         for name, value in self:
142             try:
143                 lines.append("{0} = {1}".format(name, value))
144             except UnicodeEncodeError:
145                 lines.append("{0} = {1}".format(name,
146                                                 value.encode(default_encoding)))
147             except PropertiesOptionError:
148                 pass
149         return '\n'.join(lines)
150
151     __repr__ = __str__
152
153     def _cfgimpl_get_context(self):
154         return self._impl_context()
155
156     def cfgimpl_get_description(self):
157         if self._impl_descr is None:
158             raise ConfigError(_('no option description found for this config'
159                                 ' (may be metaconfig without meta)'))
160         else:
161             return self._impl_descr
162
163     def cfgimpl_get_settings(self):
164         return self._cfgimpl_get_context()._impl_settings
165
166     def cfgimpl_get_values(self):
167         return self._cfgimpl_get_context()._impl_values
168
169     # ____________________________________________________________
170     # attribute methods
171     def __setattr__(self, name, value):
172         "attribute notation mechanism for the setting of the value of an option"
173         if name.startswith('_impl_'):
174             object.__setattr__(self, name, value)
175             return
176         self._setattr(name, value)
177
178     def _setattr(self, name, value, force_permissive=False):
179         if '.' in name:
180             homeconfig, name = self.cfgimpl_get_home_by_path(name)
181             return homeconfig.__setattr__(name, value)
182         child = getattr(self.cfgimpl_get_description(), name)
183         if not isinstance(child, SymLinkOption):
184             if self._impl_path is None:
185                 path = name
186             else:
187                 path = self._impl_path + '.' + name
188             self.cfgimpl_get_values().setitem(child, value, path,
189                                               force_permissive=force_permissive)
190         else:
191             context = self._cfgimpl_get_context()
192             path = context.cfgimpl_get_description().impl_get_path_by_opt(
193                 child._opt)
194             context._setattr(path, value, force_permissive=force_permissive)
195
196     def __delattr__(self, name):
197         child = getattr(self.cfgimpl_get_description(), name)
198         self.cfgimpl_get_values().__delitem__(child)
199
200     def __getattr__(self, name):
201         return self._getattr(name)
202
203     def _getattr(self, name, force_permissive=False, force_properties=None,
204                  validate=True):
205         """
206         attribute notation mechanism for accessing the value of an option
207         :param name: attribute name
208         :return: option's value if name is an option name, OptionDescription
209                  otherwise
210         """
211         # attribute access by passing a path,
212         # for instance getattr(self, "creole.general.family.adresse_ip_eth0")
213         if '.' in name:
214             homeconfig, name = self.cfgimpl_get_home_by_path(
215                 name, force_permissive=force_permissive,
216                 force_properties=force_properties)
217             return homeconfig._getattr(name, force_permissive=force_permissive,
218                                        force_properties=force_properties,
219                                        validate=validate)
220         opt_or_descr = getattr(self.cfgimpl_get_description(), name)
221         if self._impl_path is None:
222             subpath = name
223         else:
224             subpath = self._impl_path + '.' + name
225         # symlink options
226         if isinstance(opt_or_descr, SymLinkOption):
227             context = self._cfgimpl_get_context()
228             path = context.cfgimpl_get_description().impl_get_path_by_opt(
229                 opt_or_descr._opt)
230             return context._getattr(path, validate=validate,
231                                     force_properties=force_properties,
232                                     force_permissive=force_permissive)
233         elif isinstance(opt_or_descr, OptionDescription):
234             self.cfgimpl_get_settings().validate_properties(
235                 opt_or_descr, True, False, path=subpath,
236                 force_permissive=force_permissive,
237                 force_properties=force_properties)
238             return SubConfig(opt_or_descr, self._impl_context, subpath)
239         else:
240             return self.cfgimpl_get_values().getitem(
241                 opt_or_descr, path=subpath,
242                 validate=validate,
243                 force_properties=force_properties,
244                 force_permissive=force_permissive)
245
246     def find(self, bytype=None, byname=None, byvalue=None, type_='option'):
247         """
248             finds a list of options recursively in the config
249
250             :param bytype: Option class (BoolOption, StrOption, ...)
251             :param byname: filter by Option._name
252             :param byvalue: filter by the option's value
253             :returns: list of matching Option objects
254         """
255         return self._cfgimpl_get_context()._find(bytype, byname, byvalue,
256                                                  first=False,
257                                                  type_=type_,
258                                                  _subpath=self.cfgimpl_get_path()
259                                                  )
260
261     def find_first(self, bytype=None, byname=None, byvalue=None,
262                    type_='option', display_error=True):
263         """
264             finds an option recursively in the config
265
266             :param bytype: Option class (BoolOption, StrOption, ...)
267             :param byname: filter by Option._name
268             :param byvalue: filter by the option's value
269             :returns: list of matching Option objects
270         """
271         return self._cfgimpl_get_context()._find(
272             bytype, byname, byvalue, first=True, type_=type_,
273             _subpath=self.cfgimpl_get_path(), display_error=display_error)
274
275     def _find(self, bytype, byname, byvalue, first, type_='option',
276               _subpath=None, check_properties=True, display_error=True):
277         """
278         convenience method for finding an option that lives only in the subtree
279
280         :param first: return only one option if True, a list otherwise
281         :return: find list or an exception if nothing has been found
282         """
283         def _filter_by_name():
284             try:
285                 if byname is None or path == byname or \
286                         path.endswith('.' + byname):
287                     return True
288             except IndexError:
289                 pass
290             return False
291
292         def _filter_by_value():
293             if byvalue is None:
294                 return True
295             try:
296                 value = getattr(self, path)
297                 if isinstance(value, Multi):
298                     return byvalue in value
299                 else:
300                     return value == byvalue
301             except PropertiesOptionError:  # a property is a restriction
302                                            # upon the access of the value
303                 return False
304
305         def _filter_by_type():
306             if bytype is None:
307                 return True
308             if isinstance(option, bytype):
309                 return True
310             return False
311
312         if type_ not in ('option', 'path', 'value'):
313             raise ValueError(_('unknown type_ type {0}'
314                                'for _find').format(type_))
315         find_results = []
316         opts, paths = self.cfgimpl_get_description()._cache_paths
317         for index in range(0, len(paths)):
318             option = opts[index]
319             if isinstance(option, OptionDescription):
320                 continue
321             path = paths[index]
322             if _subpath is not None and not path.startswith(_subpath + '.'):
323                 continue
324             if not _filter_by_name():
325                 continue
326             if not _filter_by_value():
327                 continue
328             if not _filter_by_type():
329                 continue
330             #remove option with propertyerror, ...
331             if byvalue is None and check_properties:
332                 try:
333                     value = getattr(self, path)
334                 except PropertiesOptionError:
335                     # a property restricts the access of the value
336                     continue
337             if type_ == 'value':
338                 retval = value
339             elif type_ == 'path':
340                 retval = path
341             elif type_ == 'option':
342                 retval = option
343             if first:
344                 return retval
345             else:
346                 find_results.append(retval)
347         return self._find_return_results(find_results, display_error)
348
349     def _find_return_results(self, find_results, display_error):
350         if find_results == []:
351             if display_error:
352                 raise AttributeError(_("no option found in config"
353                                        " with these criteria"))
354             else:
355                 # translation is slow
356                 raise AttributeError()
357         else:
358             return find_results
359
360     def make_dict(self, flatten=False, _currpath=None, withoption=None,
361                   withvalue=None):
362         """exports the whole config into a `dict`, for example:
363
364         >>> print cfg.make_dict()
365         {'od2.var4': None, 'od2.var5': None, 'od2.var6': None}
366
367
368
369         :param flatten: returns a dict(name=value) instead of a dict(path=value)
370                         ::
371
372                             >>> print cfg.make_dict(flatten=True)
373                             {'var5': None, 'var4': None, 'var6': None}
374
375         :param withoption: returns the options that are present in the very same
376                            `OptionDescription` than the `withoption` itself::
377
378                                 >>> print cfg.make_dict(withoption='var1')
379                                 {'od2.var4': None, 'od2.var5': None,
380                                 'od2.var6': None,
381                                 'od2.var1': u'value',
382                                 'od1.var1': None,
383                                 'od1.var3': None,
384                                 'od1.var2': None}
385
386         :param withvalue: returns the options that have the value `withvalue`
387                           ::
388
389                             >>> print c.make_dict(withoption='var1',
390                                                   withvalue=u'value')
391                             {'od2.var4': None,
392                             'od2.var5': None,
393                             'od2.var6': None,
394                             'od2.var1': u'value'}
395
396         :returns: dict of Option's name (or path) and values
397         """
398         pathsvalues = []
399         if _currpath is None:
400             _currpath = []
401         if withoption is None and withvalue is not None:
402             raise ValueError(_("make_dict can't filtering with value without "
403                                "option"))
404         if withoption is not None:
405             mypath = self.cfgimpl_get_path()
406             for path in self._cfgimpl_get_context()._find(bytype=Option,
407                                                           byname=withoption,
408                                                           byvalue=withvalue,
409                                                           first=False,
410                                                           type_='path',
411                                                           _subpath=mypath):
412                 path = '.'.join(path.split('.')[:-1])
413                 opt = self._cfgimpl_get_context().cfgimpl_get_description(
414                 ).impl_get_opt_by_path(path)
415                 if mypath is not None:
416                     if mypath == path:
417                         withoption = None
418                         withvalue = None
419                         break
420                     else:
421                         tmypath = mypath + '.'
422                         if not path.startswith(tmypath):
423                             raise AttributeError(_('unexpected path {0}, '
424                                                    'should start with {1}'
425                                                    '').format(path, mypath))
426                         path = path[len(tmypath):]
427                 self._make_sub_dict(opt, path, pathsvalues, _currpath, flatten)
428         #withoption can be set to None below !
429         if withoption is None:
430             for opt in self.cfgimpl_get_description().impl_getchildren():
431                 path = opt._name
432                 self._make_sub_dict(opt, path, pathsvalues, _currpath, flatten)
433         if _currpath == []:
434             options = dict(pathsvalues)
435             return options
436         return pathsvalues
437
438     def _make_sub_dict(self, opt, path, pathsvalues, _currpath, flatten):
439         if isinstance(opt, OptionDescription):
440             try:
441                 pathsvalues += getattr(self, path).make_dict(flatten,
442                                                              _currpath +
443                                                              path.split('.'))
444             except PropertiesOptionError:
445                 pass  # this just a hidden or disabled option
446         else:
447             try:
448                 value = self._getattr(opt._name)
449                 if flatten:
450                     name = opt._name
451                 else:
452                     name = '.'.join(_currpath + [opt._name])
453                 pathsvalues.append((name, value))
454             except PropertiesOptionError:
455                 pass  # this just a hidden or disabled option
456
457     def cfgimpl_get_path(self):
458         descr = self.cfgimpl_get_description()
459         context_descr = self._cfgimpl_get_context().cfgimpl_get_description()
460         return context_descr.impl_get_path_by_opt(descr)
461
462
463 class CommonConfig(SubConfig):
464     "abstract base class for the Config and the MetaConfig"
465     __slots__ = ('_impl_values', '_impl_settings', '_impl_meta')
466
467     def _impl_build_all_paths(self):
468         self.cfgimpl_get_description().impl_build_cache()
469
470     def read_only(self):
471         "read only is a global config's setting, see `settings.py`"
472         self.cfgimpl_get_settings().read_only()
473
474     def read_write(self):
475         "read write is a global config's setting, see `settings.py`"
476         self.cfgimpl_get_settings().read_write()
477
478     def getowner(self, opt):
479         """convenience method to retrieve an option's owner
480         from the config itself
481         """
482         if not isinstance(opt, Option) and not isinstance(opt, SymLinkOption):
483             raise TypeError(_('opt in getowner must be an option not {0}'
484                               '').format(type(opt)))
485         return self.cfgimpl_get_values().getowner(opt)
486
487     def unwrap_from_path(self, path, force_permissive=False):
488         """convenience method to extract and Option() object from the Config()
489         and it is **fast**: finds the option directly in the appropriate
490         namespace
491
492         :returns: Option()
493         """
494         if '.' in path:
495             homeconfig, path = self.cfgimpl_get_home_by_path(
496                 path, force_permissive=force_permissive)
497             return getattr(homeconfig.cfgimpl_get_description(), path)
498         return getattr(self.cfgimpl_get_description(), path)
499
500     def cfgimpl_get_path(self):
501         return None
502
503     def cfgimpl_get_meta(self):
504         return self._impl_meta
505
506     # information
507     def impl_set_information(self, key, value):
508         """updates the information's attribute
509
510         :param key: information's key (ex: "help", "doc"
511         :param value: information's value (ex: "the help string")
512         """
513         self._impl_values.set_information(key, value)
514
515     def impl_get_information(self, key, default=None):
516         """retrieves one information's item
517
518         :param key: the item string (ex: "help")
519         """
520         return self._impl_values.get_information(key, default)
521
522
523 # ____________________________________________________________
524 class Config(CommonConfig):
525     "main configuration management entry"
526     __slots__ = ('__weakref__', '_impl_test')
527
528     def __init__(self, descr, session_id=None, persistent=False):
529         """ Configuration option management master class
530
531         :param descr: describes the configuration schema
532         :type descr: an instance of ``option.OptionDescription``
533         :param context: the current root config
534         :type context: `Config`
535         :param session_id: session ID is import with persistent Config to
536         retrieve good session
537         :type session_id: `str`
538         :param persistent: if persistent, don't delete storage when leaving
539         :type persistent: `boolean`
540         """
541         settings, values = get_storages(self, session_id, persistent)
542         self._impl_settings = Settings(self, settings)
543         self._impl_values = Values(self, values)
544         super(Config, self).__init__(descr, weakref.ref(self))
545         self._impl_build_all_paths()
546         self._impl_meta = None
547         #undocumented option used only in test script
548         self._impl_test = False
549
550     def __getstate__(self):
551         if self._impl_meta is not None:
552             raise ConfigError('cannot serialize Config with meta')
553         slots = set()
554         for subclass in self.__class__.__mro__:
555             if subclass is not object:
556                 slots.update(subclass.__slots__)
557         slots -= frozenset(['_impl_context', '__weakref__'])
558         state = {}
559         for slot in slots:
560             try:
561                 state[slot] = getattr(self, slot)
562             except AttributeError:
563                 pass
564         storage = self._impl_values._p_._storage
565         if not storage.serializable:
566             raise ConfigError('this storage is not serialisable, could be a '
567                               'none persistent storage')
568         state['_storage'] = {'session_id': storage.session_id,
569                              'persistent': storage.persistent}
570         state['_impl_setting'] = _impl_getstate_setting()
571         return state
572
573     def __setstate__(self, state):
574         for key, value in state.items():
575             if key not in ['_storage', '_impl_setting']:
576                 setattr(self, key, value)
577         set_storage(**state['_impl_setting'])
578         self._impl_context = weakref.ref(self)
579         self._impl_settings.context = weakref.ref(self)
580         self._impl_values.context = weakref.ref(self)
581         storage = get_storage(test=self._impl_test, **state['_storage'])
582         self._impl_values._impl_setstate(storage)
583         self._impl_settings._impl_setstate(storage)
584
585     def cfgimpl_reset_cache(self,
586                             only_expired=False,
587                             only=('values', 'settings')):
588         if 'values' in only:
589             self.cfgimpl_get_values().reset_cache(only_expired=only_expired)
590         if 'settings' in only:
591             self.cfgimpl_get_settings().reset_cache(only_expired=only_expired)
592
593
594 #class MetaConfig(CommonConfig):
595 #    __slots__ = ('_impl_children',)
596
597 #    def __init__(self, children, meta=True, session_id=None, persistent=False):
598 #        if not isinstance(children, list):
599 #            raise ValueError(_("metaconfig's children must be a list"))
600 #        self._impl_descr = None
601 #        self._impl_path = None
602 #        if meta:
603 #            for child in children:
604 #                if not isinstance(child, CommonConfig):
605 #                    raise TypeError(_("metaconfig's children "
606 #                                      "must be config, not {0}"
607 #                                      ).format(type(child)))
608 #                if self._impl_descr is None:
609 #                    self._impl_descr = child.cfgimpl_get_description()
610 #                elif not self._impl_descr is child.cfgimpl_get_description():
611 #                    raise ValueError(_('all config in metaconfig must '
612 #                                       'have the same optiondescription'))
613 #                if child.cfgimpl_get_meta() is not None:
614 #                    raise ValueError(_("child has already a metaconfig's"))
615 #                child._impl_meta = self
616
617 #        self._impl_children = children
618 #        settings, values = get_storages(self, session_id, persistent)
619 #        self._impl_settings = Settings(self, settings)
620 #        self._impl_values = Values(self, values)
621 #        self._impl_meta = None
622
623 #    def cfgimpl_get_children(self):
624 #        return self._impl_children
625
626 #    def cfgimpl_get_context(self):
627 #        "a meta config is a config wich has a setting, that is itself"
628 #        return self
629
630 #    def cfgimpl_reset_cache(self,
631 #                            only_expired=False,
632 #                            only=('values', 'settings')):
633 #        if 'values' in only:
634 #            self.cfgimpl_get_values().reset_cache(only_expired=only_expired)
635 #        if 'settings' in only:
636 #            self.cfgimpl_get_settings().reset_cache(only_expired=only_expired)
637 #        for child in self._impl_children:
638 #            child.cfgimpl_reset_cache(only_expired=only_expired, only=only)
639
640 #    def set_contexts(self, path, value):
641 #        for child in self._impl_children:
642 #            try:
643 #                if not isinstance(child, MetaConfig):
644 #                    setattr(child, path, value)
645 #                else:
646 #                    child.set_contexts(path, value)
647 #            except PropertiesOptionError:
648 #                pass
649
650 #    def find_first_contexts(self, byname=None, bypath=None, byvalue=None,
651 #                            type_='path', display_error=True):
652 #        ret = []
653 #        try:
654 #            if bypath is None and byname is not None and \
655 #                    self.cfgimpl_get_description() is not None:
656 #                bypath = self._find(bytype=None, byvalue=None, byname=byname,
657 #                                    first=True, type_='path',
658 #                                    check_properties=False,
659 #                                    display_error=display_error)
660 #        except ConfigError:
661 #            pass
662 #        for child in self._impl_children:
663 #            try:
664 #                if not isinstance(child, MetaConfig):
665 #                    if bypath is not None:
666 #                        if byvalue is not None:
667 #                            if getattr(child, bypath) == byvalue:
668 #                                ret.append(child)
669 #                        else:
670 #                            #not raise
671 #                            getattr(child, bypath)
672 #                            ret.append(child)
673 #                    else:
674 #                        ret.append(child.find_first(byname=byname,
675 #                                                    byvalue=byvalue,
676 #                                                    type_=type_,
677 #                                                    display_error=False))
678 #                else:
679 #                    ret.extend(child.find_first_contexts(byname=byname,
680 #                                                         bypath=bypath,
681 #                                                         byvalue=byvalue,
682 #                                                         type_=type_,
683 #                                                         display_error=False))
684 #            except AttributeError:
685 #                pass
686 #        return self._find_return_results(ret, display_error)
687
688
689 def mandatory_warnings(config):
690     """convenience function to trace Options that are mandatory and
691     where no value has been set
692
693     :returns: generator of mandatory Option's path
694
695     """
696     #if value in cache, properties are not calculated
697     config.cfgimpl_reset_cache(only=('values',))
698     for path in config.cfgimpl_get_description().impl_getpaths(
699             include_groups=True):
700         try:
701             config._getattr(path, force_properties=frozenset(('mandatory',)))
702         except PropertiesOptionError as err:
703             if err.proptype == ['mandatory']:
704                 yield path
705     config.cfgimpl_reset_cache(only=('values',))