Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import getpass
- import os
- import shutil
- import urllib
- import zipfile
- import wget
- vw_path = f"C:/Users/{getpass.getuser()}/AppData/Roaming/.vimeworld"
- def removeData():
- try:
- data = os.path.join(os.path.abspath(os.path.dirname(__file__)), f"{vw_path}/.data")
- shutil.rmtree(data)
- except FileNotFoundError:
- pass
- os.system("title Created by Helops - https://vk.com/id214066309")
- # Удаляем папку .data
- removeData()
- # Скачиваем архив с темой (.data)
- print("-> | Скачивание темы")
- try:
- wget.download("https://vimetheme.at.ua/themeV2.zip", f"{vw_path}/theme.zip")
- except urllib.error.URLError:
- print("-> | Ошибка при скачивании темы. Попробуйте ещё раз.")
- os.system("pause")
- raise SystemExit
- os.system("cls")
- print("-> | Тема скачана\n")
- print("-> | Установка темы")
- # Распаковываем скачаный архив
- theme = zipfile.ZipFile(f"{vw_path}/theme.zip", 'r')
- theme.extractall(vw_path)
- theme.close()
- # Удаляем архив
- try:
- theme_zip = os.path.join(os.path.abspath(os.path.dirname(__file__)), f"{vw_path}/theme.zip")
- os.remove(theme_zip)
- except FileNotFoundError:
- pass
- # Изменяем текущую тему в config
- try:
- with open(f"{vw_path}/config", "r") as file:
- text = file.read()
- textToLine = text.split("\n")
- except FileNotFoundError:
- print("-> | Не удалось найти файл config")
- removeData()
- os.system("pause")
- raise SystemExit
- themeLine = None
- for index in range(len(textToLine)):
- line = textToLine[index].split(":")
- if line[0] == "theme":
- themeLine = index
- if themeLine is None:
- print("-> | Не удалось найти параметр 'theme' в config")
- removeData()
- os.system("pause")
- raise SystemExit
- with open(f"{vw_path}/config", "w") as file:
- file.write(text.replace(textToLine[themeLine], "theme:discord"))
- print("-> | Тема установлена. Запустите VimeWorld.")
- os.system("pause")
- raise SystemExit
Add Comment
Please, Sign In to add comment