def test_using_rom_str(self, _, file):
     # This test assumes the Python STR model works!
     # This can only test basic consistency.
     from skytemple_files.data.str.model import Str
     for by in Str.internal__get_all_raw_strings_from(file):
         self.assertEqual(
             by, self.handler.serialize(self.handler.deserialize(by)))
Exemplo n.º 2
0
def replace_text_main(string_file: Str, replace_map: Dict[str, str], start_idx,
                      end_idx):
    new_strings = []
    for idx, string in enumerate(string_file.strings):
        if idx < start_idx or idx > end_idx:
            new_strings.append(replace_strings(string, replace_map))
        else:
            new_strings.append(string)
    string_file.strings = new_strings
Exemplo n.º 3
0
 def serialize(cls, data: Str) -> bytes:
     return data.to_bytes()
Exemplo n.º 4
0
 def deserialize(cls, data: bytes, **kwargs) -> Str:
     return Str(data)
Exemplo n.º 5
0
 def serialize(cls, data: Str, **kwargs: OptionalKwargs) -> bytes:
     return data.to_bytes()
Exemplo n.º 6
0
 def deserialize(cls,
                 data: bytes,
                 *,
                 string_encoding: str = PMD2_STR_ENCODER,
                 **kwargs: OptionalKwargs) -> Str:  # type: ignore
     return Str(data, string_encoding)