From 4e88d79da2a8300c4b4ba423cc3e3af425f6c05f Mon Sep 17 00:00:00 2001 From: Hugo Lopes Tavares Date: Tue, 28 Jan 2014 18:53:12 -0500 Subject: [PATCH] Refactor AmiBackend.describe_images: make logic of missing image simpler --- moto/ec2/models.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 497e57b31..e0907978f 100644 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -219,14 +219,14 @@ class AmiBackend(object): self.amis[ami_id] = ami return ami - def describe_images(self, ami_ids=None): - if ami_ids: - images = [image for image in self.amis.values() if image.id in ami_ids] - for missing_ami in set(ami_ids) - set(ami.id for ami in images): - raise InvalidIdError(missing_ami) - else: - images = self.amis.values() - return images + def describe_images(self, ami_ids=()): + images = [] + for ami_id in ami_ids: + if ami_id in self.amis: + images.append(self.amis[ami_id]) + else: + raise InvalidIdError(ami_id) + return images or self.amis.values() def deregister_image(self, ami_id): if ami_id in self.amis: