VirtualMailManager/config.py
branchv0.7.x
changeset 642 4cd9d0a9f42f
parent 641 724ac0a4068d
child 643 df1e3b67882a
equal deleted inserted replaced
641:724ac0a4068d 642:4cd9d0a9f42f
   355         """Loads the configuration, read only.
   355         """Loads the configuration, read only.
   356 
   356 
   357         Raises a ConfigError if the configuration syntax is
   357         Raises a ConfigError if the configuration syntax is
   358         invalid.
   358         invalid.
   359         """
   359         """
   360         try:
   360         with open(self._cfg_filename, 'r') as self._cfg_file:
   361             self._cfg_file = open(self._cfg_filename, 'r')
   361             try:
   362             self.readfp(self._cfg_file)
   362                 self.readfp(self._cfg_file)
   363         except (MissingSectionHeaderError, ParsingError), err:
   363             except (MissingSectionHeaderError, ParsingError), err:
   364             raise ConfigError(str(err), CONF_ERROR)
   364                 raise ConfigError(str(err), CONF_ERROR)
   365         finally:
       
   366             if self._cfg_file and not self._cfg_file.closed:
       
   367                 self._cfg_file.close()
       
   368 
   365 
   369     def check(self):
   366     def check(self):
   370         """Performs a configuration check.
   367         """Performs a configuration check.
   371 
   368 
   372         Raises a ConfigError if settings w/o a default value are missed.
   369         Raises a ConfigError if settings w/o a default value are missed.