Example #1
0
 def test_duplicatesectionerror(self):
     import pickle
     e1 = ConfigParser.DuplicateSectionError('section')
     pickled = pickle.dumps(e1)
     e2 = pickle.loads(pickled)
     self.assertEqual(e1.message, e2.message)
     self.assertEqual(e1.args, e2.args)
     self.assertEqual(e1.section, e2.section)
     self.assertEqual(repr(e1), repr(e2))
Example #2
0
 def test_duplicatesectionerror(self):
     import pickle
     e1 = ConfigParser.DuplicateSectionError('section')
     for proto in range(pickle.HIGHEST_PROTOCOL + 1):
         pickled = pickle.dumps(e1, proto)
         e2 = pickle.loads(pickled)
         self.assertEqual(e1.message, e2.message)
         self.assertEqual(e1.args, e2.args)
         self.assertEqual(e1.section, e2.section)
         self.assertEqual(repr(e1), repr(e2))
Example #3
0
    def add_section(self, section):
        """Create a new section in the configuration.

        Raise DuplicateSectionError if a section by the specified name
        already exists. Raise ValueError if name is DEFAULT or any of it's
        case-insensitive variants.
        """
        if section in self._sections:
            raise ConfigParser.DuplicateSectionError(section)
        self._sections[section] = self._dict()
Example #4
0
	def add_section(self, section):
		"""Create a new section in the configuration.

		Raise DuplicateSectionError if a section by the specified name
		already exists.
		"""
		realsection = section
		section = self.sectionxform(section)
		if self.__sections.has_key(section):
			raise ConfigParser.DuplicateSectionError(section)
		self.__sections[section] = { '__name__' : [ (realsection, realsection) ] }
Example #5
0
    def add_section(self, section, items=None):
        """Create a new section in the configuration.
		Raise DuplicateSectionError if a section by the specified name
		already exists. Raise ValueError if name is DEFAULT or any of it's
		case-insensitive variants.
		"""
        if section.lower() == "default":
            raise ValueError('Invalid section name: %s' % section)

        if section in self._sections:
            raise ConfigParser.DuplicateSectionError(section)

        self._sections[section] = collections.OrderedDict()
        if items is not None:
            for (key, value) in items:
                self._sections[section][self.optionxform(key)] = value