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

Unified Diff: third_party/boto/boto/s3/tagging.py

Issue 12755026: Added gsutil/boto to depot_tools/third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Added readme 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/boto/boto/s3/resumable_download_handler.py ('k') | third_party/boto/boto/s3/user.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/boto/boto/s3/tagging.py
diff --git a/third_party/boto/boto/s3/tagging.py b/third_party/boto/boto/s3/tagging.py
new file mode 100644
index 0000000000000000000000000000000000000000..0af6406fb12c6cd316cdd41e759fb0398abba632
--- /dev/null
+++ b/third_party/boto/boto/s3/tagging.py
@@ -0,0 +1,71 @@
+from boto import handler
+import xml.sax
+
+
+class Tag(object):
+ def __init__(self, key=None, value=None):
+ self.key = key
+ self.value = value
+
+ def startElement(self, name, attrs, connection):
+ return None
+
+ def endElement(self, name, value, connection):
+ if name == 'Key':
+ self.key = value
+ elif name == 'Value':
+ self.value = value
+
+ def to_xml(self):
+ return '<Tag><Key>%s</Key><Value>%s</Value></Tag>' % (
+ self.key, self.value)
+
+ def __eq__(self, other):
+ return (self.key == other.key and self.value == other.value)
+
+
+class TagSet(list):
+ def startElement(self, name, attrs, connection):
+ if name == 'Tag':
+ tag = Tag()
+ self.append(tag)
+ return tag
+ return None
+
+ def endElement(self, name, value, connection):
+ setattr(self, name, value)
+
+ def add_tag(self, key, value):
+ tag = Tag(key, value)
+ self.append(tag)
+
+ def to_xml(self):
+ xml = '<TagSet>'
+ for tag in self:
+ xml += tag.to_xml()
+ xml += '</TagSet>'
+ return xml
+
+
+class Tags(list):
+ """A container for the tags associated with a bucket."""
+
+ def startElement(self, name, attrs, connection):
+ if name == 'TagSet':
+ tag_set = TagSet()
+ self.append(tag_set)
+ return tag_set
+ return None
+
+ def endElement(self, name, value, connection):
+ setattr(self, name, value)
+
+ def to_xml(self):
+ xml = '<Tagging>'
+ for tag_set in self:
+ xml += tag_set.to_xml()
+ xml +='</Tagging>'
+ return xml
+
+ def add_tag_set(self, tag_set):
+ self.append(tag_set)
« no previous file with comments | « third_party/boto/boto/s3/resumable_download_handler.py ('k') | third_party/boto/boto/s3/user.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698