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()
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()
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)
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)
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()
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()