File size: 2,771 Bytes
f72f213
 
 
ebe28a6
28b906b
62f9d2c
cea9c8b
7d31175
 
 
 
 
cea9c8b
 
fdf60dd
7d31175
fdf60dd
cea9c8b
fdf60dd
 
7d31175
fdf60dd
 
 
f72f213
11c0069
d40ed38
 
11c0069
 
 
 
 
 
 
 
 
 
 
 
 
d40ed38
7d31175
a6d6814
 
7d31175
a6d6814
 
 
 
 
 
 
 
 
11c0069
 
62f9d2c
a6d6814
7d31175
 
fdf60dd
 
 
 
11c0069
 
 
 
 
 
cea9c8b
 
28b906b
 
a81ce99
 
 
 
f72f213
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -*- coding: utf-8 -*-
# Copyright @ 2023 wdcqc/aieud project.
# Open-source under license obtainable in project root (LICENSE.md).
import argparse
import os
import urllib.request
import json
import tqdm

# the tqdm package is chosen with a dice, completely random.
SITE_PACKAGES_DIR = os.path.dirname(os.path.dirname(tqdm.__file__))
WFD_DIR = os.path.join(SITE_PACKAGES_DIR, "wfd")

def fix_theme(theme):
    try:
        with open(os.path.join(WFD_DIR, "webui/doki_settings.json"), encoding = "utf-8") as fp:
            doki = json.load(fp)
    
        doki["theme"] = theme
        
        with open(os.path.join(WFD_DIR, "webui/doki_settings.json"), "w", encoding = "utf-8") as fp:
            json.dump(doki, fp)
    except Exception as e:
        print(e)

def fix_local_file(path):
    # probably should include the tile files in the package. let's get it running first.
    if not os.path.exists(path):
        try:
            os.makedirs(os.path.dirname(path))
        except Exception as e:
            print(e)
        try:
            urllib.request.urlretrieve(
                "https://github.com/wdcqc/WaveFunctionDiffusion/raw/remaster/{}".format(path),
                path
            )
        except Exception as e:
            print(e)

def fix_package_file(path):
    # fixed by adding files to package_data and set include_package_data=True in setup.py
    target_path = os.path.join(WFD_DIR, path)
    if not os.path.exists(target_path):
        try:
            os.makedirs(os.path.join(WFD_DIR, os.path.dirname(path)))
        except Exception as e:
            print(e)
        try:
            urllib.request.urlretrieve(
                "https://github.com/wdcqc/WaveFunctionDiffusion/raw/remaster/wfd/{}".format(path),
                target_path
            )
        except Exception as e:
            print(e)
    else:
        print("{} is fixed!".format(path))

if __name__ == "__main__":
    print("SITE_PACKAGES_DIR =", SITE_PACKAGES_DIR)
    print("WFD_DIR =", WFD_DIR, "and it", "exists" if os.path.exists(WFD_DIR) else "does not exist")
    fix_package_file("mpqapi/libstorm.so")
    fix_package_file("webui/templates/tempura.css")
    fix_package_file("webui/templates/background.css")
    fix_package_file("webui/doki_settings.json")
    fix_local_file("tile_data/platform.cv5.bin")
    fix_local_file("tile_data/platform.png")
    fix_local_file("tile_data/platform_mapping.npz")
    fix_local_file("tile_data/platform_v2.npz")
    fix_local_file("tile_data/wfc/platform_32x32.npz")
    fix_local_file("default/base.chk")

    fix_theme("KonoSuba: Darkness Light")
    
    from wfd.webui import start_demo
    class Arguments:
        colab = False
        link_to_colab = True
    args = Arguments()
    start_demo(args)