Skip to content

Commit 5e8f627

Browse files
committed
Python 3 preparation: change "x.has_key(y)" to "y in x".
(Also likewise "not in" where appropriate.) Tool-generated patch.
1 parent 6107bbf commit 5e8f627

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+184
-185
lines changed

detectors/creator_resolution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def creator_resolution(db, cl, nodeid, newvalues):
99
"confirm-done" first though, but "classic" Roundup doesn't have that
1010
status)
1111
'''
12-
if not newvalues.has_key('status'):
12+
if 'status' not in newvalues:
1313
return
1414

1515
# get the resolved state ID

detectors/emailauditor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def eml_to_mht(db, cl, nodeid, newvalues):
2929
3030
So... we do that. :)'''
3131
if newvalues.get('type', '').lower() == "message/rfc822":
32-
if not newvalues.has_key('name'):
32+
if 'name' not in newvalues:
3333
newvalues['name'] = 'email.mht'
3434
return
3535
name = newvalues['name']

frontends/ZRoundup/ZRoundup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ def __getitem__(self, item):
9595
def __iter__(self):
9696
return iter(self.__form)
9797
def getvalue(self, key, default=None):
98-
if self.__form.has_key(key):
98+
if key in self.__form:
9999
return self.__form[key]
100100
else:
101101
return default
102102
def has_key(self, item):
103-
return self.__form.has_key(item)
103+
return item in self.__form
104104
def keys(self):
105105
return self.__form.keys()
106106

frontends/ZRoundup/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import os
2020
# figure where ZRoundup is installed
2121
here = None
22-
if os.environ.has_key('INSTANCE_HOME'):
22+
if 'INSTANCE_HOME' in os.environ:
2323
here = os.environ['INSTANCE_HOME']
2424
path = os.path.join(here, 'Products', 'ZRoundup')
2525
if not os.path.exists(path):

roundup/backends/back_mysql.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@
4949

5050
def connection_dict(config, dbnamestr=None):
5151
d = rdbms_common.connection_dict(config, dbnamestr)
52-
if d.has_key('password'):
52+
if 'password' in d:
5353
d['passwd'] = d['password']
5454
del d['password']
55-
if d.has_key('port'):
55+
if 'port' in d:
5656
d['port'] = int(d['port'])
5757
return d
5858

@@ -252,12 +252,12 @@ def add_new_columns_v2(self):
252252
for name, s_prop in old_spec[1]:
253253
# s_prop is a repr() string of a hyperdb type object
254254
if s_prop.find('Multilink') == -1:
255-
if properties.has_key(name):
255+
if name in properties:
256256
propnames.append(name)
257257
continue
258258
tn = '%s_%s'%(cn, name)
259259

260-
if properties.has_key(name):
260+
if name in properties:
261261
# grabe the current values
262262
sql = 'select linkid, nodeid from %s'%tn
263263
self.sql(sql)
@@ -268,7 +268,7 @@ def add_new_columns_v2(self):
268268
sql = 'drop table %s'%tn
269269
self.sql(sql)
270270

271-
if properties.has_key(name):
271+
if name in properties:
272272
# re-create and populate the new table
273273
self.create_multilink_table(klass, name)
274274
sql = '''insert into %s (linkid, nodeid) values

roundup/cgi/PageTemplates/MultiMapping.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ def __init__(self, *stores):
55
self.stores = list(stores)
66
def __getitem__(self, key):
77
for store in self.stores:
8-
if store.has_key(key):
8+
if key in store:
99
return store[key]
1010
raise KeyError(key)
1111
_marker = []
1212
def get(self, key, default=_marker):
1313
for store in self.stores:
14-
if store.has_key(key):
14+
if key in store:
1515
return store[key]
1616
if default is self._marker:
1717
raise KeyError(key)

roundup/cgi/PageTemplates/PageTemplate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def pt_render(self, source=0, extra_context={}):
9393
return output.getvalue()
9494

9595
def __call__(self, *args, **kwargs):
96-
if not kwargs.has_key('args'):
96+
if 'args' not in kwargs:
9797
kwargs['args'] = args
9898
return self.pt_render(extra_context={'options': kwargs})
9999

roundup/cgi/PageTemplates/TALES.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def registerType(self, name, handler):
114114
if not _valid_name(name):
115115
raise RegistrationError('Invalid Expression type "%s".' % name)
116116
types = self.types
117-
if types.has_key(name):
117+
if name in types:
118118
raise RegistrationError(
119119
'Multiple registrations for Expression type "%s".' %
120120
name)

roundup/cgi/TAL/DummyEngine.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
ustr = str
2828

2929
IDomain = None
30-
if sys.modules.has_key('Zope'):
30+
if 'Zope' in sys.modules:
3131
try:
3232
from Zope.I18n.ITranslationService import ITranslationService
3333
from Zope.I18n.IDomain import IDomain
@@ -114,7 +114,7 @@ def evaluate(self, expression):
114114
if type == "not":
115115
return not self.evaluate(expr)
116116
if type == "exists":
117-
return self.locals.has_key(expr) or self.globals.has_key(expr)
117+
return expr in self.locals or expr in self.globals
118118
if type == "python":
119119
try:
120120
return eval(expr, self.globals, self.locals)
@@ -132,9 +132,9 @@ def evaluate(self, expression):
132132

133133
def evaluatePathOrVar(self, expr):
134134
expr = expr.strip()
135-
if self.locals.has_key(expr):
135+
if expr in self.locals:
136136
return self.locals[expr]
137-
elif self.globals.has_key(expr):
137+
elif expr in self.globals:
138138
return self.globals[expr]
139139
else:
140140
raise TALESError("unknown variable: %s" % repr(expr))

roundup/cgi/TAL/HTMLTALParser.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def close_para_tags(self, tag):
183183
if tag in EMPTY_HTML_TAGS:
184184
return
185185
close_to = -1
186-
if BLOCK_CLOSING_TAG_MAP.has_key(tag):
186+
if tag in BLOCK_CLOSING_TAG_MAP:
187187
blocks_to_close = BLOCK_CLOSING_TAG_MAP[tag]
188188
for i in range(len(self.tagstack)):
189189
t = self.tagstack[i]
@@ -295,17 +295,17 @@ def process_ns(self, name, attrs):
295295
if ns and ns != 'unknown':
296296
item = (key, value, ns)
297297
if ns == 'tal':
298-
if taldict.has_key(keybase):
298+
if keybase in taldict:
299299
raise TALError("duplicate TAL attribute " +
300300
repr(keybase), self.getpos())
301301
taldict[keybase] = value
302302
elif ns == 'metal':
303-
if metaldict.has_key(keybase):
303+
if keybase in metaldict:
304304
raise METALError("duplicate METAL attribute " +
305305
repr(keybase), self.getpos())
306306
metaldict[keybase] = value
307307
elif ns == 'i18n':
308-
if i18ndict.has_key(keybase):
308+
if keybase in i18ndict:
309309
raise I18NError("duplicate i18n attribute " +
310310
repr(keybase), self.getpos())
311311
i18ndict[keybase] = value

0 commit comments

Comments
 (0)