Пример #1
0
 def get(self, option_list, default_str, persistent):
     # Return old and current merged config entries
     entry_old = None
     if self._container_old.enabled:  # If old container is enabled => return stored entry
         entry_old = ConfigEntry.combine_entries(
             self._match_entries(self._container_old, option_list))
     # Process current entry
     (entry_default, entry_default_fallback) = self._get_default_entries(
         option_list, default_str, persistent, entry_old)
     entry_cur = self.get_entry(option_list, entry_default,
                                entry_default_fallback)
     if entry_cur is None:
         raise ConfigError(
             '"[%s] %s" does not exist!' %
             (self._get_section(specific=False), option_list[-1]))
     description = 'Using user supplied %s'
     if persistent and entry_default.used:
         description = 'Using persistent    %s'
     elif entry_default.used and (entry_cur.value != entry_default.value):
         description = 'Using modified default value %s'
     elif entry_default.used:
         description = 'Using default value %s'
     elif '!' in entry_cur.section:
         description = 'Using dynamic value %s'
     self._log.log(logging.INFO2, description,
                   entry_cur.format(print_section=True))
     return (entry_old, entry_cur)
Пример #2
0
	def get_entry(self, option_list, entry_default, entry_default_fallback):
		if not unspecified(entry_default.value):
			self._container_cur.set_default_entry(entry_default)
		# Assemble matching config entries and combine them
		entries = self._match_entries(self._container_cur, option_list)
		if not unspecified(entry_default.value):
			entries.append(entry_default_fallback)
		self._log.log(logging.DEBUG1, 'Used config entries:')
		for entry in entries:
			self._log.log(logging.DEBUG1, '  %s (%s | %s)',
				entry.format(print_section=True), entry.source, entry.order)
		entry_cur = ConfigEntry.combine_entries(entries)
		# Ensure that fallback default value is stored in persistent storage
		if entry_default_fallback.used and not unspecified(entry_default.value):
			self._container_cur.set_default_entry(entry_default_fallback)
		return entry_cur
Пример #3
0
 def get_entry(self, option_list, entry_default, entry_default_fallback):
     if not unspecified(entry_default.value):
         self._container_cur.set_default_entry(entry_default)
     # Assemble matching config entries and combine them
     entries = self._match_entries(self._container_cur, option_list)
     if not unspecified(entry_default.value):
         entries.append(entry_default_fallback)
     self._log.log(logging.DEBUG1, 'Used config entries:')
     for entry in entries:
         self._log.log(logging.DEBUG1, '  %s (%s | %s)',
                       entry.format(print_section=True), entry.source,
                       entry.order)
     entry_cur = ConfigEntry.combine_entries(entries)
     # Ensure that fallback default value is stored in persistent storage
     if entry_default_fallback.used and not unspecified(
             entry_default.value):
         self._container_cur.set_default_entry(entry_default_fallback)
     return entry_cur
Пример #4
0
	def get(self, option_list, default_str, persistent):
		# Return old and current merged config entries
		entry_old = None
		if self._container_old.enabled:  # If old container is enabled => return stored entry
			entry_old = ConfigEntry.combine_entries(self._match_entries(self._container_old, option_list))
		# Process current entry
		(entry_default, entry_default_fallback) = self._get_default_entries(
			option_list, default_str, persistent, entry_old)
		entry_cur = self.get_entry(option_list, entry_default, entry_default_fallback)
		if entry_cur is None:
			raise ConfigError('"[%s] %s" does not exist!' % (
				self._get_section(specific=False), option_list[-1]))
		description = 'Using user supplied %s'
		if persistent and entry_default.used:
			description = 'Using persistent    %s'
		elif entry_default.used and (entry_cur.value != entry_default.value):
			description = 'Using modified default value %s'
		elif entry_default.used:
			description = 'Using default value %s'
		elif '!' in entry_cur.section:
			description = 'Using dynamic value %s'
		self._log.log(logging.INFO2, description, entry_cur.format(print_section=True))
		return (entry_old, entry_cur)