Browse code

- Added headers with copyright to all files - Removed S3.compose_uri(), introduced S3UriS3.compose_uri() instead.

git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3py/trunk@63 830e0280-6d2a-0410-9c65-932aecc39d9d

Michal Ludvig authored on 2007/01/26 08:33:35
Showing 7 changed files
... ...
@@ -1,4 +1,9 @@
1
-class BidirMap:
1
+## Amazon S3 manager
2
+## Author: Michal Ludvig <michal@logix.cz>
3
+##         http://www.logix.cz/michal
4
+## License: GPL Version 2
5
+
6
+class BidirMap(object):
2 7
 	def __init__(self, **map):
3 8
 		self.k2v = {}
4 9
 		self.v2k = {}
... ...
@@ -1,3 +1,8 @@
1
+## Amazon S3 manager
2
+## Author: Michal Ludvig <michal@logix.cz>
3
+##         http://www.logix.cz/michal
4
+## License: GPL Version 2
5
+
1 6
 import logging
2 7
 from logging import debug, info, warning, error
3 8
 import re
... ...
@@ -1,3 +1,8 @@
1
+## Amazon S3 manager
2
+## Author: Michal Ludvig <michal@logix.cz>
3
+##         http://www.logix.cz/michal
4
+## License: GPL Version 2
5
+
1 6
 import os, os.path
2 7
 import base64
3 8
 import hmac
... ...
@@ -75,6 +80,7 @@ class S3(object):
75 75
 	def __init__(self, config):
76 76
 		self.config = config
77 77
 
78
+	## Commands / Actions
78 79
 	def list_all_buckets(self):
79 80
 		request = self.create_request("LIST_ALL_BUCKETS")
80 81
 		response = self.send_request(request)
... ...
@@ -147,6 +153,7 @@ class S3(object):
147 147
 			raise ValueError("Expected URI type 's3', got '%s'" % uri.type)
148 148
 		return self.object_delete(filename, uri.bucket(), uri.object())
149 149
 
150
+	## Low level methods
150 151
 	def create_request(self, operation, bucket = None, object = None, headers = None, **params):
151 152
 		resource = "/"
152 153
 		if bucket:
... ...
@@ -286,12 +293,3 @@ class S3(object):
286 286
 			raise ParameterError("Bucket name '%s' is too long (max 255 characters)" % bucket)
287 287
 		return True
288 288
 
289
-	def compose_uri(self, bucket, object = None, force_uri = False):
290
-		if self.config.show_uri or force_uri:
291
-			uri = "s3://" + bucket
292
-			if object:
293
-				uri += "/"+object
294
-			return uri
295
-		else:
296
-			return object and object or bucket
297
-
... ...
@@ -1,3 +1,8 @@
1
+## Amazon S3 manager
2
+## Author: Michal Ludvig <michal@logix.cz>
3
+##         http://www.logix.cz/michal
4
+## License: GPL Version 2
5
+
1 6
 import re
2 7
 import sys
3 8
 from BidirMap import BidirMap
... ...
@@ -53,6 +58,10 @@ class S3UriS3(S3Uri):
53 53
 
54 54
 	def uri(self):
55 55
 		return "/".join(["s3:/", self._bucket, self._object])
56
+	
57
+	@staticmethod
58
+	def compose_uri(bucket, object = ""):
59
+		return "S3://%s/%s" % (bucket, object)
56 60
 
57 61
 class S3UriS3FS(S3Uri):
58 62
 	type = "s3fs"
... ...
@@ -1,4 +1,9 @@
1
-class SortedDictIterator:
1
+## Amazon S3 manager
2
+## Author: Michal Ludvig <michal@logix.cz>
3
+##         http://www.logix.cz/michal
4
+## License: GPL Version 2
5
+
6
+class SortedDictIterator(object):
2 7
 	def __init__(self, dict):
3 8
 		self.dict = dict
4 9
 		self.keys = dict.keys()
... ...
@@ -1,3 +1,8 @@
1
+## Amazon S3 manager
2
+## Author: Michal Ludvig <michal@logix.cz>
3
+##         http://www.logix.cz/michal
4
+## License: GPL Version 2
5
+
1 6
 import time
2 7
 import re
3 8
 import elementtree.ElementTree as ET
... ...
@@ -17,7 +17,7 @@ import elementtree.ElementTree as ET
17 17
 ## Our modules
18 18
 from S3.S3 import *
19 19
 from S3.Config import Config
20
-from S3.S3Uri import S3Uri
20
+from S3.S3Uri import *
21 21
 
22 22
 def output(message):
23 23
 	print message
... ...
@@ -69,7 +69,7 @@ def subcmd_bucket_list(s3, uri):
69 69
 		output("%s  %s%s  %s" % (
70 70
 			formatDateTime(object["LastModified"]),
71 71
 			str(size).rjust(8), size_coeff.ljust(1),
72
-			s3.compose_uri(bucket, object["Key"]),
72
+			uri.compose_uri(bucket, object["Key"]),
73 73
 			))
74 74
 
75 75
 def cmd_bucket_create(args):