libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [3/4] libcloud git commit: Make code more readable, fix Python version compatibility issue.
Date Sat, 28 Feb 2015 21:44:15 GMT
Make code more readable, fix Python version compatibility issue.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/55ebfd19
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/55ebfd19
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/55ebfd19

Branch: refs/heads/trunk
Commit: 55ebfd199efa3ee19b5ea6a30a67cfc8bce9b76f
Parents: 23be732
Author: Tomaz Muraus <tomaz@apache.org>
Authored: Sat Feb 28 22:36:00 2015 +0100
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Sat Feb 28 22:36:00 2015 +0100

----------------------------------------------------------------------
 libcloud/dns/drivers/route53.py | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/55ebfd19/libcloud/dns/drivers/route53.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/drivers/route53.py b/libcloud/dns/drivers/route53.py
index 7a3904b..fe27f2e 100644
--- a/libcloud/dns/drivers/route53.py
+++ b/libcloud/dns/drivers/route53.py
@@ -314,8 +314,13 @@ class Route53DNSDriver(DNSDriver):
         ET.SubElement(change, 'Action').text = 'DELETE'
 
         rrs = ET.SubElement(change, 'ResourceRecordSet')
-        ET.SubElement(rrs, 'Name').text = record.name + '.' + \
-            record.zone.domain if record.name else record.zone.domain
+
+        if record.name:
+            record_name = record.name + '.' + record.zone.domain
+        else:
+            record_name = record.zone.domain
+
+        ET.SubElement(rrs, 'Name').text = record_name
         ET.SubElement(rrs, 'Type').text = self.RECORD_TYPE_MAP[record.type]
         ET.SubElement(rrs, 'TTL').text = str(record.extra.get('ttl', '0'))
 
@@ -334,8 +339,13 @@ class Route53DNSDriver(DNSDriver):
         ET.SubElement(change, 'Action').text = 'CREATE'
 
         rrs = ET.SubElement(change, 'ResourceRecordSet')
-        ET.SubElement(rrs, 'Name').text = name + '.' + \
-            record.zone.domain if name else record.zone.domain
+
+        if name:
+            record_name = name + '.' + record.zone.domain
+        else:
+            record_name = record.zone.domain
+
+        ET.SubElement(rrs, 'Name').text = record_name
         ET.SubElement(rrs, 'Type').text = self.RECORD_TYPE_MAP[type]
         ET.SubElement(rrs, 'TTL').text = str(extra.get('ttl', '0'))
 
@@ -365,15 +375,20 @@ class Route53DNSDriver(DNSDriver):
             ET.SubElement(change, 'Action').text = action
 
             rrs = ET.SubElement(change, 'ResourceRecordSet')
-            ET.SubElement(rrs, 'Name').text = name + '.' + \
-                zone.domain if name else zone.domain
+
+            if name:
+                record_name = name + '.' + zone.domain
+            else:
+                record_name = zone.domain
+
+            ET.SubElement(rrs, 'Name').text = record_name
             ET.SubElement(rrs, 'Type').text = self.RECORD_TYPE_MAP[type_]
             ET.SubElement(rrs, 'TTL').text = str(extra.get('ttl', '0'))
 
             rrecs = ET.SubElement(rrs, 'ResourceRecords')
             rrec = ET.SubElement(rrecs, 'ResourceRecord')
             if 'priority' in extra:
-                data = '{0} {1}'.format(extra['priority'], data)
+                data = '%s %s' % (extra['priority'], data)
             ET.SubElement(rrec, 'Value').text = data
 
         uri = API_ROOT + 'hostedzone/' + zone.id + '/rrset'


Mime
View raw message