Skip to content

Commit

Permalink
python3 compatibility: has_key
Browse files Browse the repository at this point in the history
don't use method removed from python3
  • Loading branch information
mvyskocil authored and adrianschroeter committed Apr 16, 2013
1 parent 19f689c commit 2ad4a8c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion osc/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def main(apiurl, opts, argv):
if val:
if var.startswith('OSC_'): var = var[4:]
var = var.lower().replace('_', '-')
if config.has_key(var):
if var in config:
print 'Overriding config value for %s=\'%s\' with \'%s\'' % (var, config[var], val)
config[var] = val

Expand Down
8 changes: 4 additions & 4 deletions osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6289,7 +6289,7 @@ def do_my(self, subcmd, opts, *args):
pass

res = get_user_projpkgs(apiurl, user, role_filter, exclude_projects,
what.has_key('project'), what.has_key('package'),
'project' in what, 'package' in what,
opts.maintained, opts.verbose)

# map of project =>[list of packages]
Expand Down Expand Up @@ -7046,7 +7046,7 @@ def do_whois(self, subcmd, opts, *usernames):
"""
apiurl = self.get_api_url()
if len(usernames) < 1:
if not conf.config['api_host_options'][apiurl].has_key('user'):
if 'user' not in conf.config['api_host_options'][apiurl]:
raise oscerr.WrongArgs('your .oscrc does not have your user name.')
usernames = (conf.config['api_host_options'][apiurl]['user'],)
for name in usernames:
Expand Down Expand Up @@ -7595,7 +7595,7 @@ def do_vc(self, subcmd, opts, *args):
cmd_list = ['/usr/lib/build/vc']

# set user's email if no mailaddr exists
if not os.environ.has_key('mailaddr'):
if 'mailaddr' not in os.environ:

if len(args) and is_package_dir(args[0]):
apiurl = store_read_apiurl(args[0])
Expand All @@ -7611,7 +7611,7 @@ def do_vc(self, subcmd, opts, *args):
print >>sys.stderr, 'Try env mailaddr=...'

# mailaddr can be overrided by config one
if conf.config['api_host_options'][apiurl].has_key('email'):
if 'email' in conf.config['api_host_options'][apiurl]:
os.environ['mailaddr'] = conf.config['api_host_options'][apiurl]['email']

if meego_style:
Expand Down
12 changes: 6 additions & 6 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ def commit(self, pacs = (), msg = '', files = {}, verbose = False, skip_local_se
try:
for pac in pacs:
todo = []
if files.has_key(pac):
if pac in files:
todo = files[pac]
state = self.get_state(pac)
if state == 'A':
Expand Down Expand Up @@ -4927,7 +4927,7 @@ def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[], ve
continue

for res in results:
if res.has_key('_oldstate'):
if '_oldstate' in res:
oldstate = res['_oldstate']
continue
res['status'] = res['code']
Expand Down Expand Up @@ -5066,7 +5066,7 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non
line.append(' ')
for pac in pacs[startpac:startpac+max_pacs]:
st = ''
if not status.has_key(pac) or not status[pac].has_key(tg):
if pac not in status or tg not in status[pac]:
# for newly added packages, status may be missing
st = '?'
else:
Expand Down Expand Up @@ -5095,7 +5095,7 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non
line = []
for tg in targets:
st = ''
if not status.has_key(pac) or not status[pac].has_key(tg):
if pac not in status or tg not in status[pac]:
# for newly added packages, status may be missing
st = '?'
else:
Expand Down Expand Up @@ -6539,9 +6539,9 @@ def get_user_projpkgs(apiurl, user, role=None, exclude_projects=[], proj=True, p
raise e
# backward compatibility: local role filtering
what = dict([[kind, role_filter_xpath] for kind in what.keys()])
if what.has_key('package'):
if 'package' in what:
what['package'] = xpath_join(role_filter_xpath, excl_pkg, op='and')
if what.has_key('project'):
if 'project' in what:
what['project'] = xpath_join(role_filter_xpath, excl_prj, op='and')
res = search(apiurl, **what)
filter_role(res, user, role)
Expand Down

0 comments on commit 2ad4a8c

Please sign in to comment.