diff options
author | Vincent Wong <duperduper@ucla.edu> | 2014-09-13 12:23:08 -0700 |
---|---|---|
committer | Vincent Wong <duperduper@ucla.edu> | 2014-09-13 12:34:20 -0700 |
commit | 74b37400324ad31039f38618d05b9fdaf05815d4 (patch) | |
tree | 3eee6abd20f782211d0e9b94e41bbcdd71c2cd66 | |
parent | ab464f99456d12a9dcc18a216849a89ffd7ede5e (diff) | |
download | boto-74b37400324ad31039f38618d05b9fdaf05815d4.tar.gz |
Removed duplicate code in add_tag and remove_tag
Since add_tags is a more general version of add_tag that uses the same API
call, add_tag can simply call add_tags with the correct parameters. Likewise
for remove_tag and remove_tags.
For remove_tag in particular, these lines were redundant:
if value is not None:
tags = {key : value}
else:
tags = [key]
Since EC2Connection.delete_tags just converts the list back to a dict of {key:
None} anyway, these extra checks serve no purpose.
-rw-r--r-- | boto/ec2/ec2object.py | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/boto/ec2/ec2object.py b/boto/ec2/ec2object.py index 7cc7e424..8bc428db 100644 --- a/boto/ec2/ec2object.py +++ b/boto/ec2/ec2object.py @@ -77,14 +77,7 @@ class TaggedEC2Object(EC2Object): If you want only the tag name and no value, the value should be the empty string. """ - status = self.connection.create_tags( - [self.id], - {key: value}, - dry_run=dry_run - ) - if self.tags is None: - self.tags = TagSet() - self.tags[key] = value + self.add_tags({key: value}, dry_run) def add_tags(self, tags, dry_run=False): """ @@ -124,17 +117,7 @@ class TaggedEC2Object(EC2Object): NOTE: There is an important distinction between a value of '' and a value of None. """ - if value is not None: - tags = {key: value} - else: - tags = [key] - status = self.connection.delete_tags( - [self.id], - tags, - dry_run=dry_run - ) - if key in self.tags: - del self.tags[key] + self.remove_tags({key: value}, dry_run) def remove_tags(self, tags, dry_run=False): """ |