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 cc8cd1b

Browse filesBrowse files
committed
matplotlib, texmanager: Change WARNING prints into real warnings.
1 parent ca6cd19 commit cc8cd1b
Copy full SHA for cc8cd1b

File tree

Expand file treeCollapse file tree

2 files changed

+19
-23
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-23
lines changed

‎lib/matplotlib/__init__.py

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

648648
oldname = os.path.join(os.getcwd(), '.matplotlibrc')
649649
if os.path.exists(oldname):
650-
print("""\
651-
WARNING: Old rc filename ".matplotlibrc" found in working dir
652-
and and renamed to new default rc file name "matplotlibrc"
653-
(no leading"dot"). """, file=sys.stderr)
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 ".").""")
654653
try:
655654
shutil.move('.matplotlibrc', 'matplotlibrc')
656655
except IOError as e:
657-
print("WARNING: File could not be renamed: %s" % e, file=sys.stderr)
656+
warnings.warn('File could not be renamed: %s' % e)
658657

659658
home = get_home()
660659
configdir = get_configdir()
@@ -663,19 +662,18 @@ def matplotlib_fname():
663662
if os.path.exists(oldname):
664663
if configdir is not None:
665664
newname = os.path.join(configdir, 'matplotlibrc')
666-
print("""\
667-
WARNING: Old rc filename "%s" found and renamed to
668-
new default rc file name "%s"."""%(oldname, newname), file=sys.stderr)
665+
warnings.warn("""\
666+
Old rc filename "%s" found and renamed to new default rc file name "%s"."""
667+
% (oldname, newname))
669668

670669
try:
671670
shutil.move(oldname, newname)
672671
except IOError as e:
673-
print("WARNING: File could not be renamed: %s" % e,
674-
file=sys.stderr)
672+
warnings.warn('File could not be renamed: %s' % e)
675673
else:
676-
print("""\
677-
WARNING: Could not rename old rc file "%s": a suitable configuration directory
678-
could not be found.""" % oldname, file=sys.stderr)
674+
warnings.warn("""\
675+
Could not rename old rc file "%s": a suitable configuration directory could not
676+
be found.""" % oldname)
679677

680678
fname = os.path.join(os.getcwd(), 'matplotlibrc')
681679
if os.path.exists(fname): return fname

‎lib/matplotlib/texmanager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/texmanager.py
+8-10Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import os
4242
import shutil
4343
import sys
44+
import warnings
4445

4546
from hashlib import md5
4647

@@ -103,20 +104,17 @@ class TexManager:
103104

104105
if os.path.exists(oldcache):
105106
if texcache is not None:
106-
# FIXME raise proper warning
107-
print("""\
108-
WARNING: found a TeX cache dir in the deprecated location "%s".
109-
Moving it to the new default location "%s".""" % (oldcache, texcache),
110-
file=sys.stderr)
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))
111110
try:
112111
shutil.move(oldcache, texcache)
113112
except IOError as e:
114-
print("WARNING: File could not be renamed: %s" % e,
115-
file=sys.stderr)
113+
warnings.warn('File could not be renamed: %s' % e)
116114
else:
117-
print("""\
118-
WARNING: Could not rename old TeX cache dir "%s": a suitable configuration
119-
directory could not be found.""" % oldcache, file=sys.stderr)
115+
warnings.warn("""\
116+
Could not rename old TeX cache dir "%s": a suitable configuration
117+
directory could not be found.""" % oldcache)
120118

121119
if texcache is not None:
122120
mkdirs(texcache)

0 commit comments

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