Merge lp:~oubiwann/txaws/413741-pep8-cleanup into lp:~txawsteam/txaws/trunk

Proposed by Duncan McGreggor
Status: Merged
Merged at revision: not available
Proposed branch: lp:~oubiwann/txaws/413741-pep8-cleanup
Merge into: lp:~txawsteam/txaws/trunk
Diff against target: None lines
To merge this branch: bzr merge lp:~oubiwann/txaws/413741-pep8-cleanup
Reviewer Review Type Date Requested Status
Original txAWS Team Pending
Review via email: mp+10204@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Duncan McGreggor (oubiwann) wrote :

I'd like to merge this small fix-up branch to trunk. Could I get some reviews?

Thanks!

d

Revision history for this message
Robert Collins (lifeless) wrote :

review +1

I don't really like this bit though;

#comment
#comment
"""Docstring"""

I find it _much_ easier to read visually as

#comment
#comment

"""Docstring"""

-- comments are not classes or functions :)

Revision history for this message
Duncan McGreggor (oubiwann) wrote :

On Sun, Aug 16, 2009 at 6:51 PM, Robert
Collins<email address hidden> wrote:
> review +1
>
> I don't really like this bit though;
>
> #comment
> #comment
> """Docstring"""
>
> I find it _much_ easier to read visually as
>
> #comment
> #comment
>
> """Docstring"""
>
> -- comments are not classes or functions :)

Cool -- I have no problem with that :-) I'll put it back.

d

7. By Duncan McGreggor <email address hidden>

Added new lines between comments, docstrings, and imports at the top of files
(lifeless 1).

Revision history for this message
Duncan McGreggor (oubiwann) wrote :

Robert's review point has been addressed.

Since there's not a lot of activity in this team, how about we merge with one +1. Once we have more people and contributions, maybe we can bump that up...

Revision history for this message
Robert Collins (lifeless) wrote :

On Tue, 2009-08-18 at 18:20 +0000, Duncan McGreggor wrote:
> Robert's review point has been addressed.
>
> Since there's not a lot of activity in this team, how about we merge with one +1. Once we have more people and contributions, maybe we can bump that up...

I think 2 review-capable people agreeing is sufficient - that is the
author and a reviewer, or for non team contributions, two team members.

