Permalink
Browse files

ATTENTION -- Mega WhiteSpace conversion !!!

Historically s3cmd and modules used to use <tab> for indentation.
This is not a recommended Python coding standard and many tools
treat it as an error.

This mega patch converts all <tab>s to <4-space>s and also removes
trailing white whitespace along the way.

To get meaningful diffs across this commit use: git diff -w
  • Loading branch information...
1 parent 46d61bb commit d439efb41c4372a786204195d8253c7a1b683c01 @mludvig mludvig committed Jun 7, 2011
Showing with 5,080 additions and 5,050 deletions.
  1. +199 −197 S3/ACL.py
  2. +68 −66 S3/AccessLog.py
  3. +36 −34 S3/BidirMap.py
  4. +692 −690 S3/CloudFront.py
  5. +181 −181 S3/Config.py
  6. +57 −55 S3/Exceptions.py
  7. +277 −277 S3/FileLists.py
  8. +2 −1 S3/PkgInfo.py
  9. +140 −138 S3/Progress.py
  10. +794 −792 S3/S3.py
  11. +188 −187 S3/S3Uri.py
  12. +153 −151 S3/SimpleDB.py
  13. +50 −48 S3/SortedDict.py
  14. +258 −256 S3/Utils.py
  15. +265 −263 run-tests.py
  16. +1,647 −1,645 s3cmd
  17. +24 −22 s3db
  18. +49 −47 setup.py
