Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d48a830

Browse files
committed
Only display warning when config file (not config directory) still exists.
1 parent 97b0513 commit d48a830

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

lib/matplotlib/__init__.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -544,23 +544,10 @@ def _get_config_or_cache_dir(xdg_base):
544544
return configdir
545545

546546
h = get_home()
547-
if sys.platform.startswith('linux'):
548-
xdg_path = os.path.join(xdg_base, 'matplotlib')
549-
550-
p = os.path.join(h, '.matplotlib')
551-
if os.path.exists(p):
552-
warnings.warn(
553-
"Found matplotlib configuration in ~/.matplotlib. "
554-
"To conform with the XDG base directory standard, "
555-
"this configuration directory has been deprecated "
556-
"on Linux, and the new location is now %r. Please "
557-
"move your configuration there to ensure that "
558-
"matplotlib will continue to find it in the future." %
559-
xdg_path)
560-
else:
561-
p = xdg_path
562-
else:
563-
p = os.path.join(h, '.matplotlib')
547+
p = os.path.join(h, '.matplotlib')
548+
if (sys.platform.startswith('linux') and
549+
not os.path.exists(p)):
550+
p = _get_xdg_config_dir()
564551

565552
if os.path.exists(p):
566553
if not _is_writable_dir(p):
@@ -726,6 +713,17 @@ def matplotlib_fname():
726713
if configdir is not None:
727714
fname = os.path.join(configdir, 'matplotlibrc')
728715
if os.path.exists(fname):
716+
if (sys.platform.startswith('linux') and
717+
fname == os.path.join(
718+
get_home(), '.matplotlib', 'matplotlibrc')):
719+
warnings.warn(
720+
"Found matplotlib configuration in ~/.matplotlib. "
721+
"To conform with the XDG base directory standard, "
722+
"this configuration location has been deprecated "
723+
"on Linux, and the new location is now %r. Please "
724+
"move your configuration there to ensure that "
725+
"matplotlib will continue to find it in the future." %
726+
_get_xdg_config_dir())
729727
return fname
730728

731729
path = get_data_path() # guaranteed to exist or raise

0 commit comments

Comments
 (0)