예제 #1
0
	def write(self, stream, print_minimal=False, print_source=False, print_oneline=False, **kwarg):
		config = self._prepare_write(**kwarg)
		for section in sorted(config):
			if not print_oneline:
				stream.write('[%s]\n' % section)
			for option in sorted(config[section]):
				entry_list = sorted(config[section][option], key=lambda e: e.order)
				if print_minimal:
					entry_list = ConfigEntry.simplify_entries(entry_list)
				for entry in entry_list:
					source = ''
					if print_source:
						source = entry.source
					stream.write(entry.format(print_section=print_oneline, source=source) + '\n')
			if not print_oneline:
				stream.write('\n')
예제 #2
0
 def write(self,
           stream,
           print_minimal=False,
           print_source=False,
           print_oneline=False,
           **kwarg):
     config = self._prepare_write(**kwarg)
     for section in sorted(config):
         if not print_oneline:
             stream.write('[%s]\n' % section)
         for option in sorted(config[section]):
             entry_list = sorted(config[section][option],
                                 key=lambda e: e.order)
             if print_minimal:
                 entry_list = ConfigEntry.simplify_entries(entry_list)
             for entry in entry_list:
                 source = ''
                 if print_source:
                     source = entry.source
                 stream.write(
                     entry.format(print_section=print_oneline,
                                  source=source) + '\n')
         if not print_oneline:
             stream.write('\n')