View
View
@@ -9,82 +9,84 @@
from ACL import GranteeAnonRead
try:
- import xml.etree.ElementTree as ET
+ import xml.etree.ElementTree as ET
except ImportError:
- import elementtree.ElementTree as ET
+ import elementtree.ElementTree as ET
__all__ = []
class AccessLog(object):
- LOG_DISABLED = "<BucketLoggingStatus></BucketLoggingStatus>"
- LOG_TEMPLATE = "<LoggingEnabled><TargetBucket></TargetBucket><TargetPrefix></TargetPrefix></LoggingEnabled>"
+ LOG_DISABLED = "<BucketLoggingStatus></BucketLoggingStatus>"
+ LOG_TEMPLATE = "<LoggingEnabled><TargetBucket></TargetBucket><TargetPrefix></TargetPrefix></LoggingEnabled>"
- def __init__(self, xml = None):
- if not xml:
- xml = self.LOG_DISABLED
- self.tree = getTreeFromXml(xml)
- self.tree.attrib['xmlns'] = "http://doc.s3.amazonaws.com/2006-03-01"
-
- def isLoggingEnabled(self):
- return bool(self.tree.find(".//LoggingEnabled"))
+ def __init__(self, xml = None):
+ if not xml:
+ xml = self.LOG_DISABLED
+ self.tree = getTreeFromXml(xml)
+ self.tree.attrib['xmlns'] = "http://doc.s3.amazonaws.com/2006-03-01"
- def disableLogging(self):
- el = self.tree.find(".//LoggingEnabled")
- if el:
- self.tree.remove(el)
-
- def enableLogging(self, target_prefix_uri):
- el = self.tree.find(".//LoggingEnabled")
- if not el:
- el = getTreeFromXml(self.LOG_TEMPLATE)
- self.tree.append(el)
- el.find(".//TargetBucket").text = target_prefix_uri.bucket()
- el.find(".//TargetPrefix").text = target_prefix_uri.object()
+ def isLoggingEnabled(self):
+ return bool(self.tree.find(".//LoggingEnabled"))
- def targetPrefix(self):
- if self.isLoggingEnabled():
- el = self.tree.find(".//LoggingEnabled")
- target_prefix = "s3://%s/%s" % (
- self.tree.find(".//LoggingEnabled//TargetBucket").text,
- self.tree.find(".//LoggingEnabled//TargetPrefix").text)
- return S3Uri.S3Uri(target_prefix)
- else:
- return ""
+ def disableLogging(self):
+ el = self.tree.find(".//LoggingEnabled")
+ if el:
+ self.tree.remove(el)
- def setAclPublic(self, acl_public):
- le = self.tree.find(".//LoggingEnabled")
- if not le:
- raise ParameterError("Logging not enabled, can't set default ACL for logs")
- tg = le.find(".//TargetGrants")
- if not acl_public:
- if not tg:
- ## All good, it's not been there
- return
- else:
- le.remove(tg)
- else: # acl_public == True
- anon_read = GranteeAnonRead().getElement()
- if not tg:
- tg = ET.SubElement(le, "TargetGrants")
- ## What if TargetGrants already exists? We should check if
- ## AnonRead is there before appending a new one. Later...
- tg.append(anon_read)
+ def enableLogging(self, target_prefix_uri):
+ el = self.tree.find(".//LoggingEnabled")
+ if not el:
+ el = getTreeFromXml(self.LOG_TEMPLATE)
+ self.tree.append(el)
+ el.find(".//TargetBucket").text = target_prefix_uri.bucket()
+ el.find(".//TargetPrefix").text = target_prefix_uri.object()
- def isAclPublic(self):
- raise NotImplementedError()
+ def targetPrefix(self):
+ if self.isLoggingEnabled():
+ el = self.tree.find(".//LoggingEnabled")
+ target_prefix = "s3://%s/%s" % (
+ self.tree.find(".//LoggingEnabled//TargetBucket").text,
+ self.tree.find(".//LoggingEnabled//TargetPrefix").text)
+ return S3Uri.S3Uri(target_prefix)
+ else:
+ return ""
- def __str__(self):
- return ET.tostring(self.tree)
+ def setAclPublic(self, acl_public):
+ le = self.tree.find(".//LoggingEnabled")
+ if not le:
+ raise ParameterError("Logging not enabled, can't set default ACL for logs")
+ tg = le.find(".//TargetGrants")
+ if not acl_public:
+ if not tg:
+ ## All good, it's not been there
+ return
+ else:
+ le.remove(tg)
+ else: # acl_public == True
+ anon_read = GranteeAnonRead().getElement()
+ if not tg:
+ tg = ET.SubElement(le, "TargetGrants")
+ ## What if TargetGrants already exists? We should check if
+ ## AnonRead is there before appending a new one. Later...
+ tg.append(anon_read)
+
+ def isAclPublic(self):
+ raise NotImplementedError()
+
+ def __str__(self):
+ return ET.tostring(self.tree)
__all__.append("AccessLog")
if __name__ == "__main__":
- from S3Uri import S3Uri
- log = AccessLog()
- print log
- log.enableLogging(S3Uri("s3://targetbucket/prefix/log-"))
- print log
- log.setAclPublic(True)
- print log
- log.setAclPublic(False)
- print log
- log.disableLogging()
- print log
+ from S3Uri import S3Uri
+ log = AccessLog()
+ print log
+ log.enableLogging(S3Uri("s3://targetbucket/prefix/log-"))
+ print log
+ log.setAclPublic(True)
+ print log
+ log.setAclPublic(False)
+ print log
+ log.disableLogging()
+ print log
+
+# vim:et:ts=4:sts=4:ai
View
@@ -4,37 +4,39 @@
## License: GPL Version 2
class BidirMap(object):
- def __init__(self, **map):
- self.k2v = {}
- self.v2k = {}
- for key in map:
- self.__setitem__(key, map[key])
-
- def __setitem__(self, key, value):
- if self.v2k.has_key(value):
- if self.v2k[value] != key:
- raise KeyError("Value '"+str(value)+"' already in use with key '"+str(self.v2k[value])+"'")
- try:
- del(self.v2k[self.k2v[key]])
- except KeyError:
- pass
- self.k2v[key] = value
- self.v2k[value] = key
-
- def __getitem__(self, key):
- return self.k2v[key]
-
- def __str__(self):
- return self.v2k.__str__()
-
- def getkey(self, value):
- return self.v2k[value]
-
- def getvalue(self, key):
- return self.k2v[key]
-
- def keys(self):
- return [key for key in self.k2v]
-
- def values(self):
- return [value for value in self.v2k]
+ def __init__(self, **map):
+ self.k2v = {}
+ self.v2k = {}
+ for key in map:
+ self.__setitem__(key, map[key])
+
+ def __setitem__(self, key, value):
+ if self.v2k.has_key(value):
+ if self.v2k[value] != key:
+ raise KeyError("Value '"+str(value)+"' already in use with key '"+str(self.v2k[value])+"'")
+ try:
+ del(self.v2k[self.k2v[key]])
+ except KeyError:
+ pass
+ self.k2v[key] = value
+ self.v2k[value] = key
+
+ def __getitem__(self, key):
+ return self.k2v[key]
+
+ def __str__(self):
+ return self.v2k.__str__()
+
+ def getkey(self, value):
+ return self.v2k[value]
+
+ def getvalue(self, key):
+ return self.k2v[key]
+
+ def keys(self):
+ return [key for key in self.k2v]
+
+ def values(self):
+ return [value for value in self.v2k]
+
+# vim:et:ts=4:sts=4:ai
Oops, something went wrong. Retry.

0 comments on commit d439efb

Please sign in to comment.