From: Hugh Brown Date: Thu, 10 Oct 2013 22:07:54 +0000 (-0400) Subject: Fix pylint errors relating to collection implementation X-Git-Tag: v0.2.23~92^2~38 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=54d1a70ec83d10720fa29c1746eabdb8fe325bc6;p=tools%2Fpython-jenkinsapi.git Fix pylint errors relating to collection implementation --- diff --git a/jenkinsapi/jenkins.py b/jenkinsapi/jenkins.py index 9b61d85..499e66f 100644 --- a/jenkinsapi/jenkins.py +++ b/jenkinsapi/jenkins.py @@ -232,6 +232,9 @@ class Jenkins(JenkinsBase): return Job(info["url"], info["name"], jenkins_obj=self) raise UnknownJob(jobname) + def __len__(self): + return len(self._data["jobs"]) + def __contains__(self, jobname): """ Does a job by the name specified exist diff --git a/jenkinsapi/job.py b/jenkinsapi/job.py index de3494c..d4e7243 100644 --- a/jenkinsapi/job.py +++ b/jenkinsapi/job.py @@ -316,6 +316,9 @@ class Job(JenkinsBase, MutableJenkinsThing): def __getitem__(self, buildnumber): return self.get_build(buildnumber) + def __len__(self): + return len(self.get_build_dict()) + def is_queued_or_running(self): return self.is_queued() or self.is_running() diff --git a/jenkinsapi/nodes.py b/jenkinsapi/nodes.py index 56a5068..81e8379 100644 --- a/jenkinsapi/nodes.py +++ b/jenkinsapi/nodes.py @@ -56,3 +56,6 @@ class Nodes(JenkinsBase): if k == nodename: return v raise UnknownNode(nodename) + + def __len__(self): + return len(self.iteritems()) diff --git a/jenkinsapi/result_set.py b/jenkinsapi/result_set.py index 88fd1e9..52b5b35 100644 --- a/jenkinsapi/result_set.py +++ b/jenkinsapi/result_set.py @@ -49,3 +49,7 @@ class ResultSet(JenkinsBase): def __len__(self): return len(self.items()) + + def __getitem__(self, key): + d = dict(self.iteritems()) + return d[key]