osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Spot the invalid syntax


(Because I certainly can't.)

> def _san_dnsname_ips(dnsname, dnsname_is_cname=False):
>     """
>     Returns a set of IP addresses, managed by this IPa instance,
>     that correspond to the DNS name (from the subjectAltName).
> 
>     """
>     fqdn = dnsutil.DNSName(dnsname).make_absolute()
>     if fqdn.__len__() < 4:
>         logger.debug("Skipping IPs for %s: hostname too short" % dnsname)
>         return ()
>     zone = dnsutil.DNSName(resolver.zone_for_name(fqdn))
>     name = fqdn.relativize(zone)
>     try:
>         result = api.Command['dnsrecord_show'](zone, name)['result']
>     except errors.NotFound as nf:
>         logger.debug("Skipping IPs for %s: %s" % (dnsname, nf))
>         return ()
>     ips = set()
>     for ip in itertools.chain(result.get('arecord', ()),
>                               result.get('aaaarecord', ())):
>         if _ip_rdns_ok(ip, fqdn):
>             ips.add(ip)
>     cnames = result.get('cnamerecord', ())
>     if cnames:
>         if dnsname_is_cname:
>             logger.debug("Skipping IPs for %s: chained CNAME" % dnsname)
>         else:
>             for cname in cnames:
>                 if not cname.endswith('.'):
>                     cname = u'%s.%s' % (cname, zone)
>                 ips.update(_san_dnsname_ips(cname, True)
>     return ips

2.7 and 3.6 are both giving me:

   File "/tmp/test.py", line 32
     return ips
          ^
SyntaxError: invalid syntax

I've checked for tabs and mismatched parentheses.

Aargh!

-- 
========================================================================
Ian Pilcher                                         arequipeno at gmail.com
-------- "I grew up before Mark Zuckerberg invented friendship" --------
========================================================================