{ "cells": [ { "cell_type": "markdown", "id": "f86a8411", "metadata": {}, "source": [ "# Configure xemc3\n", "\n", "Currently, only the filenames can be changed.\n", "\n", "The `default` profile is used by default.\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "751c671b", "metadata": {}, "outputs": [], "source": [ "import xemc3" ] }, { "cell_type": "markdown", "id": "5d4f0cb5", "metadata": {}, "source": [ "you can get the current settings using `xemc3.config.get()`:" ] }, { "cell_type": "code", "execution_count": null, "id": "dd7e2f45", "metadata": {}, "outputs": [], "source": [ "xemc3.config.get()" ] }, { "cell_type": "markdown", "id": "32e8e365", "metadata": {}, "source": [ "There are 3 ways to change the profile.\n", "\n", "## Using the `with` context manager" ] }, { "cell_type": "code", "execution_count": null, "id": "f9c0172d", "metadata": {}, "outputs": [], "source": [ "with xemc3.config.set(filenames=\"some_specifc_config\"):\n", " try:\n", " xemc3.load.all(\"some_folder\")\n", " except FileNotFoundError as e:\n", " print(\"some_specifc_config does not exist, so it fails:\")\n", " print(e)\n", " pass" ] }, { "cell_type": "markdown", "id": "bad2ff2d", "metadata": {}, "source": [ "outside of the with block, we still have the default config" ] }, { "cell_type": "code", "execution_count": null, "id": "362cd948", "metadata": {}, "outputs": [], "source": [ "print(xemc3.config.get(\"filenames\"))" ] }, { "cell_type": "markdown", "id": "4dedefee", "metadata": {}, "source": [ "## Simply setting it in the code" ] }, { "cell_type": "code", "execution_count": null, "id": "0ddb975e", "metadata": {}, "outputs": [], "source": [ "xemc3.config.set(filenames=\"some_specifc_config\")\n", "print(xemc3.config.get(\"filenames\"))" ] }, { "cell_type": "markdown", "id": "a241640d", "metadata": {}, "source": [ "you have to reset it afterwards, if you want the default back:" ] }, { "cell_type": "code", "execution_count": null, "id": "023c9a9a", "metadata": {}, "outputs": [], "source": [ "print(xemc3.config.get(\"filenames\"))\n", "xemc3.config.set(filenames=\"default\")\n", "print(xemc3.config.get(\"filenames\"))" ] }, { "cell_type": "markdown", "id": "441898a3", "metadata": {}, "source": [ "## Setting it in `~/.local/xemc3/config.yaml`\n", "\n", "This allows to permanently set the default.\n", "\n", "Putting\n", "```\n", "filenames: some_specifc_config\n", "```\n", "into `~/.local/xemc3/config.yaml` will ensure that is from now on used, also by xemc3 command line tools." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.7" } }, "nbformat": 4, "nbformat_minor": 5 }