Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/boto/s3/tagging.py

Issue 12633019: Added boto/ to depot_tools/third_party (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Moved boto down by one Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/boto/s3/resumable_download_handler.py ('k') | third_party/boto/s3/user.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 from boto import handler
2 import xml.sax
3
4
5 class Tag(object):
6 def __init__(self, key=None, value=None):
7 self.key = key
8 self.value = value
9
10 def startElement(self, name, attrs, connection):
11 return None
12
13 def endElement(self, name, value, connection):
14 if name == 'Key':
15 self.key = value
16 elif name == 'Value':
17 self.value = value
18
19 def to_xml(self):
20 return '<Tag><Key>%s</Key><Value>%s</Value></Tag>' % (
21 self.key, self.value)
22
23 def __eq__(self, other):
24 return (self.key == other.key and self.value == other.value)
25
26
27 class TagSet(list):
28 def startElement(self, name, attrs, connection):
29 if name == 'Tag':
30 tag = Tag()
31 self.append(tag)
32 return tag
33 return None
34
35 def endElement(self, name, value, connection):
36 setattr(self, name, value)
37
38 def add_tag(self, key, value):
39 tag = Tag(key, value)
40 self.append(tag)
41
42 def to_xml(self):
43 xml = '<TagSet>'
44 for tag in self:
45 xml += tag.to_xml()
46 xml += '</TagSet>'
47 return xml
48
49
50 class Tags(list):
51 """A container for the tags associated with a bucket."""
52
53 def startElement(self, name, attrs, connection):
54 if name == 'TagSet':
55 tag_set = TagSet()
56 self.append(tag_set)
57 return tag_set
58 return None
59
60 def endElement(self, name, value, connection):
61 setattr(self, name, value)
62
63 def to_xml(self):
64 xml = '<Tagging>'
65 for tag_set in self:
66 xml += tag_set.to_xml()
67 xml +='</Tagging>'
68 return xml
69
70 def add_tag_set(self, tag_set):
71 self.append(tag_set)
OLDNEW
« no previous file with comments | « third_party/boto/s3/resumable_download_handler.py ('k') | third_party/boto/s3/user.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698