# Path: chirp/common/mp3_header.py
# STEREO = 0
# JOINT_STEREO = 1
# DUAL_MONO = 2
# MONO = 3
# _CHANNELS_TO_STR = {
#     STEREO: 'stereo',
#     JOINT_STEREO: 'joint_stereo',
#     DUAL_MONO: 'dual_mono',
#     MONO: 'mono',
#     None: None,
# }
# _PROTECTED_TABLE = (True, False)
# _BIT_RATE_KBPS_TABLE = (0, 32, 40, 48, 56, 64, 80, 96,
#                         112, 128, 160, 192, 224, 256, 320)
# _SAMPLING_RATE_HZ_TABLE = (44100, 48000, 32000)
# _PADDING_TABLE = (False, True)
# _SAMPLES_PER_FRAME = 1152
# def _match_eq(x, y):
#     def __init__(self, sampling_rate_hz=None, bit_rate_kbps=None,
#                  channels=None, protected=None, padding=None):
#     def is_complete(self):
#     def match(self, hdr):
#     def __str__(self):
# def parse(data, offset=0):
# def find(data, expected_hdr=None):
# def from_mutagen(mutagen_mp3):
# class MP3Header(object):
# 
# Path: chirp/library/audio_file.py
# class AudioFile(object):
#     def __eq__(self, other):
#         def _mutagen_id3_set(obj):
#     def has_ufid(self):
#     def ufid(self):
#     def ufid_tag(self):
#     def tpe1(self):
#     def talb(self):
#     def tit2(self):
#     def canonical_directory(self, prefix=""):
#     def canonical_filename(self):
#     def canonical_path(self, prefix=""):
# def _get_mp3(path):
# def _tag_to_int(au_file, tag_key):
# def scan_fast(path, _read_id3_hook=None):
# def scan(path, _read_id3_hook=None):
# 
# Path: chirp/library/audio_file_test.py
# TESTDATA = os.path.join(ROOT_DIR, "library/testdata/audio_file_test")
# TEST_VOL = 65
# TEST_TS = 1230430574
# TEST_FP = "7" * 40
# TEST_UFID = ufid.ufid(TEST_VOL, TEST_TS, TEST_FP)
# TEST_UFID_PREFIX = ufid.ufid_prefix(TEST_VOL, TEST_TS)
# def get_test_audio_file(n):
#     def test_basic(self):
#     def test_tag_accessors(self):
#     def test_scan_fast_tag_handling(self):
#     def test_scan_no_chirp_tags(self):
#     def test_scan_has_chirp_tags(self):
# class AudioFileTest(unittest.TestCase):
#         class MockInfo(object): pass
# 
# Path: chirp/library/nml_writer.py
# _UNKNOWN_ARTIST = "* Artist Not Known *"
# _UNKNOWN_ALBUM = "* Album Not Known *"
# _UNKNOWN_SONG = "* Title Not Known *"
# _NML_PREFIX = u"""<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
# <NML VERSION="14"><HEAD COMPANY="www.native-instruments.com" PROGRAM="Traktor - Native Instruments"></HEAD>
# <MUSICFOLDERS></MUSICFOLDERS>
# <COLLECTION ENTRIES="%10d">"""
# _NML_ENTRY = u"""<ENTRY MODIFIED_DATE=%(modified_date)s MODIFIED_TIME=%(modified_time)s TITLE=%(song)s ARTIST=%(artist)s><LOCATION DIR=%(dir)s FILE=%(file)s VOLUME=%(volume)s VOLUME_ID=""></LOCATION>
# <ALBUM OF_TRACKS=%(total_num)s TITLE=%(album)s TRACK=%(order_num)s></ALBUM>
# <INFO BITRATE=%(bitrate)s GENRE=%(genre)s PLAYTIME=%(duration_s)s IMPORT_DATE=%(import_date)s FILESIZE=%(size_in_kb)s></INFO>
# </ENTRY>
# """
# _NML_SUFFIX = u"""</COLLECTION>
# <PLAYLISTS><NODE TYPE="FOLDER" NAME="$ROOT"><SUBNODES COUNT="1">
# <NODE TYPE="PLAYLIST" NAME="_RECORDINGS"><PLAYLIST ENTRIES="0" TYPE="LIST"></PLAYLIST>
# </NODE>
# </SUBNODES>
# </NODE>
# </PLAYLISTS>
# </NML>
# """
# def _traktor_path_quote(path):
#     def __init__(self, file_volume, root_dir, out_fh):
#     def write(self, au_file):
#     def close(self):
# class NMLWriter(object):


import cStringIO
import unittest
import xml.dom.minidom
import mutagen.id3
from chirp.common import mp3_header
from chirp.library import audio_file
from chirp.library import audio_file_test
from chirp.library import nml_writer
#!/usr/bin/env python






class NMLWriterTest(unittest.TestCase):

    def assert_is_valid_xml(self, xml_str):
        xml.dom.minidom.parseString(xml_str)

    def test_empty(self):
        output = cStringIO.StringIO()
        writer = nml_writer.NMLWriter("test_file_volume", "/lib", output)
        writer.close()
        output_str = output.getvalue()
        self.assert_is_valid_xml(output_str)
        self.assertTrue("<COLLECTION ENTRIES=\"%10d\"" % 0 in output_str)

    def test_simple(self):
        output = cStringIO.StringIO()

