MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / matplotlib_fname

Function matplotlib_fname

lib/matplotlib/__init__.py:640–682  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

638
639
640def 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
685class RcParams(MutableMapping, dict):

Callers 2

rc_paramsFunction · 0.85
__init__.pyFile · 0.85

Calls 1

gen_candidatesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…