-Rob

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/aws-status'
2--- bin/aws-status 2009-04-26 08:32:36 +0000
3+++ bin/aws-status 2009-08-15 03:28:45 +0000
4@@ -1,8 +1,9 @@
5 #!/usr/bin/env python
6 # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net>
7 # Licenced under the txaws licence available at /LICENSE in the txaws source.
8-
9 import sys
10 from txaws.client.gui.gtk import main
11+
12+
13 sys.exit(main(sys.argv))
14
15
16=== modified file 'txaws/client/gui/gtk.py'
17--- txaws/client/gui/gtk.py 2009-05-08 13:18:59 +0000
18+++ txaws/client/gui/gtk.py 2009-08-15 03:28:45 +0000
19@@ -1,18 +1,19 @@
20 # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net>
21 # Licenced under the txaws licence available at /LICENSE in the txaws source.
22-
23 """A GTK client for working with aws."""
24
25 from __future__ import absolute_import
26
27-__all__ = ['main']
28-
29 import gnomekeyring
30 import gobject
31 import gtk
32
33 from txaws.credentials import AWSCredentials
34
35+
36+__all__ = ['main']
37+
38+
39 class AWSStatusIcon(gtk.StatusIcon):
40 """A status icon shown when instances are running."""
41
42@@ -49,7 +50,8 @@
43 self.manager = gtk.UIManager()
44 self.manager.insert_action_group(ag, 0)
45 self.manager.add_ui_from_string(menu)
46- self.menu = self.manager.get_widget('/Menubar/Menu/Stop instances').props.parent
47+ self.menu = self.manager.get_widget(
48+ '/Menubar/Menu/Stop instances').props.parent
49 self.connect('popup-menu', self.on_popup_menu)
50
51 def create_client(self, creds):
52@@ -79,7 +81,8 @@
53 return AWSCredentials(access_key=key_id, secret_key=secret_key)
54
55 def show_a_password_dialog(self):
56- self.password_dialog = gtk.Dialog("Enter your AWS credentals", None, gtk.DIALOG_MODAL,
57+ self.password_dialog = gtk.Dialog(
58+ "Enter your AWS credentals", None, gtk.DIALOG_MODAL,
59 (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT,
60 gtk.STOCK_CANCEL,
61 gtk.RESPONSE_REJECT))
62@@ -109,7 +112,8 @@
63 # credentials.
64 return
65 self.probing = True
66- self.client.describe_instances().addCallbacks(self.showhide, self.describe_error)
67+ d = self.client.describe_instances()
68+ d.addCallbacks(self.showhide, self.describe_error)
69
70 def on_popup_menu(self, status, button, time):
71 self.menu.popup(None, None, None, button, time)
72
73=== modified file 'txaws/credentials.py'
74--- txaws/credentials.py 2009-04-27 08:53:11 +0000
75+++ txaws/credentials.py 2009-08-15 03:28:45 +0000
76@@ -1,14 +1,15 @@
77 # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net>
78 # Licenced under the txaws licence available at /LICENSE in the txaws source.
79-
80 """Credentials for accessing AWS services."""
81
82-__all__ = ['AWSCredentials']
83-
84 import os
85
86 from txaws.util import *
87
88+
89+__all__ = ['AWSCredentials']
90+
91+
92 class AWSCredentials(object):
93
94 def __init__(self, access_key=None, secret_key=None):
95
96=== modified file 'txaws/ec2/client.py'
97--- txaws/ec2/client.py 2009-04-28 11:52:57 +0000
98+++ txaws/ec2/client.py 2009-08-15 03:28:45 +0000
99@@ -1,10 +1,6 @@
100 # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net>
101 # Licenced under the txaws licence available at /LICENSE in the txaws source.
102-
103 """EC2 client support."""
104-
105-__all__ = ['EC2Client']
106-
107 from base64 import b64encode
108 from urllib import quote
109
110@@ -14,13 +10,15 @@
111 from txaws.util import iso8601time, XML
112
113
114+__all__ = ['EC2Client']
115+
116+
117 class Instance(object):
118 """An Amazon EC2 Instance.
119
120- :attrib instanceId: The instance ID of this instance.
121- :attrib instanceState: The state of this instance.
122+ @attrib instanceId: The instance ID of this instance.
123+ @attrib instanceState: The state of this instance.
124 """
125-
126 def __init__(self, instanceId, instanceState):
127 self.instanceId = instanceId
128 self.instanceState = instanceState
129@@ -34,7 +32,7 @@
130 def __init__(self, creds=None, query_factory=None):
131 """Create an EC2Client.
132
133- :param creds: Explicit credentials to use. If None, credentials are
134+ @param creds: Explicit credentials to use. If None, credentials are
135 inferred as per txaws.credentials.AWSCredentials.
136 """
137 if creds is None:
138@@ -67,8 +65,8 @@
139 def terminate_instances(self, *instance_ids):
140 """Terminate some instances.
141
142- :param instance_ids: The ids of the instances to terminate.
143- :return: A deferred which on success gives an iterable of
144+ @param instance_ids: The ids of the instances to terminate.
145+ @return: A deferred which on success gives an iterable of
146 (id, old-state, new-state) tuples.
147 """
148 instanceset = {}
149
150=== modified file 'txaws/ec2/tests/test_client.py'
151--- txaws/ec2/tests/test_client.py 2009-04-28 11:52:57 +0000
152+++ txaws/ec2/tests/test_client.py 2009-08-15 03:28:45 +0000
153@@ -1,6 +1,5 @@
154 # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net>
155 # Licenced under the txaws licence available at /LICENSE in the txaws source.
156-
157 import os
158
159 from twisted.internet.defer import succeed
160@@ -9,6 +8,7 @@
161 from txaws.ec2 import client
162 from txaws.tests import TXAWSTestCase
163
164+
165 sample_describe_instances_result = """<?xml version="1.0"?>
166 <DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01/">
167 <requestId>52b4c730-f29f-498d-94c1-91efb75994cc</requestId>
168@@ -49,6 +49,7 @@
169 </DescribeInstancesResponse>
170 """
171
172+
173 sample_terminate_instances_result = """<?xml version="1.0"?>
174 <TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01/">
175 <instancesSet>
176
177=== modified file 'txaws/storage/client.py'
178--- txaws/storage/client.py 2009-04-27 08:53:11 +0000
179+++ txaws/storage/client.py 2009-08-15 03:28:45 +0000
180@@ -6,8 +6,6 @@
181 Various API-incompatible changes are planned in order to expose missing
182 functionality in this wrapper.
183 """
184-
185-
186 from hashlib import md5
187 from base64 import b64encode
188
189@@ -64,7 +62,8 @@
190
191 if self.creds is not None:
192 signature = self.getSignature(headers)
193- headers['Authorization'] = 'AWS %s:%s' % (self.creds.access_key, signature)
194+ headers['Authorization'] = 'AWS %s:%s' % (
195+ self.creds.access_key, signature)
196
197 return headers
198
199@@ -73,7 +72,8 @@
200
201 def getCanonicalizedAmzHeaders(self, headers):
202 result = ''
203- headers = [(name.lower(), value) for name, value in headers.iteritems() if name.lower().startswith('x-amz-')]
204+ headers = [(name.lower(), value) for name, value in headers.iteritems()
205+ if name.lower().startswith('x-amz-')]
206 headers.sort()
207 return ''.join('%s:%s\n' % (name, value) for name, value in headers)
208
209@@ -87,7 +87,9 @@
210 return self.creds.sign(text)
211
212 def submit(self):
213- return self.getPage(url=self.getURI(), method=self.verb, postdata=self.data, headers=self.getHeaders())
214+ return self.getPage(
215+ url=self.getURI(), method=self.verb, postdata=self.data,
216+ headers=self.getHeaders())
217
218 def getPage(self, *a, **kw):
219 return getPage(*a, **kw)
220@@ -95,6 +97,7 @@
221
222 NS = '{http://s3.amazonaws.com/doc/2006-03-01/}'
223
224+
225 class S3(object):
226 rootURI = 'https://s3.amazonaws.com/'
227 requestFactory = S3Request
228@@ -117,8 +120,11 @@
229 """
230 root = XML(response)
231 for bucket in root.find(NS + 'Buckets'):
232- yield {'name': bucket.findtext(NS + 'Name'),
233- 'created': Time.fromISO8601TimeAndDate(bucket.findtext(NS + 'CreationDate'))}
234+ timeText = bucket.findtext(NS + 'CreationDate')
235+ yield {
236+ 'name': bucket.findtext(NS + 'Name'),
237+ 'created': Time.fromISO8601TimeAndDate(timeText),
238+ }
239
240 def listBuckets(self):
241 """
242@@ -127,7 +133,9 @@
243 Returns a list of all the buckets owned by the authenticated sender of
244 the request.
245 """
246- return self.makeRequest('GET').submit().addCallback(self._parseBucketList)
247+ d = self.makeRequest('GET').submit()
248+ d.addCallback(self._parseBucketList)
249+ return d
250
251 def createBucket(self, bucket):
252 """
253@@ -143,13 +151,15 @@
254 """
255 return self.makeRequest('DELETE', bucket).submit()
256
257- def putObject(self, bucket, objectName, data, contentType=None, metadata={}):
258+ def putObject(self, bucket, objectName, data, contentType=None,
259+ metadata={}):
260 """
261 Put an object in a bucket.
262
263 Any existing object of the same name will be replaced.
264 """
265- return self.makeRequest('PUT', bucket, objectName, data, contentType, metadata).submit()
266+ return self.makeRequest(
267+ 'PUT', bucket, objectName, data, contentType, metadata).submit()
268
269 def getObject(self, bucket, objectName):
270 """
271
272=== modified file 'txaws/storage/test/test_client.py'
273--- txaws/storage/test/test_client.py 2009-04-26 08:32:36 +0000
274+++ txaws/storage/test/test_client.py 2009-08-15 03:28:45 +0000
275@@ -8,6 +8,7 @@
276 from txaws.tests import TXAWSTestCase
277 from txaws.storage.client import S3, S3Request, calculateMD5
278
279+
280 class StubbedS3Request(S3Request):
281 def getPage(self, url, method, postdata, headers):
282 self.getPageArgs = (url, method, postdata, headers)
283@@ -25,9 +26,13 @@
284 DATA = 'objectData'
285 DIGEST = 'zhdB6gwvocWv/ourYUWMxA=='
286
287- request = S3Request('PUT', 'somebucket', 'object/name/here', DATA, contentType='text/plain', metadata={'foo': 'bar'})
288+ request = S3Request(
289+ 'PUT', 'somebucket', 'object/name/here', DATA,
290+ contentType='text/plain', metadata={'foo': 'bar'})
291 self.assertEqual(request.verb, 'PUT')
292- self.assertEqual(request.getURI(), 'https://s3.amazonaws.com/somebucket/object/name/here')
293+ self.assertEqual(
294+ request.getURI(),
295+ 'https://s3.amazonaws.com/somebucket/object/name/here')
296 headers = request.getHeaders()
297 self.assertNotEqual(headers.pop('Date'), '')
298 self.assertEqual(headers,
299@@ -45,7 +50,8 @@
300
301 request = S3Request('GET', 'somebucket')
302 self.assertEqual(request.verb, 'GET')
303- self.assertEqual(request.getURI(), 'https://s3.amazonaws.com/somebucket')
304+ self.assertEqual(
305+ request.getURI(), 'https://s3.amazonaws.com/somebucket')
306 headers = request.getHeaders()
307 self.assertNotEqual(headers.pop('Date'), '')
308 self.assertEqual(headers,
309@@ -75,7 +81,9 @@
310 req.date = 'Wed, 28 Mar 2007 01:29:59 +0000'
311
312 headers = req.getHeaders()
313- self.assertEqual(headers['Authorization'], 'AWS 0PN5J17HBGZHT7JJ3X82:jF7L3z/FTV47vagZzhKupJ9oNig=')
314+ self.assertEqual(
315+ headers['Authorization'],
316+ 'AWS 0PN5J17HBGZHT7JJ3X82:jF7L3z/FTV47vagZzhKupJ9oNig=')
317
318
319 class InertRequest(S3Request):
320@@ -140,7 +148,8 @@
321
322 def setUp(self):
323 TXAWSTestCase.setUp(self)
324- self.creds = AWSCredentials(access_key='accessKey', secret_key='secretKey')
325+ self.creds = AWSCredentials(
326+ access_key='accessKey', secret_key='secretKey')
327 self.s3 = TestableS3(creds=self.creds)
328
329 def test_makeRequest(self):
330@@ -167,11 +176,14 @@
331 self.assertEqual(req.objectName, None)
332
333 def _checkResult(buckets):
334- self.assertEqual(list(buckets),
335- [{'name': u'quotes',
336- 'created': Time.fromDatetime(datetime(2006, 2, 3, 16, 45, 9))},
337- {'name': u'samples',
338- 'created': Time.fromDatetime(datetime(2006, 2, 3, 16, 41, 58))}])
339+ self.assertEqual(
340+ list(buckets),
341+ [{'name': u'quotes',
342+ 'created': Time.fromDatetime(
343+ datetime(2006, 2, 3, 16, 45, 9))},
344+ {'name': u'samples',
345+ 'created': Time.fromDatetime(
346+ datetime(2006, 2, 3, 16, 41, 58))}])
347 return d.addCallback(_checkResult)
348
349 def test_createBucket(self):
350@@ -191,7 +203,8 @@
351 self.assertEqual(req.objectName, None)
352
353 def test_putObject(self):
354- self.s3.putObject('foobucket', 'foo', 'data', 'text/plain', {'foo': 'bar'})
355+ self.s3.putObject(
356+ 'foobucket', 'foo', 'data', 'text/plain', {'foo': 'bar'})
357 req = self.s3._lastRequest
358 self.assertTrue(req.submitted)
359 self.assertEqual(req.verb, 'PUT')
360
361=== modified file 'txaws/tests/__init__.py'
362--- txaws/tests/__init__.py 2009-04-27 08:53:11 +0000
363+++ txaws/tests/__init__.py 2009-08-15 03:28:45 +0000
364@@ -2,6 +2,7 @@
365
366 from twisted.trial.unittest import TestCase
367
368+
369 class TXAWSTestCase(TestCase):
370 """Support for isolation of txaws tests."""
371
372
373=== modified file 'txaws/tests/test_credentials.py'
374--- txaws/tests/test_credentials.py 2009-04-27 14:15:48 +0000
375+++ txaws/tests/test_credentials.py 2009-08-15 03:28:45 +0000
376@@ -1,6 +1,5 @@
377 # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net>
378 # Licenced under the txaws licence available at /LICENSE in the txaws source.
379-
380 import os
381
382 from twisted.trial.unittest import TestCase
383
384=== modified file 'txaws/tests/test_util.py'
385--- txaws/tests/test_util.py 2009-04-27 08:53:11 +0000
386+++ txaws/tests/test_util.py 2009-08-15 03:28:45 +0000
387@@ -2,6 +2,7 @@
388
389 from txaws.util import *
390
391+
392 class MiscellaneousTests(TestCase):
393
394 def test_hmac_sha1(self):
395
396=== modified file 'txaws/util.py'
397--- txaws/util.py 2009-04-27 08:53:11 +0000
398+++ txaws/util.py 2009-08-15 03:28:45 +0000
399@@ -3,19 +3,21 @@
400 New things in this module should be of relevance to more than one of amazon's
401 services.
402 """
403-
404-__all__ = ['hmac_sha1', 'iso8601time']
405-
406 from base64 import b64encode
407 from hashlib import sha1
408 import hmac
409 import time
410+
411 # Import XML from somwhere; here in one place to prevent duplication.
412 try:
413 from xml.etree.ElementTree import XML
414 except ImportError:
415 from elementtree.ElementTree import XML
416
417+
418+__all__ = ['hmac_sha1', 'iso8601time']
419+
420+
421 def hmac_sha1(secret, data):
422 digest = hmac.new(secret, data, sha1).digest()
423 return b64encode(digest)

Subscribers

People subscribed via source and target branches