diff --git a/osc/build.py b/osc/build.py index d882cdcc..ecae364f 100644 --- a/osc/build.py +++ b/osc/build.py @@ -331,7 +331,7 @@ def get_prefer_pkgs(dirs, wanted_arch, type): packageQueries.add(packageQuery) prefer_pkgs = dict((name, packageQuery.path()) - for name, packageQuery in packageQueries.iteritems()) + for name, packageQuery in packageQueries.items()) depfile = create_deps(packageQueries.values()) cpio = cpio.CpioWrite() @@ -631,7 +631,7 @@ def main(apiurl, opts, argv): else: raise - bi = Buildinfo(bi_filename, apiurl, build_type, prefer_pkgs.keys()) + bi = Buildinfo(bi_filename, apiurl, build_type, list(prefer_pkgs.keys())) if bi.debuginfo and not (opts.disable_debuginfo or '--debug' in buildargs): buildargs.append('--debug') @@ -660,7 +660,7 @@ def main(apiurl, opts, argv): rpmlist_prefers = [] if prefer_pkgs: print 'Evaluating preferred packages' - for name, path in prefer_pkgs.iteritems(): + for name, path in prefer_pkgs.tems(): if bi.has_dep(name): # We remove a preferred package from the buildinfo, so that the # fetcher doesn't take care about them. @@ -804,7 +804,7 @@ def main(apiurl, opts, argv): else: os.symlink(sffn, tffn) if prefer_pkgs: - for name, path in prefer_pkgs.iteritems(): + for name, path in prefer_pkgs.items(): if name == filename: print "Using prefered package: " + path + "/" + filename os.unlink(tffn) diff --git a/osc/cmdln.py b/osc/cmdln.py index f6ec2e1a..9f9c0156 100644 --- a/osc/cmdln.py +++ b/osc/cmdln.py @@ -707,10 +707,8 @@ class RawCmdln(cmd.Cmd): for attr in self.get_names(): if attr.startswith("do_"): cmdnames[attr[3:]] = True - cmdnames = cmdnames.keys() - cmdnames.sort() linedata = [] - for cmdname in cmdnames: + for cmdname in sorted(cmdnames.keys()): if aliases.get(cmdname): a = aliases[cmdname] a.sort() @@ -770,8 +768,7 @@ class RawCmdln(cmd.Cmd): helpnames[helpname] = True if helpnames: - helpnames = helpnames.keys() - helpnames.sort() + helpnames = sorted(helpnames.keys()) linedata = [(self.name+" help "+n, "") for n in helpnames] subindent = indent + ' '*4 diff --git a/osc/commandline.py b/osc/commandline.py index e7604faf..b47f61d9 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -4135,7 +4135,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. if not pac.todo: pac.todo = pac.filenamelist + pac.filenamelist_unvers pac.todo.sort() - for prj_path, packages in prj_paths.iteritems(): + for prj_path, packages in prj_paths.items(): prj = Project(prj_path) if not msg: msg = get_commit_msg(prj.absdir, pac_objs[prj_path]) @@ -6490,7 +6490,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. if role_filter: role_filter = '%s (%s)' % (search_term, role_filter) kind_map = {'published/binary/id': 'binary'} - for kind, root in res.iteritems(): + for kind, root in res.items(): results = [] for node in root.findall(kind_map.get(kind, kind)): result = [] @@ -7791,7 +7791,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. args = parseargs(args) pacs = [] - apiurls = conf.config['api_host_options'].keys() + apiurls = list(conf.config['api_host_options'].keys()) apiurl = '' for i in args: if is_project_dir(i): diff --git a/osc/core.py b/osc/core.py index 646ab17d..2ce805ec 100644 --- a/osc/core.py +++ b/osc/core.py @@ -1234,9 +1234,7 @@ class Package: def __generate_commitlist(self, todo_send): root = ET.Element('directory') - keys = todo_send.keys() - keys.sort() - for i in keys: + for i in sorted(todo_send.keys()): ET.SubElement(root, 'entry', name=i, md5=todo_send[i]) return root @@ -2302,10 +2300,7 @@ class Action: raise oscerr.WrongArgs('invalid argument: \'%s\'' % i) # set all type specific attributes for i in Action.type_args[type]: - if kwargs.has_key(i): - setattr(self, i, kwargs[i]) - else: - setattr(self, i, None) + setattr(self, i, kwargs.get(i)) def to_xml(self): """ @@ -3721,7 +3716,7 @@ def get_review_list(apiurl, project='', package='', byuser='', bygroup='', bypro todo['project'] = project if package: todo['package'] = package - for kind, val in todo.iteritems(): + for kind, val in todo.items(): xpath_base = 'action/target/@%(kind)s=\'%(val)s\' or ' \ 'submit/target/@%(kind)s=\'%(val)s\'' @@ -3787,7 +3782,7 @@ def get_request_list(apiurl, project='', package='', req_who='', req_state=('new todo['project'] = project if package: todo['package'] = package - for kind, val in todo.iteritems(): + for kind, val in todo.items(): xpath_base = 'action/target/@%(kind)s=\'%(val)s\' or ' \ 'submit/target/@%(kind)s=\'%(val)s\'' @@ -3827,7 +3822,7 @@ def get_user_projpkgs_request_list(apiurl, user, req_state=('new','review',), re if not i.get('project') in projects: projpkgs.setdefault(i.get('project'), []).append(i.get('name')) xpath = '' - for prj, pacs in projpkgs.iteritems(): + for prj, pacs in projpkgs.items(): if not len(pacs): xpath = xpath_join(xpath, 'action/target/@project=\'%s\'' % prj, inner=True) else: @@ -4493,7 +4488,7 @@ def aggregate_pac(src_project, src_package, dst_project, dst_package, repo_map = aggregate_template += """\ """ - for src, tgt in repo_map.iteritems(): + for src, tgt in repo_map.items(): aggregate_template += """\ """ % (tgt, src) @@ -5758,7 +5753,7 @@ def search(apiurl, **kwargs): GET /search/kindN?match=xpathN """ res = {} - for urlpath, xpath in kwargs.iteritems(): + for urlpath, xpath in kwargs.items(): path = [ 'search' ] path += urlpath.split('_') # FIXME: take underscores as path seperators. I see no other way atm to fix OBS api calls and not breaking osc api u = makeurl(apiurl, path, ['match=%s' % quote_plus(xpath)]) @@ -6591,7 +6586,7 @@ def filter_role(meta, user, role): remove all project/package nodes if no person node exists where @userid=user and @role=role """ - for kind, root in meta.iteritems(): + for kind, root in meta.items(): delete = [] for node in root.findall(kind): found = False diff --git a/osc/fetch.py b/osc/fetch.py index 0ae74725..2ef73f05 100644 --- a/osc/fetch.py +++ b/osc/fetch.py @@ -122,7 +122,7 @@ class Fetcher: archive.copyin_file(hdr.filename, os.path.dirname(tmpfile), os.path.basename(tmpfile)) self.move_package(tmpfile, pac.localdir, pac) # check if we got all packages... (because we've no .errors file) - for pac in pkgs.itervalues(): + for pac in pkgs.values(): if not os.path.isfile(pac.fullfilename): raise oscerr.APIError('failed to fetch file \'%s\': ' \ 'does not exist in CPIO archive' % pac.repofilename) @@ -130,7 +130,7 @@ class Fetcher: if e.errno != 14 or e.code != 414: raise # query str was too large - keys = pkgs.keys() + keys = list(pkgs.keys()) if len(keys) == 1: raise oscerr.APIError('unable to fetch cpio archive: server always returns code 414') n = len(pkgs) / 2 @@ -145,7 +145,7 @@ class Fetcher: os.unlink(tmpfile) def __fetch_cpio(self, apiurl): - for prpap, pkgs in self.cpio.iteritems(): + for prpap, pkgs in self.cpio.items(): project, repo, arch, package = prpap.split('/', 3) self.__download_cpio_archive(apiurl, project, repo, arch, package, **pkgs) @@ -246,7 +246,7 @@ class Fetcher: self.__fetch_cpio(buildinfo.apiurl) - prjs = buildinfo.projects.keys() + prjs = list(buildinfo.projects.keys()) for i in prjs: dest = "%s/%s" % (self.cachedir, i) if not os.path.exists(dest): diff --git a/osc/util/cpio.py b/osc/util/cpio.py index ee8582f9..a891defe 100644 --- a/osc/util/cpio.py +++ b/osc/util/cpio.py @@ -62,7 +62,7 @@ class CpioHdr: self.namesize = namesize # != 0 indicates CRC format (which we do not support atm) self.checksum = checksum - for k,v in self.__dict__.iteritems(): + for k,v in self.__dict__.items(): self.__dict__[k] = int(v, 16) self.filename = filename # data starts at dataoff and ends at dataoff+filesize