From ab34b69ee20b3fd8b319d849bbe6b2f8fa2d7cd0 Mon Sep 17 00:00:00 2001 From: Hugh Brown Date: Thu, 10 Oct 2013 16:04:13 -0400 Subject: [PATCH] Remove use of has_key --- jenkinsapi/job.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jenkinsapi/job.py b/jenkinsapi/job.py index 71a896a..0a7ccc2 100644 --- a/jenkinsapi/job.py +++ b/jenkinsapi/job.py @@ -67,7 +67,7 @@ class Job(JenkinsBase, MutableJenkinsThing): Jenkins API loads the first 100 builds and thus may not contain all builds information. This method checks if all builds are loaded in the data object and updates it with the missing builds if needed.''' - if not data.has_key("builds") or not data["builds"]: + if not data.get("builds"): return data # do not call _buildid_for_type here: it would poll and do an infinite loop oldest_loaded_build_number = data["builds"][-1]["number"] @@ -219,12 +219,15 @@ class Job(JenkinsBase, MutableJenkinsThing): return self._buildid_for_type("lastCompletedBuild") def get_build_dict(self): - if not self._data.has_key("builds"): + if "builds" not in self._data: raise NoBuildData(repr(self)) builds = self._data["builds"] last_build = self._data['lastBuild'] if builds and last_build and builds[0]['number'] != last_build['number']: builds = [last_build] + builds + # FIXME SO how is this supposed to work if build is false-y? + # I don't think that builds *can* be false here, so I don't + # understand the test above. return dict((build["number"], build["url"]) for build in builds) -- 2.7.4