bcsfe-wrapper-python 0.1.14__py3-none-any.whl → 0.1.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bcsfe_wrapper/wrapper.py +38 -13
- {bcsfe_wrapper_python-0.1.14.dist-info → bcsfe_wrapper_python-0.1.16.dist-info}/METADATA +1 -1
- {bcsfe_wrapper_python-0.1.14.dist-info → bcsfe_wrapper_python-0.1.16.dist-info}/RECORD +5 -5
- {bcsfe_wrapper_python-0.1.14.dist-info → bcsfe_wrapper_python-0.1.16.dist-info}/WHEEL +0 -0
- {bcsfe_wrapper_python-0.1.14.dist-info → bcsfe_wrapper_python-0.1.16.dist-info}/top_level.txt +0 -0
bcsfe_wrapper/wrapper.py
CHANGED
|
@@ -7,43 +7,68 @@ from bcsfe import core
|
|
|
7
7
|
from bcsfe.cli import edits
|
|
8
8
|
|
|
9
9
|
class BCSFEWrapper:
|
|
10
|
-
def __init__(self, save_path_or_data: Union[str, bytes], cc: str = "jp", gv: str = "13.
|
|
10
|
+
def __init__(self, save_path_or_data: Union[str, bytes, core.Data], cc: str = "jp", gv: str = "13.4.0"):
|
|
11
11
|
self._init_core()
|
|
12
12
|
self.cc = core.CountryCode.from_code(cc)
|
|
13
13
|
self.gv = core.GameVersion.from_string(gv)
|
|
14
14
|
|
|
15
|
+
if not save_path_or_data:
|
|
16
|
+
self.save_path = None
|
|
17
|
+
self.save_file = None
|
|
18
|
+
return
|
|
19
|
+
|
|
15
20
|
if isinstance(save_path_or_data, str):
|
|
16
21
|
self.save_path = core.Path(save_path_or_data)
|
|
17
22
|
self.save_file = core.SaveFile(self.save_path.read(), cc=self.cc, gv=self.gv)
|
|
18
23
|
self.save_file.save_path = self.save_path
|
|
19
|
-
|
|
24
|
+
elif isinstance(save_path_or_data, bytes):
|
|
20
25
|
self.save_file = core.SaveFile(core.Data(save_path_or_data), cc=self.cc, gv=self.gv)
|
|
21
26
|
self.save_path = None
|
|
27
|
+
elif isinstance(save_path_or_data, core.Data):
|
|
28
|
+
self.save_file = core.SaveFile(save_path_or_data, cc=self.cc, gv=self.gv)
|
|
29
|
+
self.save_path = None
|
|
30
|
+
else:
|
|
31
|
+
# すでにSaveFileオブジェクトなどが渡された場合
|
|
32
|
+
self.save_file = save_path_or_data
|
|
33
|
+
self.save_path = getattr(save_path_or_data, "save_path", None)
|
|
22
34
|
|
|
23
35
|
def _init_core(self):
|
|
24
36
|
data_folder = core.Path.get_data_folder()
|
|
25
37
|
core.set_config_path(data_folder.add("config.yaml"))
|
|
26
38
|
core.set_log_path(data_folder.add("log.txt"))
|
|
27
39
|
core.core_data.init_data()
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
except AttributeError:
|
|
32
|
-
# 最新バージョンではUPDATE_TO_BETAに変更されている可能性がある
|
|
40
|
+
|
|
41
|
+
# 設定項目の安全な設定
|
|
42
|
+
def safe_set(key_name, value):
|
|
33
43
|
try:
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
if hasattr(core.ConfigKey, key_name):
|
|
45
|
+
core.core_data.config.set(getattr(core.ConfigKey, key_name), value)
|
|
46
|
+
except:
|
|
36
47
|
pass
|
|
48
|
+
|
|
49
|
+
safe_set("STRICT_UPGRADE", False)
|
|
50
|
+
safe_set("UPDATE_TO_BETAS", False)
|
|
51
|
+
safe_set("UPDATE_TO_BETA", False)
|
|
52
|
+
safe_set("SHOW_LOGS", False)
|
|
53
|
+
|
|
37
54
|
core.print_config_err = False
|
|
38
55
|
|
|
39
56
|
@classmethod
|
|
40
|
-
def from_server(cls, transfer_code: str, confirmation_code: str, cc: str = "jp", gv: str = "13.
|
|
41
|
-
|
|
57
|
+
def from_server(cls, transfer_code: str, confirmation_code: str, cc: str = "jp", gv: str = "13.4.0") -> 'BCSFEWrapper':
|
|
58
|
+
# coreの初期化のみ行う
|
|
59
|
+
dummy = cls(None, cc=cc, gv=gv)
|
|
60
|
+
dummy._init_core()
|
|
61
|
+
|
|
42
62
|
server_handler, result = core.ServerHandler.from_codes(
|
|
43
63
|
transfer_code, confirmation_code, core.CountryCode.from_code(cc), core.GameVersion.from_string(gv), print=False
|
|
44
64
|
)
|
|
45
|
-
if server_handler is None:
|
|
46
|
-
|
|
65
|
+
if server_handler is None:
|
|
66
|
+
raise RuntimeError(f"Download failed: {result}")
|
|
67
|
+
|
|
68
|
+
# ダウンロードしたデータから実体を生成
|
|
69
|
+
instance = cls(server_handler.save_file.to_data(), cc=cc, gv=gv)
|
|
70
|
+
instance.save_file = server_handler.save_file
|
|
71
|
+
return instance
|
|
47
72
|
|
|
48
73
|
def save(self, output_path: Optional[str] = None):
|
|
49
74
|
path = core.Path(output_path) if output_path else self.save_path
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
bcsfe_wrapper/__init__.py,sha256=o2LbyVJjuRV1gap8wDbsv39kEUJM1rt8Lq49u1RYYXA,268
|
|
2
|
-
bcsfe_wrapper/wrapper.py,sha256
|
|
2
|
+
bcsfe_wrapper/wrapper.py,sha256=-IVObsK-kElqXYEVuThJFZWZKadUi3hLKpilxb8HiNU,10532
|
|
3
3
|
bcsfe_wrapper/bcsfe/__init__.py,sha256=vCHjSoJq5u684HLQXahhtA64MZWffNHFdhweP7RM0f4,144
|
|
4
4
|
bcsfe_wrapper/bcsfe/__main__.py,sha256=Dam14Fv6L-tRRufIkIRpr69dM0b2ybU1eALJxIw_eFI,2091
|
|
5
5
|
bcsfe_wrapper/bcsfe/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -198,7 +198,7 @@ bcsfe_wrapper/bcsfe/files/locales/vi/edits/treasures.properties,sha256=U9uKsF4y0
|
|
|
198
198
|
bcsfe_wrapper/bcsfe/files/locales/vi/edits/user_rank.properties,sha256=FcldhzKM0UmuhmGzI3dGzxstuKcw-t-gkbmKLZT4VKg,603
|
|
199
199
|
bcsfe_wrapper/bcsfe/files/themes/default.json,sha256=w8eqqd9ATIFwUcvOWTdJjyd1T3LGgUm3iVkJhT5wfEo,392
|
|
200
200
|
bcsfe_wrapper/bcsfe/files/themes/discord.json,sha256=W1dtEev6tap_waHOxvSqENDcMRA9jfBvjW7t-ssdGs4,370
|
|
201
|
-
bcsfe_wrapper_python-0.1.
|
|
202
|
-
bcsfe_wrapper_python-0.1.
|
|
203
|
-
bcsfe_wrapper_python-0.1.
|
|
204
|
-
bcsfe_wrapper_python-0.1.
|
|
201
|
+
bcsfe_wrapper_python-0.1.16.dist-info/METADATA,sha256=a8UgOyJbKSzGwbOwbTvoA9SqD-hyVRUJNK_rVWL2fkI,4327
|
|
202
|
+
bcsfe_wrapper_python-0.1.16.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
203
|
+
bcsfe_wrapper_python-0.1.16.dist-info/top_level.txt,sha256=kqyMKpAdNg39_kGGtqsxOSLPIb-qx7R1mQj1hReUsYM,14
|
|
204
|
+
bcsfe_wrapper_python-0.1.16.dist-info/RECORD,,
|
|
File without changes
|
{bcsfe_wrapper_python-0.1.14.dist-info → bcsfe_wrapper_python-0.1.16.dist-info}/top_level.txt
RENAMED
|
File without changes
|