bcsfe-wrapper-python 0.1.15__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 CHANGED
@@ -7,7 +7,7 @@ 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.1.0"):
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)
@@ -21,38 +21,54 @@ class BCSFEWrapper:
21
21
  self.save_path = core.Path(save_path_or_data)
22
22
  self.save_file = core.SaveFile(self.save_path.read(), cc=self.cc, gv=self.gv)
23
23
  self.save_file.save_path = self.save_path
24
- else:
24
+ elif isinstance(save_path_or_data, bytes):
25
25
  self.save_file = core.SaveFile(core.Data(save_path_or_data), cc=self.cc, gv=self.gv)
26
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)
27
34
 
28
35
  def _init_core(self):
29
36
  data_folder = core.Path.get_data_folder()
30
37
  core.set_config_path(data_folder.add("config.yaml"))
31
38
  core.set_log_path(data_folder.add("log.txt"))
32
39
  core.core_data.init_data()
33
- core.core_data.config.set(core.ConfigKey.STRICT_UPGRADE, False)
34
- try:
35
- core.core_data.config.set(core.ConfigKey.UPDATE_TO_BETAS, False)
36
- except AttributeError:
37
- # 最新バージョンではUPDATE_TO_BETAに変更されている可能性がある
40
+
41
+ # 設定項目の安全な設定
42
+ def safe_set(key_name, value):
38
43
  try:
39
- core.core_data.config.set(core.ConfigKey.UPDATE_TO_BETA, False)
40
- except (AttributeError, ValueError):
44
+ if hasattr(core.ConfigKey, key_name):
45
+ core.core_data.config.set(getattr(core.ConfigKey, key_name), value)
46
+ except:
41
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
+
42
54
  core.print_config_err = False
43
55
 
44
56
  @classmethod
45
57
  def from_server(cls, transfer_code: str, confirmation_code: str, cc: str = "jp", gv: str = "13.4.0") -> 'BCSFEWrapper':
46
- # ダミーの初期化を回避
47
- wrapper = cls(b"", cc=cc, gv=gv)
58
+ # coreの初期化のみ行う
59
+ dummy = cls(None, cc=cc, gv=gv)
60
+ dummy._init_core()
61
+
48
62
  server_handler, result = core.ServerHandler.from_codes(
49
63
  transfer_code, confirmation_code, core.CountryCode.from_code(cc), core.GameVersion.from_string(gv), print=False
50
64
  )
51
65
  if server_handler is None:
52
66
  raise RuntimeError(f"Download failed: {result}")
53
67
 
54
- wrapper.save_file = server_handler.save_file
55
- return wrapper
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
56
72
 
57
73
  def save(self, output_path: Optional[str] = None):
58
74
  path = core.Path(output_path) if output_path else self.save_path
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bcsfe-wrapper-python
3
- Version: 0.1.15
3
+ Version: 0.1.16
4
4
  Summary: A Python wrapper for BCSFE-Python to easily interact with Battle Cats save files.
5
5
  Home-page: https://github.com/fieryhenry/BCSFE-Python
6
6
  Author: Manus AI
@@ -1,5 +1,5 @@
1
1
  bcsfe_wrapper/__init__.py,sha256=o2LbyVJjuRV1gap8wDbsv39kEUJM1rt8Lq49u1RYYXA,268
2
- bcsfe_wrapper/wrapper.py,sha256=JnN7UdZ0CA-l4pVhobIH7zAOkUqWO0cl30um-GAdyNg,9918
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.15.dist-info/METADATA,sha256=t_d1WGXr6Hs4fIPHMwkxVX3QziitNgOVsuws2mas5X8,4327
202
- bcsfe_wrapper_python-0.1.15.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
203
- bcsfe_wrapper_python-0.1.15.dist-info/top_level.txt,sha256=kqyMKpAdNg39_kGGtqsxOSLPIb-qx7R1mQj1hReUsYM,14
204
- bcsfe_wrapper_python-0.1.15.dist-info/RECORD,,
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,,