comparison env/lib/python3.9/site-packages/boto/ec2/tag.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 # Copyright (c) 2010 Mitch Garnaat http://garnaat.org/
2 # Copyright (c) 2010, Eucalyptus Systems, Inc.
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish, dis-
8 # tribute, sublicense, and/or sell copies of the Software, and to permit
9 # persons to whom the Software is furnished to do so, subject to the fol-
10 # lowing conditions:
11 #
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 # IN THE SOFTWARE.
22
23
24 class TagSet(dict):
25 """
26 A TagSet is used to collect the tags associated with a particular
27 EC2 resource. Not all resources can be tagged but for those that
28 can, this dict object will be used to collect those values. See
29 :class:`boto.ec2.ec2object.TaggedEC2Object` for more details.
30 """
31
32 def __init__(self, connection=None):
33 self.connection = connection
34 self._current_key = None
35 self._current_value = None
36
37 def startElement(self, name, attrs, connection):
38 if name == 'item':
39 self._current_key = None
40 self._current_value = None
41 return None
42
43 def endElement(self, name, value, connection):
44 if name == 'key':
45 self._current_key = value
46 elif name == 'value':
47 self._current_value = value
48 elif name == 'item':
49 self[self._current_key] = self._current_value
50
51
52 class Tag(object):
53 """
54 A Tag is used when creating or listing all tags related to
55 an AWS account. It records not only the key and value but
56 also the ID of the resource to which the tag is attached
57 as well as the type of the resource.
58 """
59
60 def __init__(self, connection=None, res_id=None, res_type=None,
61 name=None, value=None):
62 self.connection = connection
63 self.res_id = res_id
64 self.res_type = res_type
65 self.name = name
66 self.value = value
67
68 def __repr__(self):
69 return 'Tag:%s' % self.name
70
71 def startElement(self, name, attrs, connection):
72 return None
73
74 def endElement(self, name, value, connection):
75 if name == 'resourceId':
76 self.res_id = value
77 elif name == 'resourceType':
78 self.res_type = value
79 elif name == 'key':
80 self.name = value
81 elif name == 'value':
82 self.value = value
83 else:
84 setattr(self, name, value)