From b5e7356b9168958e9b3017210ef42a999b887506 Mon Sep 17 00:00:00 2001 From: Martin Levy Date: Wed, 30 Mar 2022 13:45:11 -0700 Subject: [PATCH] print() was outdate - from pull #120 --- README.md | 19 ++++++++++--------- README.rst | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 77baad8..d9522d9 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ def main(): for zone in zones: zone_id = zone['id'] zone_name = zone['name'] - print zone_id, zone_name + print("zone_id=%s zone_name=%s" % (zone_id, zone_name)) if __name__ == '__main__': main() @@ -85,7 +85,8 @@ def main(): settings_ipv6 = cf.zones.settings.ipv6.get(zone_id) ipv6_status = settings_ipv6['value'] - print zone_id, zone_name, ssl_status, ipv6_status + print("zone_id=%s zone_name=%s" % (zone_id, zone_name)) + print("ssl_status=%s ipv6_status=%s" % (ssl_status, ipv6_status)) if __name__ == '__main__': main() @@ -110,7 +111,7 @@ def main(): for zone in zones: zone_id = zone['id'] zone_name = zone['name'] - print zone_id, zone_name + print("zone_id=%s zone_name=%s" % (zone_id, zone_name)) total_pages = raw_results['result_info']['total_pages'] if page_number == total_pages: @@ -152,7 +153,7 @@ def main(): exit('/zones/dns_records.get %d %s - api call failed' % (e, e)) # print the results - first the zone name - print zone_id, zone_name + print("zone_id=%s zone_name=%s" % (zone_id, zone_name)) # then all the DNS records for that zone for dns_record in dns_records: @@ -160,7 +161,7 @@ def main(): r_type = dns_record['type'] r_value = dns_record['content'] r_id = dns_record['id'] - print '\t', r_id, r_name, r_type, r_value + print('\t', r_id, r_name, r_type, r_value) exit(0) @@ -322,7 +323,7 @@ import CloudFlare def main(): cf = CloudFlare.CloudFlare() zones = cf.zones.get(params={'per_page':5}) - print len(zones) + print("len=%d" % (zones.length())) if __name__ == '__main__': main() @@ -345,8 +346,8 @@ import CloudFlare def main(): cf = CloudFlare.CloudFlare(raw=True) zones = cf.zones.get(params={'per_page':5}) - print zones.length() - print json.dumps(zones, indent=4, sort_keys=True) + print("len=%d" % (zones.length())) + print(json.dumps(zones, indent=4, sort_keys=True)) if __name__ == '__main__': main() @@ -908,7 +909,7 @@ def main(): for l in dns_records.splitlines(): if len(l) == 0 or l[0] == ';': continue - print l + print(l) exit(0) if __name__ == '__main__': diff --git a/README.rst b/README.rst index c05e480..f5d6c23 100644 --- a/README.rst +++ b/README.rst @@ -64,7 +64,7 @@ A very simple listing of zones within your account; including the IPv6 status of for zone in zones: zone_id = zone['id'] zone_name = zone['name'] - print zone_id, zone_name + print("zone_id=%s zone_name=%s" % (zone_id, zone_name)) if __name__ == '__main__': main() @@ -90,7 +90,8 @@ Now lets expand on that and add code to show the IPv6 and SSL status of the zone settings_ipv6 = cf.zones.settings.ipv6.get(zone_id) ipv6_status = settings_ipv6['value'] - print zone_id, zone_name, ssl_status, ipv6_status + print("zone_id=%s zone_name=%s" % (zone_id, zone_name)) + print("ssl_status=%s ipv6_status=%s" % (ssl_status, ipv6_status)) if __name__ == '__main__': main() @@ -114,7 +115,7 @@ Raw mode is only needed when a get request has the possibility of returning many for zone in zones: zone_id = zone['id'] zone_name = zone['name'] - print zone_id, zone_name + print("zone_id=%s zone_name=%s" % (zone_id, zone_name)) total_pages = raw_results['result_info']['total_pages'] if page_number == total_pages: @@ -156,7 +157,7 @@ A more complex example follows. exit('/zones/dns_records.get %d %s - api call failed' % (e, e)) # print the results - first the zone name - print zone_id, zone_name + print("zone_id=%s zone_name=%s" % (zone_id, zone_name)) # then all the DNS records for that zone for dns_record in dns_records: @@ -164,7 +165,7 @@ A more complex example follows. r_type = dns_record['type'] r_value = dns_record['content'] r_id = dns_record['id'] - print '\t', r_id, r_name, r_type, r_value + print('\t', r_id, r_name, r_type, r_value) exit(0) @@ -326,7 +327,7 @@ You can return all the paging values by calling the class with raw=True. Here’ def main(): cf = CloudFlare.CloudFlare() zones = cf.zones.get(params={'per_page':5}) - print len(zones) + print("len=%d" % (zones.length())) if __name__ == '__main__': main() @@ -349,8 +350,8 @@ When you add the raw option; the APIs full structure is returned. This means the def main(): cf = CloudFlare.CloudFlare(raw=True) zones = cf.zones.get(params={'per_page':5}) - print zones.length() - print json.dumps(zones, indent=4, sort_keys=True) + print("len=%d" % (zones.length())) + print(json.dumps(zones, indent=4, sort_keys=True)) if __name__ == '__main__': main() @@ -923,7 +924,7 @@ This can also be done via Python code with the following example. for l in dns_records.splitlines(): if len(l) == 0 or l[0] == ';': continue - print l + print(l) exit(0) if __name__ == '__main__':