def aggregate_sections_partials(self, opts): """Aggregate options by sections in order to notify observers.""" to_update = {} for opt in opts: section = self.CONF_SECTION if opt in self.cross_section_options: section = self.cross_section_options[opt] section_options = to_update.get(section, []) section_options.append(opt) to_update[section] = section_options for section in to_update: section_prefix = PrefixedTuple() # Notify section observers CONF.notify_observers(section, '__section', recursive_notification=False) for opt in to_update[section]: if isinstance(opt, tuple): opt = opt[:-1] section_prefix.add_path(opt) # Notify prefixed observers for prefix in section_prefix: try: CONF.notify_observers(section, prefix, recursive_notification=False) except Exception: # Prevent unexpected failures on tests pass
def notify_section_all_observers(self, section: str): """Notify all the observers subscribed to any option of a section.""" option_observers = self._observers[section] section_prefix = PrefixedTuple() # Notify section observers CONF.notify_observers(section, '__section') for option in option_observers: if isinstance(option, tuple): section_prefix.add_path(option) else: try: self.notify_observers(section, option) except cp.NoOptionError: # Skip notification if the option/section does not exist. # This prevents unexpected errors in the test suite. pass # Notify prefixed observers for prefix in section_prefix: try: self.notify_observers(section, prefix) except cp.NoOptionError: # See above explanation. pass