Static method for resolving a DID to a subdomain
    Return the subdomain record on success
    Return None on error

def get_DID_subdomain(did, db_path=None, zonefiles_dir=None, atlasdb_path=None, check_pending=False):
    """
    Static method for resolving a DID to a subdomain
    Return the subdomain record on success
    Return None on error
    """
    opts = get_blockstack_opts()
    if not is_subdomains_enabled(opts):
        log.warn("Subdomain support is disabled")
        return None

    if db_path is None:
        db_path = opts['subdomaindb_path']

    if zonefiles_dir is None:
        zonefiles_dir = opts['zonefiles']
    
    if atlasdb_path is None:
        atlasdb_path = opts['atlasdb_path']

    db = SubdomainDB(db_path, zonefiles_dir)
    try:
        subrec = db.get_DID_subdomain(did)
    except Exception as e:
        if BLOCKSTACK_DEBUG:
            log.exception(e)

        log.warn("Failed to load subdomain for {}".format(did))
        return None

    if check_pending:
        # make sure that all of the zone files between this subdomain's
        # domain's creation and this subdomain's zone file index are present,
        # minus the ones that are allowed to be missing.
        subrec.pending = db.subdomain_check_pending(subrec, atlasdb_path)

    return subrec