Put dict to use
authorHugh Brown <hbrown@amplify.com>
Thu, 10 Oct 2013 22:26:55 +0000 (18:26 -0400)
committerHugh Brown <hbrown@amplify.com>
Thu, 10 Oct 2013 23:29:03 +0000 (19:29 -0400)
jenkinsapi/queue.py

index 5c5b506..b14ec51 100644 (file)
@@ -43,10 +43,11 @@ class Queue(JenkinsBase):
         return len(self._data['items'])
 
     def __getitem__(self, item_id):
-        for id, item in self.iteritems():
-            if id == item_id:
-                return item
-        raise UnknownQueueItem(item_id)
+        self_as_dict = dict(self.iteritems())
+        if item_id in self_as_dict:
+            return self_as_dict[item_id]
+        else:
+            raise UnknownQueueItem(item_id)
 
     def get_queue_items_for_job(self, job_name):
         if not job_name: