skip to main content

@tonyfast s notebooks

site navigation
notebook summary
title
configuration files
description
i'm going to include my configuration files in this package. it seems like a great place to keep them for consistency. we can import them.
cells
10 total
6 code
state
executed out of order
kernel
Python [conda env:root] *
language
python
name
conda-root-py
lines of code
26
outputs
0
table of contents
{"kernelspec": {"display_name": "Python [conda env:root] *", "language": "python", "name": "conda-root-py"}, "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.9.13"}, "title": "configuration files", "description": "i'm going to include my configuration files in this package. it seems like a great place to keep them for consistency.\nwe can import them."}
notebook toolbar
Activate
cell ordering
1

configuration files

i'm going to include my configuration files in this package. it seems like a great place to keep them for consistency. we can import them.

2
    from tonyfast import ipython_config, jupyter_lab_config
3

the configurations on the c symbol staying consistent with traitlets configurations.

4
    ipython_config.c
5

then we can apply the configuration files to the property directories. IPython and jupyter_core ship their path locations

6
    import IPython.paths, jupyter_core.paths
    from pathlib import Path
7
    JUPYTER = Path(jupyter_core.paths.jupyter_config_dir())
    IPYTHON = Path(IPython.paths.get_ipython_dir())
8

set the configuration files for IPython and jupyter

9
    def set_configs(use_platform_dir: bool=True):
        import shutil
        if use_platform_dir:
            shutil.copy(jupyter_lab_config.__file__, JUPYTER / Path(jupyter_lab_config.__file__).name)        
            shutil.copy(ipython_config.__file__, IPYTHON / Path(ipython_config.__file__).name)
        else:
            shutil.copy(jupyter_lab_config.__file__, Path(jupyter_lab_config.__file__).name)        
            shutil.copy(ipython_config.__file__, Path(ipython_config.__file__).name)
10
    if __name__ == "__main__":
        if "__file__" in locals():
            __import__("typer").run(set_configs)
        else:
            !importnb 2022-12-31-jupyter-config-files.ipynb --help