Browse code

* S3/S3Uri.py: Added some convenience methods to S3UriS3()

git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/branches/s3cmd-airlock@341 830e0280-6d2a-0410-9c65-932aecc39d9d

Michal Ludvig authored on 2009/01/16 21:54:56
Showing 2 changed files
... ...
@@ -1,6 +1,7 @@
1 1
 2009-01-17  Michal Ludvig  <michal@logix.cz>
2 2
 
3 3
 	* S3/Utils.py: Added getDictFromTree() and appendXmlTextNode()
4
+	* S3/S3Uri.py: Added some convenience methods to S3UriS3() 
4 5
 
5 6
 2009-01-16  Michal Ludvig  <michal@logix.cz>
6 7
 
... ...
@@ -71,12 +71,21 @@ class S3UriS3(S3Uri):
71 71
 	def uri(self):
72 72
 		return "/".join(["s3:/", self._bucket, self._object])
73 73
 	
74
+	def is_dns_compatible(self):
75
+		return S3.check_bucket_name_dns_conformity(self._bucket)
76
+
74 77
 	def public_url(self):
75
-		if S3.check_bucket_name_dns_conformity(self._bucket):
78
+		if self.is_dns_compatible():
76 79
 			return "http://%s.s3.amazonaws.com/%s" % (self._bucket, self._object)
77 80
 		else:
78 81
 			return "http://s3.amazonaws.com/%s/%s" % (self._bucket, self._object)
79 82
 
83
+	def host_name(self):
84
+		if self.is_dns_compatible():
85
+			return "%s.s3.amazonaws.com" % (self._bucket)
86
+		else:
87
+			return "s3.amazonaws.com"
88
+
80 89
 	@staticmethod
81 90
 	def compose_uri(bucket, object = ""):
82 91
 		return "s3://%s/%s" % (bucket, object)