Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f01ebe1

Browse filesBrowse files
committed
matplotlib, texmanager: Only print the rename message if it actually succeeded.
1 parent cc8cd1b commit f01ebe1
Copy full SHA for f01ebe1

File tree

Expand file treeCollapse file tree

2 files changed

+12
-9
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-9
lines changed

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -647,13 +647,14 @@ def matplotlib_fname():
647647

648648
oldname = os.path.join(os.getcwd(), '.matplotlibrc')
649649
if os.path.exists(oldname):
650-
warnings.warn("""\
651-
Old rc filename ".matplotlibrc" found in working dir and and renamed to new
652-
default rc file name "matplotlibrc" (no leading ".").""")
653650
try:
654651
shutil.move('.matplotlibrc', 'matplotlibrc')
655652
except IOError as e:
656653
warnings.warn('File could not be renamed: %s' % e)
654+
else:
655+
warnings.warn("""\
656+
Old rc filename ".matplotlibrc" found in working dir and and renamed to new
657+
default rc file name "matplotlibrc" (no leading ".").""")
657658

658659
home = get_home()
659660
configdir = get_configdir()
@@ -662,14 +663,15 @@ def matplotlib_fname():
662663
if os.path.exists(oldname):
663664
if configdir is not None:
664665
newname = os.path.join(configdir, 'matplotlibrc')
665-
warnings.warn("""\
666-
Old rc filename "%s" found and renamed to new default rc file name "%s"."""
667-
% (oldname, newname))
668666

669667
try:
670668
shutil.move(oldname, newname)
671669
except IOError as e:
672670
warnings.warn('File could not be renamed: %s' % e)
671+
else:
672+
warnings.warn("""\
673+
Old rc filename "%s" found and renamed to new default rc file name "%s"."""
674+
% (oldname, newname))
673675
else:
674676
warnings.warn("""\
675677
Could not rename old rc file "%s": a suitable configuration directory could not

‎lib/matplotlib/texmanager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/texmanager.py
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,14 @@ class TexManager:
104104

105105
if os.path.exists(oldcache):
106106
if texcache is not None:
107-
warnings.warn("""\
108-
Found a TeX cache dir in the deprecated location "%s".
109-
Moving it to the new default location "%s".""" % (oldcache, texcache))
110107
try:
111108
shutil.move(oldcache, texcache)
112109
except IOError as e:
113110
warnings.warn('File could not be renamed: %s' % e)
111+
else:
112+
warnings.warn("""\
113+
Found a TeX cache dir in the deprecated location "%s".
114+
Moving it to the new default location "%s".""" % (oldcache, texcache))
114115
else:
115116
warnings.warn("""\
116117
Could not rename old TeX cache dir "%s": a suitable configuration

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.