def ensure_label_domain(fqdn, force=False):
    """Returns a label and domain object."""
    if fqdn == '':
        raise ValidationError("FQDN cannot be the emptry string.")
    try:
        domain = Domain.objects.get(name=fqdn)
        if not domain.soa and not force:
            raise ValidationError("You must create a record inside an "
                                  "existing zones.")
        return '', domain
    except __HOLE__:
        pass
    fqdn_partition = fqdn.split('.')
    if len(fqdn_partition) == 1:
        raise ValidationError("Creating this record would force the creation "
                              "of a new TLD '{0}'!".format(fqdn))
    else:
        label, domain_name = fqdn_partition[0], '.'.join(fqdn_partition[1:])
        domain = ensure_domain(domain_name, purgeable=True, inherit_soa=True)
        if not domain.soa and not force:
            raise ValidationError("You must create a record inside an "
                                  "existing zones.")
        return label, domain
dataset/ETHPy150Open mozilla/inventory/mozdns/utils.py/ensure_label_domain