-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoReplace.py
34 lines (28 loc) · 998 Bytes
/
autoReplace.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import tempfile
import shutil
import urllib.request
temp_dir = tempfile.gettempdir()
base_path = os.path.join(temp_dir, "ODG")
zip_path = os.path.join(base_path, "OpenDotaGuides.zip")
temp_dump_path = os.path.join(base_path, "temp")
os.makedirs(base_path, exist_ok=True)
try:
with open("itembuilddir.txt", "r") as file:
itembuilds_dir = os.path.normpath(file.readline())
except:
itembuilds_dir_input = input("Write your itembuild dir:\n")
itembuils_dir = itembuilds_dir_input
with open("itembuilddir.txt", "w") as file:
file.write(itembuilds_dir_input)
urllib.request.urlretrieve(
"https://github.com/Egezenn/OpenDotaGuides/releases/latest/download/itembuilds.zip",
zip_path,
)
shutil.unpack_archive(zip_path, temp_dump_path, "zip")
for file in os.listdir(temp_dump_path):
shutil.copy(
os.path.join(temp_dump_path, file),
os.path.join(itembuilds_dir, file),
)
shutil.rmtree(base_path)