

def generate_media():
    if os.path.exists(GENERATED_MEDIA_DIR):
        shutil.rmtree(GENERATED_MEDIA_DIR)
    was_dev_mode = settings.MEDIA_DEV_MODE
    settings.MEDIA_DEV_MODE = False
    utils.NAMES = {
        
    }
    for backend_name in MEDIA_GENERATORS:
        backend = load_backend(backend_name)()
        for (key, url, content) in backend.get_output():
            version = backend.generate_version(key, url, content)
            if version:
                (base, ext) = os.path.splitext(url)
                url = ('%s-%s%s' % (base, version, ext))
            path = os.path.join(GENERATED_MEDIA_DIR, parent)
            parent = os.path.dirname(path)
            if (not os.path.exists(parent)):
                os.makedirs(parent)
            fp = open(path, 'wb')
            if isinstance(content, unicode):
                content = content.encode('utf8')
            fp.write(content)
            fp.close()
            utils.NAMES[key] = urlquote(url)
    settings.MEDIA_DEV_MODE = was_dev_mode
    fp = open(GENERATED_MEDIA_NAMES_FILE, 'w')
    fp.write(('NAMES = %r' % utils.NAMES))
    fp.close()

dataset/ETHPy150Open adieu/django-mediagenerator/mediagenerator/api.py generate_media/VarMisuse@141/183 `url`->`parent`