Permalink
Browse files

PEP8 cleanup.

  • Loading branch information...
garnaat committed Mar 28, 2012
1 parent ee94b00 commit b4083978da43118274ff3c65dda2d085e30fc5ab
View
@@ -15,7 +15,7 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
View
@@ -15,23 +15,20 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
import xml.sax
-import time
import uuid
import boto
from boto.connection import AWSAuthConnection
from boto import handler
-from boto.resultset import ResultSet
import boto.jsonresponse
import boto.compat as compat
from . import exception
-from . import hostedzone
HZXML = """<?xml version="1.0" encoding="UTF-8"?>
<CreateHostedZoneRequest xmlns="%(xmlns)s">
@@ -41,9 +38,10 @@
<Comment>%(comment)s</Comment>
</HostedZoneConfig>
</CreateHostedZoneRequest>"""
-
+
#boto.set_stream_logger('dns')
+
class Route53Connection(AWSAuthConnection):
DefaultHost = 'route53.amazonaws.com'
"""The default Route53 API endpoint to connect to."""
@@ -68,10 +66,12 @@ def make_request(self, action, path, headers=None, data='', params=None):
if params:
pairs = []
for key, val in params.items():
- if val is None: continue
+ if val is None:
+ continue
pairs.append(key + '=' + compat.quote(str(val)))
path += '?' + '&'.join(pairs)
- return AWSAuthConnection.make_request(self, action, path, headers, data)
+ return AWSAuthConnection.make_request(self, action, path,
+ headers, data)
# Hosted Zones
@@ -110,10 +110,9 @@ def get_all_hosted_zones(self, start_marker=None, zone_list=None):
def get_hosted_zone(self, hosted_zone_id):
"""
Get detailed information about a particular Hosted Zone.
-
+
:type hosted_zone_id: str
:param hosted_zone_id: The unique identifier for the Hosted Zone
-
"""
uri = '/%s/hostedzone/%s' % (self.Version, hosted_zone_id)
response = self.make_request('GET', uri)
@@ -133,7 +132,7 @@ def create_hosted_zone(self, domain_name, caller_ref=None, comment=''):
"""
Create a new Hosted Zone. Returns a Python data structure with
information about the newly created Hosted Zone.
-
+
:type domain_name: str
:param domain_name: The name of the domain. This should be a
fully-specified domain, and should end with a final period
@@ -153,20 +152,20 @@ def create_hosted_zone(self, domain_name, caller_ref=None, comment=''):
use that.
:type comment: str
- :param comment: Any comments you want to include about the hosted
+ :param comment: Any comments you want to include about the hosted
zone.
"""
if caller_ref is None:
caller_ref = str(uuid.uuid4())
- params = {'name' : domain_name,
- 'caller_ref' : caller_ref,
- 'comment' : comment,
- 'xmlns' : self.XMLNameSpace}
+ params = {'name': domain_name,
+ 'caller_ref': caller_ref,
+ 'comment': comment,
+ 'xmlns': self.XMLNameSpace}
xml = HZXML % params
uri = '/%s/hostedzone' % self.Version
response = self.make_request('POST', uri,
- {'Content-Type' : 'text/xml'}, xml)
+ {'Content-Type': 'text/xml'}, xml)
body = response.read()
boto.log.debug(body)
if response.status == 201:
@@ -179,7 +178,7 @@ def create_hosted_zone(self, domain_name, caller_ref=None, comment=''):
raise exception.DNSServerError(response.status,
response.reason,
body)
-
+
def delete_hosted_zone(self, hosted_zone_id):
uri = '/%s/hostedzone/%s' % (self.Version, hosted_zone_id)
response = self.make_request('DELETE', uri)
@@ -201,7 +200,7 @@ def get_all_rrsets(self, hosted_zone_id, type=None,
"""
Retrieve the Resource Record Sets defined for this Hosted Zone.
Returns the raw XML data returned by the Route53 call.
-
+
:type hosted_zone_id: str
:param hosted_zone_id: The unique identifier for the Hosted Zone
@@ -281,7 +280,7 @@ def change_rrsets(self, hosted_zone_id, xml_body):
"""
uri = '/%s/hostedzone/%s/rrset' % (self.Version, hosted_zone_id)
response = self.make_request('POST', uri,
- {'Content-Type' : 'text/xml'},
+ {'Content-Type': 'text/xml'},
xml_body)
body = response.read()
boto.log.debug(body)
@@ -15,13 +15,14 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
from boto.exception import BotoServerError
+
class DNSServerError(BotoServerError):
pass
@@ -22,6 +22,7 @@
# IN THE SOFTWARE.
#
+
class HostedZone(object):
def __init__(self, id=None, name=None, owner=None, version=None,
@@ -53,4 +54,3 @@ def endElement(self, name, value, connection):
self.caller_reference = value
else:
setattr(self, name, value)
-
View
@@ -23,6 +23,8 @@
RECORD_TYPES = ['A', 'AAAA', 'TXT', 'CNAME', 'MX', 'PTR', 'SRV', 'SPF']
from boto.resultset import ResultSet
+
+
class ResourceRecordSets(ResultSet):
"""
A list of resource records.
@@ -159,7 +161,6 @@ def __iter__(self):
results = None
-
class Record(object):
"""An individual ResourceRecordSet"""
@@ -195,8 +196,6 @@ class Record(object):
<DNSName>%s</DNSName>
</AliasTarget>"""
-
-
def __init__(self, name=None, type=None, ttl=600, resource_records=None,
alias_hosted_zone_id=None, alias_dns_name=None, identifier=None,
weight=None, region=None):
@@ -225,7 +224,8 @@ def to_xml(self):
"""Spit this resource record set out as XML"""
if self.alias_hosted_zone_id != None and self.alias_dns_name != None:
# Use alias
- body = self.AliasBody % (self.alias_hosted_zone_id, self.alias_dns_name)
+ body = self.AliasBody % (self.alias_hosted_zone_id,
+ self.alias_dns_name)
else:
# Use resource record(s)
records = ""
@@ -241,8 +241,8 @@ def to_xml(self):
self.weight}
elif self.identifier != None and self.region != None:
weight = self.RRRBody % {"identifier": self.identifier, "region":
- self.region}
-
+ self.region}
+
params = {
"name": self.name,
"type": self.type,
@@ -258,7 +258,7 @@ def to_print(self):
rr = 'ALIAS ' + self.alias_hosted_zone_id + ' ' + self.alias_dns_name
else:
# Show resource record(s)
- rr = ",".join(self.resource_records)
+ rr = ",".join(self.resource_records)
if self.identifier != None and self.weight != None:
rr += ' (WRR id=%s, w=%s)' % (self.identifier, self.weight)
View
@@ -14,14 +14,15 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
from .regioninfo import SDBRegionInfo
+
def regions():
"""
Get all available regions for the SDB service.
@@ -45,14 +46,15 @@ def regions():
endpoint='sdb.ap-southeast-1.amazonaws.com')
]
+
def connect_to_region(region_name, **kw_params):
"""
- Given a valid region name, return a
+ Given a valid region name, return a
:class:`boto.sdb.connection.SDBConnection`.
:type: str
:param region_name: The name of the region to connect to.
-
+
:rtype: :class:`boto.sdb.connection.SDBConnection` or ``None``
:return: A connection to the given region, or None if an invalid region
name is given
@@ -62,6 +64,7 @@ def connect_to_region(region_name, **kw_params):
return region.connect(**kw_params)
return None
+
def get_region(region_name, **kw_params):
"""
Find and return a :class:`boto.sdb.regioninfo.RegionInfo` object
Oops, something went wrong.

0 comments on commit b408397

Please sign in to comment.