8000 Remove some uses of unicode_literals by embray · Pull Request #10044 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Remove some uses of unicode_literals #10044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 21, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@
to MATLAB®, a registered trademark of The MathWorks, Inc.

"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function

import six

Expand Down Expand Up @@ -277,10 +276,7 @@ def _parse_commandline():
'info', 'warning')

for arg in sys.argv[1:]:
# cast to str because we are using unicode_literals,
# and argv is always str

if arg.startswith(str('--verbose-')):
if arg.startswith('--verbose-'):
level_str = arg[10:]
# If it doesn't match one of ours, then don't even
# bother noting it, we are just a 3rd-party library
Expand All @@ -305,9 +301,7 @@ class Verbose(object):
_commandLineVerbose = None

for arg in sys.argv[1:]:
# cast to str because we are using unicode_literals,
# and argv is always str
if not arg.startswith(str('--verbose-')):
if not arg.startswith('--verbose-'):
continue
level_str = arg[10:]
# If it doesn't match one of ours, then don't even
Expand Down Expand Up @@ -716,7 +710,7 @@ def _get_cachedir():


def _decode_filesystem_path(path):
if isinstance(path, bytes):
if not isinstance(path, str):
return path.decode(sys.getfilesystemencoding())
else:
return path
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
it imports matplotlib only at runtime.
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function

import six
from six.moves import xrange, zip
Expand Down
11 changes: 5 additions & 6 deletions lib/matplotlib/dviread.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
...

"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function

import six
from six.moves import xrange
Expand Down Expand Up @@ -764,13 +763,13 @@ def __init__(self, filename):
with open(filename, 'rb') as file:
header1 = file.read(24)
lh, bc, ec, nw, nh, nd = \
struct.unpack(str('!6H'), header1[2:14])
struct.unpack('!6H', header1[2:14])
_log.debug(
'lh=%d, bc=%d, ec=%d, nw=%d, nh=%d, nd=%d' % (
lh, bc, ec, nw, nh, nd))
header2 = file.read(4*lh)
self.checksum, self.design_size = \
struct.unpack(str('!2I'), header2[:8])
struct.unpack('!2I', header2[:8])
# there is also encoding information etc.
char_info = file.read(4*(ec-bc+1))
widths = file.read(4*nw)
Expand All @@ -779,7 +778,7 @@ def __init__(self, filename):

self.width, self.height, self.depth = {}, {}, {}
widths, heights, depths = \
[struct.unpack(str('!%dI') % (len(x)/4), x)
[struct.unpack('!%dI' % (len(x)/4), x)
for x in (widths, heights, depths)]
for idx, char in enumerate(xrange(bc, ec+1)):
byte0 = ord(char_info[4*idx])
Expand Down Expand Up @@ -1040,7 +1039,7 @@ def find_tex_file(filename, format=None):
if isinstance(format, bytes):
format = format.decode('utf-8', errors='replace')

cmd = [str('kpsewhich')]
cmd = ['kpsewhich']
if format is not None:
cmd += ['--format=' + format]
cmd += [filename]
Expand Down
47 changes: 23 additions & 24 deletions lib/matplotlib/finance.py
10000
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
This module is deprecated in 2.0 and has been moved to a module called
`mpl_finance`.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function

import six
from six.moves import xrange, zip
Expand Down Expand Up @@ -57,31 +56,31 @@ def md5(x):


stock_dt_ohlc = np.dtype([
(str('date'), object),
(str('year'), np.int16),
(str('month'), np.int8),
(str('day'), np.int8),
(str('d'), float), # mpl datenum
(str('open'), float),
(str('high'), float),
(str('low'), float),
(str('close'), float),
(str('volume'), float),
(str('aclose'), float)])
('date', object),
('year', np.int16),
('month', np.int8),
('day', np.int8),
('d', float), # mpl datenum
('open', float),
('high', float),
('low', float),
('close', float),
('volume', float),
('aclose', float)])


stock_dt_ochl = np.dtype(
[(str('date'), object),
(str('year'), np.int16),
(str('month'), np.int8),
(str('day'), np.int8),
(str('d'), float), # mpl datenum
(str('open'), float),
(str('close'), float),
(str('high'), float),
(str('low'), float),
(str('volume'), float),
(str('aclose'), float)])
[('date', object),
('year', np.int16),
('month', np.int8),
('day', np.int8),
('d', float), # mpl datenum
('open', float),
('close', float),
('high', float),
('low', float),
('volume', float),
('aclose', float)])


def parse_yahoo_historical_ochl(fh, adjusted=True, asobject=False):
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
platforms, so if a font is installed, it is much more likely to be
found.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function

import six
from six.moves import cPickle as pickle
Expand Down
Loading
0