# Path: pylsdj/kits.py
# class Kits(object):
#     """A wrapper for an LSDJ ROM's kits"""
# 
#     def __init__(self, rom_file):
#         """Load kits from the provided LSDJ ROM
# 
#         :param rom_file: path to the LSDJ ROM to load
#         """
#         with open(rom_file, 'rb') as fp:
#             self._data = b.parse(fp, lsdj_rom_kits)
# 
#         # Don't include the last four kits in the kit list, which are reserved
#         # for the speech synthesizer
#         self._kits = list(map(lambda k: Kit(k), self._data.kits[:-4]))
# 
#     def __getitem__(self, i):
#         return self._kits[i]
# 
#     def __str__(self):
#         return '\n'.join(map(str, self._kits))
# 
#     def __iter__(self):
#         for kit in self._kits:
#             yield kit
# 
# Path: pylsdj/utils.py
# def name_without_zeroes(name):
#     """
#     Return a human-readable name without LSDJ's trailing zeroes.
# 
#     :param name: the name from which to strip zeroes
#     :rtype: the name, without trailing zeroes
#     """
#     first_zero = name.find(b'\0')
# 
#     if first_zero == -1:
#         return name
#     else:
#         return str(name[:first_zero])


import os
import tempfile
from nose.tools import assert_equal, raises
from .kits import Kits
from .utils import name_without_zeroes
        b'CR8000',
        b'DR-55 ',
        b'DR-110',
        b'DRUMUL',
        b'DMX   ',
        b'KR-55 ',
        b'LINNDR',
        b'RHYACE',
        b'TOM   ',
        b'ACIEED',
        b'GHETTO'
    ]

    for i, kit in enumerate(expected_kit_names):
        assert_equal(expected_kit_names[i], kits[i].name)

    # As a spot-check, test that the TR-707's samples are what we expect
    tr707_sample_names = [
        b'BD1', b'SD1', b'CHH', b'OHH', b'HT-', b'MT-', b'LT-', b'CCY', b'RCY',
        b'BD2', b'SD2', b'RIM', b'COW', b'TAM', b'CLP'
    ]

    for i, sample_name in enumerate(tr707_sample_names):
        assert_equal(sample_name, kits[1].samples[i].name)


def test_load_save_sample():
    test_rom = os.path.join(os.path.dirname(__file__), "test_data",
                            "lsdj_onlykits.gb")


# Path: pylsdj/kits.py
# class Kits(object):
#     """A wrapper for an LSDJ ROM's kits"""
# 
#     def __init__(self, rom_file):
#         """Load kits from the provided LSDJ ROM
# 
#         :param rom_file: path to the LSDJ ROM to load
#         """
#         with open(rom_file, 'rb') as fp:
#             self._data = b.parse(fp, lsdj_rom_kits)
# 
#         # Don't include the last four kits in the kit list, which are reserved
#         # for the speech synthesizer
#         self._kits = list(map(lambda k: Kit(k), self._data.kits[:-4]))
# 
#     def __getitem__(self, i):
#         return self._kits[i]
# 
#     def __str__(self):
#         return '\n'.join(map(str, self._kits))
# 
#     def __iter__(self):
#         for kit in self._kits:
#             yield kit
# 
# Path: pylsdj/utils.py
# def name_without_zeroes(name):
#     """
#     Return a human-readable name without LSDJ's trailing zeroes.
# 
#     :param name: the name from which to strip zeroes
#     :rtype: the name, without trailing zeroes
#     """
#     first_zero = name.find(b'\0')
# 
#     if first_zero == -1:
#         return name
#     else:
#         return str(name[:first_zero])


# Path: pylsdj/test_kits.py
import os
import tempfile
from nose.tools import assert_equal, raises
from .kits import Kits
from .utils import name_without_zeroes

        b'CR8000',
        b'DR-55 ',
        b'DR-110',
        b'DRUMUL',
        b'DMX   ',
        b'KR-55 ',
        b'LINNDR',
        b'RHYACE',
        b'TOM   ',
        b'ACIEED',
        b'GHETTO'
    ]

    for i, kit in enumerate(expected_kit_names):
        assert_equal(expected_kit_names[i], kits[i].name)

    # As a spot-check, test that the TR-707's samples are what we expect
    tr707_sample_names = [
        b'BD1', b'SD1', b'CHH', b'OHH', b'HT-', b'MT-', b'LT-', b'CCY', b'RCY',
        b'BD2', b'SD2', b'RIM', b'COW', b'TAM', b'CLP'
    ]

    for i, sample_name in enumerate(tr707_sample_names):
        assert_equal(sample_name, kits[1].samples[i].name)


def test_load_save_sample():
    test_rom = os.path.join(os.path.dirname(__file__), "test_data",
                            "lsdj_onlykits.gb")


    kits = Kits(test_rom)