def zone_for_name(name, rdclass=dns.rdataclass.IN, tcp=False, resolver=None):
 if isinstance(name, (str, unicode)):
  name = dns.name.from_text(name, dns.name.root)
 if (resolver is None):
  resolver = get_default_resolver()
 if (not name.is_absolute()):
  raise NotAbsolute(name)
 while 1:
  try:
   answer = resolver.query(name, dns.rdatatype.SOA, rdclass, tcp)
   if (answer.rrset.name == name):
    return name
  except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
   pass
  try:
   name = name.parent()
  except dns.name.NoParent:
   raise NoRootSOA

def zone_for_name ( name , rdclass = dns . rdataclass . IN , tcp = False , resolver = None ) : if isinstance ( name , ( str , unicode ) ) : name = dns . name . from_text ( name , dns . name . root ) if ( resolver is None ) : resolver = get_default_resolver ( ) if ( not name . is_absolute ( ) ) : raise NotAbsolute ( name ) while 1 : try : answer = resolver . query ( name , dns . rdatatype . SOA , rdclass , tcp ) if ( answer . rrset . name == name ) : return name except ( dns . resolver . NXDOMAIN , dns . resolver . NoAnswer ) : pass try : name = name . parent ( ) except dns . name . NoParent : raise NoRootSOA
find the name of the zone which contains the specified name .