Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

перепиши строку shutil.copytree(sourcefolder, newfolder). тут выдаёт ошибку import…

  1. User

    перепиши строку shutil.copytree(source_folder, new_folder). тут выдаёт ошибку

    import shutil import json import os from PIL import Image

    Указываем путь и название исходной папки

    source_folder = input("source_folder")

    Указываем путь и название новой папки

    new_folder = input("new_folder")

    Копирование папки с новым названием

    shutil.copytree(source_folder, new_folder)

    Путь к файлу config.json в новой папке

    config_file = new_folder + "/config.json"

    Открываем файл на чтение и загружаем его содержимое в переменную data

    with open(config_file, "r") as file: data = json.load(file)

    Получаем данные от пользователя

    map_name = input("Введите название карты: ") author = input("Введите автора: ") background_name = input("Введите название фона: ")

    Замена строк в config.json

    data["MapName"] = map_name data["Author"] = author data["BackgroundName"] = background_name data["WorldMap"] = True

    Записываем изменения обратно в файл config.json

    with open(config_file, "w") as file: json.dump(data, file)

    Путь к папке provinces

    provinces_folder = new_folder + "/data/scales/provinces"

    Создание папок с указанными названиями

    folders = input("Введите названия папок через запятую (например: 1,3): ") folders_list = folders.split(",") for folder_name in folders_list: folder_path = os.path.join(provinces_folder, folder_name.strip()) os.makedirs(folder_path)

    Путь к файлу Age_of_Civilizations

    age_of_civilizations_file = provinces_folder + "/Age_of_Civilizations"

    Запись названий папок в файл Age_of_Civilizations

    with open(age_of_civilizations_file, "w") as file: file.write(";".join(folders_list))

    Указываем путь к папке PROV

    PROV = input("Введите путь к папке PROV: ")

    Пути к папкам назначения

    update_folder = new_folder + "/update" updatePB_folder = new_folder + "/updatePB" provinces_data_folder = new_folder + "/data/provinces"

    Копирование файлов из PROV в папку update

    for file_name in os.listdir(PROV): file_path = os.path.join(PROV, file_name) shutil.copy(file_path, update_folder)

    Копирование файлов из update в папку updatePB

    for file_name in os.listdir(update_folder): file_path = os.path.join(update_folder, file_name) shutil.copy(file_path, updatePB_folder)

    Копирование файлов из update в папку provinces

    for file_name in os.listdir(update_folder): file_path = os.path.join(update_folder, file_name) shutil.copy(file_path, provinces_data_folder)

    Получаем количество файлов в PROV

    file_count = len(os.listdir(PROV))

    Замена строки NumberOfProvinces в config.json на количество файлов

    data["NumberOfProvinces"] = file_count

    Записываем изменения обратно в файл config.json

    with open(config_file, "w") as file: json.dump(data, file)

    Указываем путь к изображению

    image_path = input("Введите путь к изображению: ") image_name = os.path.basename(image_path)

    Разделение изображения на две части

    image = Image.open(image_path) width, height = image.size left_image = image.crop((0, 0, width//2, height)) right_image = image.crop((width//2, 0, width, height))

    Новые названия для левой и правой частей изображения

    left_image_name = image_name.split(".")[0] + "_L." + image_name.split(".")[1] right_image_name = image_name.split(".")[0] + "_R." + image_name.split(".")[1]

    Сохранение левой и правой частей изображения

    left_image.save(os.path.join(new_folder, left_image_name)) right_image.save(os.path.join(new_folder, right_image_name))

  2. Assistant

    source_folder = input("Введите путь и название исходной папки: ") new_folder = input("Введите путь и название новой папки: ") shutil.copytree(source_folder, new_folder) config_file = os.path.join(new_folder, "config.json")

    with open(config_file, "r") as file: data = json.load(file)

    map_name = input("Введите название карты: ") author = input("Введите автора: ") background_name = input("Введите название фона: ")

    data["MapName"] = map_name data["Author"] = author data["BackgroundName"] = background_name data["WorldMap"] = True

    with open(config_file, "w") as file: json.dump(data, file)

    provinces_folder = os.path.join(new_folder, "data", "scales", "provinces") folders = input("Введите названия папок через запятую (например: 1,3): ") folders_list = folders.split(",")

    for folder_name in folders_list: folder_path = os.path.join(provinces_folder, folder_name.strip()) os.makedirs(folder_path)

    age_of_civilizations_file = os.path.join(provinces_folder, "Age_of_Civilizations")

    with open(age_of_civilizations_file, "w") as file: file.write(";".join(folders_list))

    PROV = input("Введите путь к папке PROV: ") update_folder = os.path.join(new_folder, "update") updatePB_folder = os.path.join(new_folder, "updatePB") provinces_data_folder = os.path.join(new_folder, "data", "provinces")

    for file_name in os.listdir(PROV): file_path = os.path.join(PROV, file_name) shutil.copy(file_path, update_folder)

    for file_name in os.listdir(update_folder): file_path = os.path.join(update_folder, file_name) shutil.copy(file_path, updatePB_folder)

    for file_name in os.listdir(update_folder): file_path = os.path.join(update_folder, file_name) shutil.copy(file_path, provinces_data_folder)

    file_count = len(os.listdir(PROV)) data["NumberOfProvinces"] = file_count

    with open(config_file, "w") as file: json.dump(data, file)

    image_path = input("Введите путь к изображению: ") image_name = os.path.basename(image_path)

    image = Image.open(image_path) width, height = image.size left_image = image.crop((0, 0, width//2, height)) right_image = image.crop((width//2, 0, width, height))

    left_image_name = image_name.split(".")[0] + "_L." + image_name.split(".")[1] right_image_name = image_name.split(".")[0] + "_R." + image_name.split(".")[1]

    left_image.save(os.path.join(new_folder, left_image_name)) right_image.save(os.path.join(new_folder, right_image_name))