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