Configure xemc3¶
Currently, only the filenames can be changed.
The default profile is used by default.
[1]:
import xemc3
you can get the current settings using xemc3.config.get():
[2]:
xemc3.config.get()
[2]:
{'filenames': 'default'}
There are 3 ways to change the profile.
Using the with context manager¶
[3]:
with xemc3.config.set(filenames="some_specifc_config"):
try:
xemc3.load.all("some_folder")
except FileNotFoundError as e:
print("some_specifc_config does not exist, so it fails:")
print(e)
pass
some_specifc_config does not exist, so it fails:
[Errno 2] Failed to find a config file for some_specifc_config - the following locations have been tried:
* '/home/docs/checkouts/readthedocs.org/user_builds/xemc3/envs/stable/lib/python3.12/site-packages/xemc3/data/some_specifc_config.yaml'
* '~/.local/xemc3/some_specifc_config.yaml'
outside of the with block, we still have the default config
[4]:
print(xemc3.config.get("filenames"))
default
Simply setting it in the code¶
[5]:
xemc3.config.set(filenames="some_specifc_config")
print(xemc3.config.get("filenames"))
some_specifc_config
you have to reset it afterwards, if you want the default back:
[6]:
print(xemc3.config.get("filenames"))
xemc3.config.set(filenames="default")
print(xemc3.config.get("filenames"))
some_specifc_config
default
Setting it in ~/.local/xemc3/config.yaml¶
This allows to permanently set the default.
Putting
filenames: some_specifc_config
into ~/.local/xemc3/config.yaml will ensure that is from now on used, also by xemc3 command line tools.