Skip to content

Commit 41e1afc

Browse files
committed
Fix some python2.6 -3 warnings. (mainly usage of has_key)
svn path=/trunk/matplotlib/; revision=6143
1 parent 34723f2 commit 41e1afc

29 files changed

+74
-82
lines changed

boilerplate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def %(func)s(*args, **kwargs):
114114

115115

116116
for func in _plotcommands:
117-
if cmappable.has_key(func):
117+
if func in cmappable:
118118
mappable = cmappable[func]
119119
else:
120120
mappable = ''

lib/matplotlib/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def _get_configdir():
443443
def _get_data_path():
444444
'get the path to matplotlib data'
445445

446-
if os.environ.has_key('MATPLOTLIBDATA'):
446+
if 'MATPLOTLIBDATA' in os.environ:
447447
path = os.environ['MATPLOTLIBDATA']
448448
if not os.path.isdir(path):
449449
raise RuntimeError('Path in environment MATPLOTLIBDATA not a directory')
@@ -535,7 +535,7 @@ def matplotlib_fname():
535535
fname = os.path.join( os.getcwd(), 'matplotlibrc')
536536
if os.path.exists(fname): return fname
537537

538-
if os.environ.has_key('MATPLOTLIBRC'):
538+
if 'MATPLOTLIBRC' in os.environ:
539539
path = os.environ['MATPLOTLIBRC']
540540
if os.path.exists(path):
541541
fname = os.path.join(path, 'matplotlibrc')
@@ -637,7 +637,7 @@ def rc_params(fail_on_error=False):
637637
verbose.set_fileo(ret['verbose.fileo'])
638638

639639
for key, (val, line, cnt) in rc_temp.iteritems():
640-
if defaultParams.has_key(key):
640+
if key in defaultParams:
641641
if fail_on_error:
642642
ret[key] = val # try to convert to proper type or raise
643643
else:
@@ -745,7 +745,7 @@ def rc(group, **kwargs):
745745
for k,v in kwargs.items():
746746
name = aliases.get(k) or k
747747
key = '%s.%s' % (g, name)
748-
if not rcParams.has_key(key):
748+
if key not in rcParams:
749749
raise KeyError('Unrecognized key "%s" for group "%s" and name "%s"' %
750750
(key, g, name))
751751

lib/matplotlib/_pylab_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def destroy(num):
3131
destroy = staticmethod(destroy)
3232

3333
def has_fignum(num):
34-
return Gcf.figs.has_key(num)
34+
return num in Gcf.figs
3535
has_fignum = staticmethod(has_fignum)
3636

3737
def get_all_fig_managers():

lib/matplotlib/afm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def _parse_optional(fh):
263263
if len(line)==0: continue
264264
key = line.split()[0]
265265

266-
if optional.has_key(key): d[key] = optional[key](fh)
266+
if key in optional: d[key] = optional[key](fh)
267267

268268
l = ( d['StartKernData'], d['StartComposites'] )
269269
return l

lib/matplotlib/artist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ def aliased_name(self, s):
662662
alias, return 'markerfacecolor or mfc' and for the transform
663663
property, which does not, return 'transform'
664664
"""
665-
if self.aliasd.has_key(s):
665+
if s in self.aliasd:
666666
return '%s or %s' % (s, self.aliasd[s])
667667
else: return s
668668

lib/matplotlib/axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@ def _process_plot_format(fmt):
7373
chars = [c for c in fmt]
7474

7575
for c in chars:
76-
if mlines.lineStyles.has_key(c):
76+
if c in mlines.lineStyles:
7777
if linestyle is not None:
7878
raise ValueError(
7979
'Illegal format string "%s"; two linestyle symbols' % fmt)
8080
linestyle = c
81-
elif mlines.lineMarkers.has_key(c):
81+
elif c in mlines.lineMarkers:
8282
if marker is not None:
8383
raise ValueError(
8484
'Illegal format string "%s"; two marker symbols' % fmt)
8585
marker = c
86-
elif mcolors.colorConverter.colors.has_key(c):
86+
elif c in mcolors.colorConverter.colors:
8787
if color is not None:
8888
raise ValueError(
8989
'Illegal format string "%s"; two color symbols' % fmt)
@@ -2632,7 +2632,7 @@ def text(self, x, y, s, fontdict=None,
26322632

26332633

26342634
#if t.get_clip_on(): t.set_clip_box(self.bbox)
2635-
if kwargs.has_key('clip_on'): t.set_clip_box(self.bbox)
2635+
if 'clip_on' in kwargs: t.set_clip_box(self.bbox)
26362636
return t
26372637
text.__doc__ = cbook.dedent(text.__doc__) % martist.kwdocd
26382638

lib/matplotlib/backends/backend_gtk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def motion_notify_event(self, widget, event):
234234
return False # finish event propagation?
235235

236236
def _get_key(self, event):
237-
if self.keyvald.has_key(event.keyval):
237+
if event.keyval in self.keyvald:
238238
key = self.keyvald[event.keyval]
239239
elif event.keyval <256:
240240
key = chr(event.keyval)

lib/matplotlib/backends/backend_qt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def minumumSizeHint( self ):
170170
def _get_key( self, event ):
171171
if event.key() < 256:
172172
key = event.text().latin1()
173-
elif self.keyvald.has_key( event.key() ):
173+
elif event.key() in self.keyvald.has_key:
174174
key = self.keyvald[ event.key() ]
175175
else:
176176
key = None

lib/matplotlib/backends/backend_qt4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def minumumSizeHint( self ):
174174
def _get_key( self, event ):
175175
if event.key() < 256:
176176
key = str(event.text())
177-
elif self.keyvald.has_key( event.key() ):
177+
elif event.key() in self.keyvald:
178178
key = self.keyvald[ event.key() ]
179179
else:
180180
key = None

lib/matplotlib/backends/backend_tkagg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def scroll_event_windows(self, event):
297297

298298
def _get_key(self, event):
299299
val = event.keysym_num
300-
if self.keyvald.has_key(val):
300+
if val in self.keyvald:
301301
key = self.keyvald[val]
302302
elif val<256:
303303
key = chr(val)

0 commit comments

Comments
 (0)