1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-02 09:46:16 +01:00

python3 compatibility: has_key

don't use method removed from python3
This commit is contained in:
Michal Vyskocil 2013-04-09 11:33:25 +02:00 committed by Adrian Schröter
parent 19f689ce0b
commit 2ad4a8c873
3 changed files with 11 additions and 11 deletions

View File

@ -478,7 +478,7 @@ def main(apiurl, opts, argv):
if val: if val:
if var.startswith('OSC_'): var = var[4:] if var.startswith('OSC_'): var = var[4:]
var = var.lower().replace('_', '-') 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) print 'Overriding config value for %s=\'%s\' with \'%s\'' % (var, config[var], val)
config[var] = val config[var] = val

View File

@ -6289,7 +6289,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
pass pass
res = get_user_projpkgs(apiurl, user, role_filter, exclude_projects, 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) opts.maintained, opts.verbose)
# map of project =>[list of packages] # map of project =>[list of packages]
@ -7046,7 +7046,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
""" """
apiurl = self.get_api_url() apiurl = self.get_api_url()
if len(usernames) < 1: 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.') raise oscerr.WrongArgs('your .oscrc does not have your user name.')
usernames = (conf.config['api_host_options'][apiurl]['user'],) usernames = (conf.config['api_host_options'][apiurl]['user'],)
for name in usernames: for name in usernames:
@ -7595,7 +7595,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
cmd_list = ['/usr/lib/build/vc'] cmd_list = ['/usr/lib/build/vc']
# set user's email if no mailaddr exists # 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]): if len(args) and is_package_dir(args[0]):
apiurl = store_read_apiurl(args[0]) apiurl = store_read_apiurl(args[0])
@ -7611,7 +7611,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print >>sys.stderr, 'Try env mailaddr=...' print >>sys.stderr, 'Try env mailaddr=...'
# mailaddr can be overrided by config one # 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'] os.environ['mailaddr'] = conf.config['api_host_options'][apiurl]['email']
if meego_style: if meego_style:

View File

@ -838,7 +838,7 @@ class Project:
try: try:
for pac in pacs: for pac in pacs:
todo = [] todo = []
if files.has_key(pac): if pac in files:
todo = files[pac] todo = files[pac]
state = self.get_state(pac) state = self.get_state(pac)
if state == 'A': if state == 'A':
@ -4927,7 +4927,7 @@ def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[], ve
continue continue
for res in results: for res in results:
if res.has_key('_oldstate'): if '_oldstate' in res:
oldstate = res['_oldstate'] oldstate = res['_oldstate']
continue continue
res['status'] = res['code'] res['status'] = res['code']
@ -5066,7 +5066,7 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non
line.append(' ') line.append(' ')
for pac in pacs[startpac:startpac+max_pacs]: for pac in pacs[startpac:startpac+max_pacs]:
st = '' 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 # for newly added packages, status may be missing
st = '?' st = '?'
else: else:
@ -5095,7 +5095,7 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non
line = [] line = []
for tg in targets: for tg in targets:
st = '' 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 # for newly added packages, status may be missing
st = '?' st = '?'
else: else:
@ -6539,9 +6539,9 @@ def get_user_projpkgs(apiurl, user, role=None, exclude_projects=[], proj=True, p
raise e raise e
# backward compatibility: local role filtering # backward compatibility: local role filtering
what = dict([[kind, role_filter_xpath] for kind in what.keys()]) 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') 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') what['project'] = xpath_join(role_filter_xpath, excl_prj, op='and')
res = search(apiurl, **what) res = search(apiurl, **what)
filter_role(res, user, role) filter_role(res, user, role)