Make a method to check if an item matches the pattern, and is wanted

    If wanted is None just check the pattern

def make_needed(pattern, path_to_directory, wanted):
    """Make a method to check if an item matches the pattern, and is wanted

    If wanted is None just check the pattern
    """
    if wanted:
        def needed(name):
            return fnmatch(name, pattern) and wanted(
                os.path.join(path_to_directory, name))
        return needed
    else:
        return lambda name: fnmatch(name, pattern)