-
Notifications
You must be signed in to change notification settings - Fork 3
/
delta_importexport.py
65 lines (56 loc) · 1.56 KB
/
delta_importexport.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import shutil
import os
import glob
import json
import sys
import tarfile
import zipfile
from delta_util import *
modfolder = "@ERROR@"
jarfolder = "@ERROR@"
execdir = "@ERROR@"
instance = "@ERROR@"
def init_config_importexport(data): #data is a 5-tuple
global modfolder, jarfolder, mc_version, execdir, instance, gui #makes it edit the global vars rather than create new ones
modfolder, jarfolder, mc_version, execdir, instance, gui = data
def recieve_tkinst_importexport(data):
global tkinst
tkinst = data
def export_mods(filename):
if (filename == None):
filename = cinput("What would you like your new modlist to be called?")
os.chdir(execdir)
os.chdir("LocalData/Modlists")
mods = []
if(os.path.exists(execdir + "/LocalData/ModsDownloaded/"+instance)):
mods = os.listdir(execdir + "/LocalData/ModsDownloaded/"+instance)
i = 0
for modtmp in mods:
cprint(modtmp)
modtmp = modtmp[:-10]
modtmp = '"' + modtmp + '"'
cprint(modtmp)
mods[i] = modtmp
i += 1
cprint('{ "Mods":' + json.dumps(mods) + "}")
f = open(filename + '.modlist', 'w')
f.write('{ "Mods":' + json.dumps(mods) + '}')
f.close()
cprint("Done! now in LocalData/Modlists.")
os.chdir(execdir)
else:
return
def import_mods(path):
if (path == None):
path = cinput("Please enter the path to the modlist.")
if(os.path.exists(path)): # Telling user that file exists
cprint(path + " found.")
else:
cprint(path + " not found.")
return
json_data = json.load(path)
mods = []
mods = json_data["Mods"]
for mod in mods:
cprint(mod)
delta_install.install_mod(mod)