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

Side by Side Diff: boto/file/bucket.py

Issue 8386013: Merging in latest boto. (Closed) Base URL: svn://svn.chromium.org/boto
Patch Set: Redoing vendor drop by deleting and then merging. Created 9 years, 1 month 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 | « boto/exception.py ('k') | boto/file/key.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2010 Google Inc. 1 # Copyright 2010 Google Inc.
2 # Copyright (c) 2011, Nexenta Systems Inc.
2 # 3 #
3 # Permission is hereby granted, free of charge, to any person obtaining a 4 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the 5 # copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including 6 # "Software"), to deal in the Software without restriction, including
6 # without limitation the rights to use, copy, modify, merge, publish, dis- 7 # without limitation the rights to use, copy, modify, merge, publish, dis-
7 # tribute, sublicense, and/or sell copies of the Software, and to permit 8 # tribute, sublicense, and/or sell copies of the Software, and to permit
8 # persons to whom the Software is furnished to do so, subject to the fol- 9 # persons to whom the Software is furnished to do so, subject to the fol-
9 # lowing conditions: 10 # lowing conditions:
10 # 11 #
11 # The above copyright notice and this permission notice shall be included 12 # The above copyright notice and this permission notice shall be included
(...skipping 30 matching lines...) Expand all
42 def delete_key(self, key_name, headers=None, 43 def delete_key(self, key_name, headers=None,
43 version_id=None, mfa_token=None): 44 version_id=None, mfa_token=None):
44 """ 45 """
45 Deletes a key from the bucket. 46 Deletes a key from the bucket.
46 47
47 :type key_name: string 48 :type key_name: string
48 :param key_name: The key name to delete 49 :param key_name: The key name to delete
49 50
50 :type version_id: string 51 :type version_id: string
51 :param version_id: Unused in this subclass. 52 :param version_id: Unused in this subclass.
52 53
53 :type mfa_token: tuple or list of strings 54 :type mfa_token: tuple or list of strings
54 :param mfa_token: Unused in this subclass. 55 :param mfa_token: Unused in this subclass.
55 """ 56 """
56 os.remove(key_name) 57 os.remove(key_name)
57 58
58 def get_all_keys(self, headers=None, **params): 59 def get_all_keys(self, headers=None, **params):
59 """ 60 """
60 This method returns the single key around which this anonymous Bucket 61 This method returns the single key around which this anonymous Bucket
61 was instantiated. 62 was instantiated.
62 63
63 :rtype: SimpleResultSet 64 :rtype: SimpleResultSet
64 :return: The result from file system listing the keys requested 65 :return: The result from file system listing the keys requested
65 66
66 """ 67 """
67 key = Key(self.name, self.contained_key) 68 key = Key(self.name, self.contained_key)
68 return SimpleResultSet([key]) 69 return SimpleResultSet([key])
69 70
70 def get_key(self, key_name, headers=None, version_id=None): 71 def get_key(self, key_name, headers=None, version_id=None,
72 key_type=Key.KEY_REGULAR_FILE):
71 """ 73 """
72 Check to see if a particular key exists within the bucket. 74 Check to see if a particular key exists within the bucket.
73 Returns: An instance of a Key object or None 75 Returns: An instance of a Key object or None
74 76
75 :type key_name: string 77 :type key_name: string
76 :param key_name: The name of the key to retrieve 78 :param key_name: The name of the key to retrieve
77 79
78 :type version_id: string 80 :type version_id: string
79 :param version_id: Unused in this subclass. 81 :param version_id: Unused in this subclass.
80 82
83 :type stream_type: integer
84 :param stream_type: Type of the Key - Regular File or input/output Strea m
85
81 :rtype: :class:`boto.file.key.Key` 86 :rtype: :class:`boto.file.key.Key`
82 :returns: A Key object from this bucket. 87 :returns: A Key object from this bucket.
83 """ 88 """
84 fp = open(key_name, 'rb') 89 if key_name == '-':
85 return Key(self.name, key_name, fp) 90 return Key(self.name, '-', key_type=Key.KEY_STREAM_READABLE)
91 else:
92 fp = open(key_name, 'rb')
93 return Key(self.name, key_name, fp)
86 94
87 def new_key(self, key_name=None): 95 def new_key(self, key_name=None, key_type=Key.KEY_REGULAR_FILE):
88 """ 96 """
89 Creates a new key 97 Creates a new key
90 98
91 :type key_name: string 99 :type key_name: string
92 :param key_name: The name of the key to create 100 :param key_name: The name of the key to create
93 101
94 :rtype: :class:`boto.file.key.Key` 102 :rtype: :class:`boto.file.key.Key`
95 :returns: An instance of the newly created key object 103 :returns: An instance of the newly created key object
96 """ 104 """
97 dir_name = os.path.dirname(key_name) 105 if key_name == '-':
98 if dir_name and not os.path.exists(dir_name): 106 return Key(self.name, '-', key_type=Key.KEY_STREAM_WRITABLE)
99 os.makedirs(dir_name) 107 else:
100 fp = open(key_name, 'wb') 108 dir_name = os.path.dirname(key_name)
101 return Key(self.name, key_name, fp) 109 if dir_name and not os.path.exists(dir_name):
110 os.makedirs(dir_name)
111 fp = open(key_name, 'wb')
112 return Key(self.name, key_name, fp)
OLDNEW
« no previous file with comments | « boto/exception.py ('k') | boto/file/key.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698