Defines a generator used to walk into directories using given maximum depth.

    Usage::

        >>> for item in depth_walker("./foundations/tests/tests_foundations/resources/standard/level_0"):
        ...     print(item)
        ...
        (u'./foundations/tests/tests_foundations/resources/standard/level_0', [u'level_1'], [u'standard.ibl'])
        (u'./foundations/tests/tests_foundations/resources/standard/level_0/level_1', [u'level_2'], [u'lorem_ipsum.txt', u'standard.rc'])
        >>> for item in depth_walker(tests_foundations, 2):
        ...     print(item)
        ...
        (u'./foundations/tests/tests_foundations/resources/standard/level_0', [u'level_1'], [u'standard.ibl'])
        (u'./foundations/tests/tests_foundations/resources/standard/level_0/level_1', [u'level_2'], [u'lorem_ipsum.txt', u'standard.rc'])
        (u'./foundations/tests/tests_foundations/resources/standard/level_0/level_1/level_2', [], [u'standard.sIBLT'])

    :param directory: Directory to walk.
    :type directory: unicode
    :param maximum_depth: Maximum depth.
    :type maximum_depth: int
    :return: Parent directory, directories, files.
    :rtype: tuple

def depth_walker(directory, maximum_depth=1):
    """
    Defines a generator used to walk into directories using given maximum depth.

    Usage::

        >>> for item in depth_walker("./foundations/tests/tests_foundations/resources/standard/level_0"):
        ...     print(item)
        ...
        (u'./foundations/tests/tests_foundations/resources/standard/level_0', [u'level_1'], [u'standard.ibl'])
        (u'./foundations/tests/tests_foundations/resources/standard/level_0/level_1', [u'level_2'], [u'lorem_ipsum.txt', u'standard.rc'])
        >>> for item in depth_walker(tests_foundations, 2):
        ...     print(item)
        ...
        (u'./foundations/tests/tests_foundations/resources/standard/level_0', [u'level_1'], [u'standard.ibl'])
        (u'./foundations/tests/tests_foundations/resources/standard/level_0/level_1', [u'level_2'], [u'lorem_ipsum.txt', u'standard.rc'])
        (u'./foundations/tests/tests_foundations/resources/standard/level_0/level_1/level_2', [], [u'standard.sIBLT'])

    :param directory: Directory to walk.
    :type directory: unicode
    :param maximum_depth: Maximum depth.
    :type maximum_depth: int
    :return: Parent directory, directories, files.
    :rtype: tuple
    """

    separator = os.path.sep
    base_depth = directory.count(separator)

    for parent_directory, directories, files in os.walk(directory):
        yield parent_directory, directories, files
        if base_depth + maximum_depth <= parent_directory.count(separator):
            del directories[:]