def test_enum_string(self): """Test function dqutils.dq3.enum_string.""" testdata = tuple(enum_string(0x100, 0x110)) self.assertEqual(testdata[0][0], 0xFED659) self.assertTrue('せいすい' in get_text( testdata[0][1], CONTEXT["charmap"], CONTEXT["delimiters"])) self.assertEqual(testdata[15][0], 0xFED6CA) self.assertTrue('にじのしずく' in get_text( testdata[15][1], CONTEXT["charmap"], CONTEXT["delimiters"]))
def test_enum_string(self): """Test function dqutils.dq6.enum_string.""" testdata = tuple(enum_string(0x300, 0x310)) self.assertEqual(testdata[0][0], 0xFB97DB) self.assertTrue('ムドー' in get_text( testdata[0][1], CONTEXT["charmap"], CONTEXT["delimiters"])) self.assertEqual(testdata[15][0], 0xFB9835) self.assertTrue('デュラン' in get_text( testdata[15][1], CONTEXT["charmap"], CONTEXT["delimiters"]))
def print_scenario(context, generator_t, first=None, last=None): """Print message data to sys.stdout. Message data that indices in [`first`, `last`) will be output. Args: context: TBW generator_t: The type of message generator. See the module dqutils.message_generator for details. first: The first index of the range you want. last: The last index + 1 of the range you want. Returns: None. """ charmap = context["charmap"] assert charmap is None or isinstance(charmap, dict) delims = context["delimiters"] assert delims is None or isinstance(delims, array) for i, item in enumerate(enum_scenario(context, generator_t, first, last)): address, shift, code_seq = item text = get_text(code_seq, charmap, delims) print("{index:04X}:{address:06X}:{shift:02X}:{message}".format( index=i, address=address, shift=shift, message=text))
def print_battle(context, first=None, last=None): """Print message data to sys.stdout. Message data that indices in [`first`, `last`) will be output. Args: context: TBW first: The first index of the range you want. last: The last index + 1 of the range you want. Returns: None. """ # Test preconditions. charmap = context["charmap"] assert charmap is None or isinstance(charmap, dict) delims = context["delimiters"] assert delims is None or isinstance(delims, bytes) for i, item in enumerate(enum_battle(context, first, last)): if charmap: text = get_text(item[1], charmap, delims) else: text = get_hex(item[1]) print("{index:04X}:{address:06X}:{message}".format( index=i, address=item[0], message=text))
def test_get_text(self): """Test function dqutils.dq3.get_text.""" text = get_text( b"\x26\x24\x12\x24\xDC\x0E\xAC", CONTEXT["charmap"], CONTEXT["delimiters"]) self.assertTrue('ひのきのぼう' in text)
def test_make_text(self): """Test function dqutils.dq5.charmapsmall.process_dakuten.""" context = CONTEXT_GROUP[5] charmap = context["charmap"] text = process_dakuten(get_text(self.hinokinobou, charmap, None)) self.assertEqual(text, 'ひのきのぼう')
def print_all(): """Print all of the strings in DQ5 to sys.stdout.""" for i, context in enumerate(CONTEXT_GROUP): print('Group #{0:d}'.format(i)) charmap = context["charmap"] assert charmap is None or isinstance(charmap, dict) for j, item in enumerate(StringGeneratorPascalStyle(context)): text = process_dakuten(get_text(item[1], charmap, None)) print('{index:04X}:{address:06X}:{data}'.format( index=j, address=item[0], data=text))
def print_all_battle(): """Print message data to sys.stdout.""" context = CONTEXT_MESSAGE_BATTLE first = context["message_id_first"] last = context["message_id_last"] assert first < last charmap = context["charmap"] assert charmap is None or isinstance(charmap, dict) delims = context["delimiters"] assert delims is None or isinstance(delims, array) for i, item in enumerate(enum_battle(first, last)): address, shift, code_seq = item text = process_dakuten(get_text(code_seq, charmap, delims)) print("{index:04X}:{address:06X}:{shift:02X}:{message}".format( index=i, address=address, shift=shift, message=text))