Skip to content

Commit 9876c38

Browse files
committed
lint fix
1 parent 043a552 commit 9876c38

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

matplotlib2tikz/save.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import codecs
44
import os
55
import matplotlib as mpl
6+
import six
67

78
from . import axes
89
from . import legend
@@ -19,7 +20,6 @@
1920
def get_tikz_code(
2021
filepath,
2122
figure='gcf',
22-
encoding=None,
2323
figurewidth=None,
2424
figureheight=None,
2525
textsize=10.0,
@@ -30,7 +30,7 @@ def get_tikz_code(
3030
extra_tikzpicture_parameters=None,
3131
dpi=None,
3232
show_info=True
33-
):
33+
):
3434
'''Main function. Here, the recursion into the image starts and the
3535
contents are picked up. The actual file gets written in this routine.
3636
@@ -39,8 +39,6 @@ def get_tikz_code(
3939
:param filepath: The file to which the TikZ output will be written.
4040
:type filepath: str
4141
42-
:param encoding: Which encoding to use for the file.
43-
4442
:param figurewidth: If not ``None``, this will be used as figure width
4543
within the TikZ/PGFPlots output. If ``figureheight``
4644
is not given, ``matplotlib2tikz`` will try to preserve
@@ -185,16 +183,13 @@ def save(*args, **kwargs):
185183
'''
186184
code = get_tikz_code(*args, **kwargs)
187185

188-
file_handle = codecs.open(
189-
args[0],
190-
'w',
191-
kwargs['encoding'] if 'encoding' in kwargs else None
192-
)
186+
encoding = kwargs['encoding'] if 'encoding' in kwargs else None
187+
file_handle = codecs.open(args[0], 'w', encoding)
193188
try:
194189
file_handle.write(code)
195190
except UnicodeEncodeError:
196-
# We're probably using Python 2, so use proper unicode treatment
197-
file_handle.write(unicode(code).encode('utf-8'))
191+
# We're probably using Python 2, so treat unicode explicitly
192+
file_handle.write(six.text_type(code).encode('utf-8'))
198193
file_handle.close()
199194
return
200195

0 commit comments

Comments
 (0)