# Path: chirp/common/mp3_header.py
# STEREO = 0
# JOINT_STEREO = 1
# DUAL_MONO = 2
# MONO = 3
# _CHANNELS_TO_STR = {
#     STEREO: 'stereo',
#     JOINT_STEREO: 'joint_stereo',
#     DUAL_MONO: 'dual_mono',
#     MONO: 'mono',
#     None: None,
# }
# _PROTECTED_TABLE = (True, False)
# _BIT_RATE_KBPS_TABLE = (0, 32, 40, 48, 56, 64, 80, 96,
#                         112, 128, 160, 192, 224, 256, 320)
# _SAMPLING_RATE_HZ_TABLE = (44100, 48000, 32000)
# _PADDING_TABLE = (False, True)
# _SAMPLES_PER_FRAME = 1152
# def _match_eq(x, y):
#     def __init__(self, sampling_rate_hz=None, bit_rate_kbps=None,
#                  channels=None, protected=None, padding=None):
#     def is_complete(self):
#     def match(self, hdr):
#     def __str__(self):
# def parse(data, offset=0):
# def find(data, expected_hdr=None):
# def from_mutagen(mutagen_mp3):
# class MP3Header(object):
# 
# Path: chirp/library/audio_file.py
# class AudioFile(object):
#     def __eq__(self, other):
#         def _mutagen_id3_set(obj):
#     def has_ufid(self):
#     def ufid(self):
#     def ufid_tag(self):
#     def tpe1(self):
#     def talb(self):
#     def tit2(self):
#     def canonical_directory(self, prefix=""):
#     def canonical_filename(self):
#     def canonical_path(self, prefix=""):
# def _get_mp3(path):
# def _tag_to_int(au_file, tag_key):
# def scan_fast(path, _read_id3_hook=None):
# def scan(path, _read_id3_hook=None):
# 
# Path: chirp/library/audio_file_test.py
# TESTDATA = os.path.join(ROOT_DIR, "library/testdata/audio_file_test")
# TEST_VOL = 65
# TEST_TS = 1230430574
# TEST_FP = "7" * 40
# TEST_UFID = ufid.ufid(TEST_VOL, TEST_TS, TEST_FP)
# TEST_UFID_PREFIX = ufid.ufid_prefix(TEST_VOL, TEST_TS)
# def get_test_audio_file(n):
#     def test_basic(self):
#     def test_tag_accessors(self):
#     def test_scan_fast_tag_handling(self):
#     def test_scan_no_chirp_tags(self):
#     def test_scan_has_chirp_tags(self):
# class AudioFileTest(unittest.TestCase):
#         class MockInfo(object): pass
# 
# Path: chirp/library/nml_writer.py
# _UNKNOWN_ARTIST = "* Artist Not Known *"
# _UNKNOWN_ALBUM = "* Album Not Known *"
# _UNKNOWN_SONG = "* Title Not Known *"
# _NML_PREFIX = u"""<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
# <NML VERSION="14"><HEAD COMPANY="www.native-instruments.com" PROGRAM="Traktor - Native Instruments"></HEAD>
# <MUSICFOLDERS></MUSICFOLDERS>
# <COLLECTION ENTRIES="%10d">"""
# _NML_ENTRY = u"""<ENTRY MODIFIED_DATE=%(modified_date)s MODIFIED_TIME=%(modified_time)s TITLE=%(song)s ARTIST=%(artist)s><LOCATION DIR=%(dir)s FILE=%(file)s VOLUME=%(volume)s VOLUME_ID=""></LOCATION>
# <ALBUM OF_TRACKS=%(total_num)s TITLE=%(album)s TRACK=%(order_num)s></ALBUM>
# <INFO BITRATE=%(bitrate)s GENRE=%(genre)s PLAYTIME=%(duration_s)s IMPORT_DATE=%(import_date)s FILESIZE=%(size_in_kb)s></INFO>
# </ENTRY>
# """
# _NML_SUFFIX = u"""</COLLECTION>
# <PLAYLISTS><NODE TYPE="FOLDER" NAME="$ROOT"><SUBNODES COUNT="1">
# <NODE TYPE="PLAYLIST" NAME="_RECORDINGS"><PLAYLIST ENTRIES="0" TYPE="LIST"></PLAYLIST>
# </NODE>
# </SUBNODES>
# </NODE>
# </PLAYLISTS>
# </NML>
# """
# def _traktor_path_quote(path):
#     def __init__(self, file_volume, root_dir, out_fh):
#     def write(self, au_file):
#     def close(self):
# class NMLWriter(object):


# Path: chirp/library/nml_writer_test.py
import cStringIO
import unittest
import xml.dom.minidom
import mutagen.id3
from chirp.common import mp3_header
from chirp.library import audio_file
from chirp.library import audio_file_test
from chirp.library import nml_writer

#!/usr/bin/env python






class NMLWriterTest(unittest.TestCase):

    def assert_is_valid_xml(self, xml_str):
        xml.dom.minidom.parseString(xml_str)

    def test_empty(self):
        output = cStringIO.StringIO()
        writer = nml_writer.NMLWriter("test_file_volume", "/lib", output)
        writer.close()
        output_str = output.getvalue()
        self.assert_is_valid_xml(output_str)
        self.assertTrue("<COLLECTION ENTRIES=\"%10d\"" % 0 in output_str)

    def test_simple(self):
        output = cStringIO.StringIO()

        writer = nml_writer.NMLWriter("test_file_volume", "/lib", output)