import zipfile import glob import os from ai import completion import shutil html_path_list = [] if os.path.exists('dist'): shutil.rmtree('dist') for fname in glob.glob('./webs/**/*.zip'): dirs = fname.split('/') owners = dirs[2] print(f'Procesando a {owners}') owner = completion(f'you are an ai that only gets the first person\'s name and returns it in lowercase. here is the current directory name: {owners}. you must only return the lowercase name and nothing else. you mustn\'t return special characters, only english ones. return names composed of more than one word with underscores') dist_loc = f'dist/{owner}' os.makedirs(dist_loc) archive = zipfile.ZipFile(fname) archive_dirs = archive.namelist() root_zip_dir = archive_dirs[0].split('/')[0] for dirs in archive_dirs: if dirs.startswith(f'{root_zip_dir}/dist'): archive.extract(dirs, dist_loc) shutil.move(f'{dist_loc}/{dirs}', dist_loc) shutil.rmtree(f'{dist_loc}/{root_zip_dir}') html_path_list.append(f'