Пример #1
0
 def save(self, cfg_file_path=None):
     """Save config to original or given file."""
     try:
         with open(cfg_file_path or self._cfg_file_path, 'w') as cfg_file:
             self._parser.write(cfg_file)
     except (OSError, IOError):
         raise PyRevitIOError()
Пример #2
0
 def reload(self, cfg_file_path=None):
     """Reload config from original or given file."""
     try:
         with open(cfg_file_path or self._cfg_file_path, 'r') as cfg_file:
             self._parser.readfp(cfg_file)
     except (OSError, IOError):
         raise PyRevitIOError()
Пример #3
0
 def __init__(self, cfg_file_path=None):
     self._parser = ConfigParser.ConfigParser()
     if cfg_file_path is not None:
         try:
             with open(cfg_file_path, 'r') as cfg_file:
                 self._parser.readfp(cfg_file)
         except (OSError, IOError):
             raise PyRevitIOError()
         except Exception as read_err:
             raise PyRevitException(read_err)
Пример #4
0
 def __init__(self, cfg_file_path=None):
     self._cfg_file_path = cfg_file_path
     self._parser = configparser.ConfigParser()
     if self._cfg_file_path:
         try:
             with codecs.open(self._cfg_file_path, 'r', 'utf-8') as cfg_file:
                 self._parser.readfp(cfg_file)
         except (OSError, IOError):
             raise PyRevitIOError()
         except Exception as read_err:
             raise PyRevitException(read_err)
Пример #5
0
 def save(self, cfg_file_path):
     try:
         with open(cfg_file_path, 'w') as cfg_file:
             self._parser.write(cfg_file)
     except (OSError, IOError):
         raise PyRevitIOError()
Пример #6
0
 def reload(self, cfg_file_path):
     try:
         with open(cfg_file_path, 'r') as cfg_file:
             self._parser.readfp(cfg_file)
     except (OSError, IOError):
         raise PyRevitIOError()