xoa.load_options#
- xoa.load_options(cfgfile=None)[source]#
Load specified options and keep them for the session
The options are merged into the current ones. Use
set_optionsto change them temporarily.- Parameters:
cfgfile (str,
os.PathLike, list(str), dict) – Path of a config file, lines or a dict
Example
# Dict In [1]: load_options({'plot': {'cmappos': 'mycmap'}}) # Lines In [2]: optlines = "[plot]\n cmappos=mycmap".split('\n') In [3]: load_options(optlines) # File In [4]: load_options("/path/to/my/xoa.cfg") --------------------------------------------------------------------------- OSError Traceback (most recent call last) Cell In[4], line 1 ----> 1 load_options("/path/to/my/xoa.cfg") File ~/checkouts/xoa/conda/develop/lib/python3.15/site-packages/xoa/options.py:254, in load_options(cfgfile) 251 if isinstance(cfgfile, os.PathLike): 252 cfgfile = os.fspath(cfgfile) 253 options.merge( --> 254 configobj.ConfigObj(cfgfile, file_error=True, raise_errors=True, list_values=True) 255 ) 256 _check_options_(options) 257 _XOA_CACHE["options"] = options File ~/checkouts/xoa/conda/develop/lib/python3.15/site-packages/configobj/__init__.py:1224, in ConfigObj.__init__(self, infile, options, configspec, encoding, interpolation, raise_errors, list_values, create_empty, file_error, stringify, indent_type, default_encoding, unrepr, write_empty_values, _inspec) 1222 configspec = options['configspec'] 1223 self._original_configspec = configspec -> 1224 self._load(infile, configspec) File ~/checkouts/xoa/conda/develop/lib/python3.15/site-packages/configobj/__init__.py:1235, in ConfigObj._load(self, infile, configspec) 1232 content = h.readlines() or [] 1233 elif self.file_error: 1234 # raise an error if the file doesn't exist -> 1235 raise IOError('Config file not found: "%s".' % self.filename) 1236 else: 1237 # file doesn't already exist 1238 if self.create_empty: 1239 # this is a good test that the filename specified 1240 # isn't impossible - like on a non-existent device OSError: Config file not found: "/path/to/my/xoa.cfg".