(media_objects)
return _media_files(), errors
take as input the output of get_media_objects
    and return an iterator of (path, data) tuples for the media files
    as they should show up in the .zip
    as well as a list of error messages

    as a side effect of implementation,
    errors will not include all error messages until the iterator is exhausted
take as input the output of get_media_objects
    and return an iterator of (path, data) tuples for the media files
    as they should show up in the .zip
    as well as a list of error messages
take as input the output of get_media_objects and return an iterator of ( path data ) tuples for the media files as they should show up in the . zip as well as a list of error messages
def iter_media_files(media_objects):
    """
    take as input the output of get_media_objects
    and return an iterator of (path, data) tuples for the media files
    as they should show up in the .zip
    as well as a list of error messages

    as a side effect of implementation,
    errors will not include all error messages until the iterator is exhausted

    """
    errors = []

    def _media_files():
        for path, media in media_objects:
            try:
                data, _ = media.get_display_file()
                folder = path.replace(MULTIMEDIA_PREFIX, "")
                if not isinstance(data, str):
                    yield os.path.join(folder), data
            except NameError as e:
                message = "%(path)s produced an ERROR: %(error)s" % {
                    'path': path,
                    'error': e,
                }
                errors.append(message)
    return _media_files(), errors
def iter_media_files ( media_objects ) : errors = [ ] def _media_files ( ) : for path , media in media_objects : try : data , _ = media . get_display_file ( ) folder = path . replace ( MULTIMEDIA_PREFIX , "" ) if not isinstance ( data , str ) : yield os . path . join ( folder ) , data except NameError as e : message = "%(path)s produced an ERROR: %(error)s" % { 'path' : path , 'error' : e , } errors . append ( message ) return _media_files ( ) , errors