def _scan_directory(directory, sentinel, depth=0):
    directory = os.path.abspath(directory)
    real_directory = os.path.realpath(directory)

    if depth < max_directory_depth and real_directory not in sentinel \
            and os.path.isdir(directory):
        sentinel.add(real_directory)

        for item in os.listdir(directory):
            if item in ('.', '..'):
                # I'm not sure if this is even needed any more.
                continue

            p = os.path.abspath(os.path.join(directory, item))
            if (os.path.isdir(p) and _dir_ignore.search(p)) \
                    or (os.path.isfile(p) and _ext_ignore.search(p)):
                continue

            yield p
Registers a model with reversion, if required.
dataset/ETHPy150Open tweekmonster/moult/moult/filesystem_scanner.py/_scan_directory--crossover with--dataset/ETHPy150Open etianen/django-reversion/src/reversion/admin.py/VersionAdmin._autoregister