Get the location of the config file. The file location is determined in the following order - ``$PWD/matplotlibrc`` - ``$MATPLOTLIBRC`` if it is not a directory - ``$MATPLOTLIBRC/matplotlibrc`` - ``$MPLCONFIGDIR/matplotlibrc`` - On Linux, - ``$XDG_CONFIG_HOME/m
()
| 638 | |
| 639 | |
| 640 | def matplotlib_fname(): |
| 641 | """ |
| 642 | Get the location of the config file. |
| 643 | |
| 644 | The file location is determined in the following order |
| 645 | |
| 646 | - ``$PWD/matplotlibrc`` |
| 647 | - ``$MATPLOTLIBRC`` if it is not a directory |
| 648 | - ``$MATPLOTLIBRC/matplotlibrc`` |
| 649 | - ``$MPLCONFIGDIR/matplotlibrc`` |
| 650 | - On Linux, |
| 651 | - ``$XDG_CONFIG_HOME/matplotlib/matplotlibrc`` (if ``$XDG_CONFIG_HOME`` |
| 652 | is defined) |
| 653 | - or ``$HOME/.config/matplotlib/matplotlibrc`` (if ``$XDG_CONFIG_HOME`` |
| 654 | is not defined) |
| 655 | - On other platforms, |
| 656 | - ``$HOME/.matplotlib/matplotlibrc`` if ``$HOME`` is defined |
| 657 | - Lastly, it looks in ``$MATPLOTLIBDATA/matplotlibrc``, which should always |
| 658 | exist. |
| 659 | """ |
| 660 | |
| 661 | def gen_candidates(): |
| 662 | # rely on down-stream code to make absolute. This protects us |
| 663 | # from having to directly get the current working directory |
| 664 | # which can fail if the user has ended up with a cwd that is |
| 665 | # non-existent. |
| 666 | yield 'matplotlibrc' |
| 667 | try: |
| 668 | matplotlibrc = os.environ['MATPLOTLIBRC'] |
| 669 | except KeyError: |
| 670 | pass |
| 671 | else: |
| 672 | yield matplotlibrc |
| 673 | yield os.path.join(matplotlibrc, 'matplotlibrc') |
| 674 | yield os.path.join(get_configdir(), 'matplotlibrc') |
| 675 | yield os.path.join(get_data_path(), 'matplotlibrc') |
| 676 | |
| 677 | for fname in gen_candidates(): |
| 678 | if os.path.exists(fname) and not os.path.isdir(fname): |
| 679 | return fname |
| 680 | |
| 681 | raise RuntimeError("Could not find matplotlibrc file; your Matplotlib " |
| 682 | "install is broken") |
| 683 | |
| 684 | |
| 685 | class RcParams(MutableMapping, dict): |
no test coverage detected
searching dependent graphs…