# Path: chirp/library/artists.py
# _LIBRARY_DATA_PREFIX = os.path.join(ROOT_DIR, "library", "data")
# _WHITELIST_FILE = os.path.join(_LIBRARY_DATA_PREFIX, "artist-whitelist")
# _MAPPINGS_FILE = os.path.join(_LIBRARY_DATA_PREFIX, "artist-mappings")
# _MAPPINGS_SEP = u"\xbb\xbb\xbb"
# _BASE_SPLIT_PATTERN = (
#     r"\s*((feat\.?)|(ft\.)|(featuring)|(with)|(w/)|(and)|(&))"
#     r"\s+(?P<feat>.*)")
# _SPLIT_RES = [
#     re.compile(r"%s%s%s" % (a, _BASE_SPLIT_PATTERN, b), re.IGNORECASE)
#     for a, b in ((r"\(", r"\)"), (r"\[", r"\]"), ("", ""))]
#     MAX_DIST = 10
#     MAX_NORM_DIST = 0.25
# def all():
# def sort_key(artist_name):
# def _standardize_simple(artist_name, whitelist, mappings):
# def _standardize(artist_name, whitelist, mappings):
# def standardize(artist_name):
# def is_standardized(artist_name):
# def split(artist_name):
# def split_and_standardize(artist_name):
# def suggest(name):
# def _seq_to_whitelist(seq_of_names):
# def reset_artist_whitelist(seq_of_names):
# def _read_artist_whitelist_from_file(file_obj):
# def _read_artist_mappings_from_file(file_obj):
# def _init():
# def merge_whitelist_and_mappings(whitelist, raw_mappings):


import codecs
import cStringIO
import os
import sys
import unittest
from chirp.library import artists
        self.assertEqual(2, len(raw_mappings))

        # Check basic matching against the whitelist.
        for the_fall in ("fall", "fall, the", " the fall", "fall, the "):
            self.assertEqual(
                "The Fall",
                artists._standardize(the_fall, whitelist, mappings))
        self.assertEqual(
            "Bob Dylan",
            artists._standardize("dylan bob", whitelist, mappings))
        self.assertEqual(
            "Tom Petty & the Heartbreakers",
            artists._standardize("tom petty and his heartbreakers",
                                 whitelist, mappings))
        self.assertEqual(
            "John Lee Hooker",
            artists._standardize("john  lee hooker", whitelist, mappings))
        self.assertEqual(None,
                         artists._standardize("unknown", whitelist, mappings))

        # Check mappings.
        self.assertEqual(
            "John Lee Hooker",
            artists._standardize("john hooker", whitelist, mappings))
        self.assertEqual(
            "John Lee Hooker",
            artists._standardize("hooker, john", whitelist, mappings))

    def test_reset_fails_on_collisions(self):
        self.assertFalse(

# Path: chirp/library/artists.py
# _LIBRARY_DATA_PREFIX = os.path.join(ROOT_DIR, "library", "data")
# _WHITELIST_FILE = os.path.join(_LIBRARY_DATA_PREFIX, "artist-whitelist")
# _MAPPINGS_FILE = os.path.join(_LIBRARY_DATA_PREFIX, "artist-mappings")
# _MAPPINGS_SEP = u"\xbb\xbb\xbb"
# _BASE_SPLIT_PATTERN = (
#     r"\s*((feat\.?)|(ft\.)|(featuring)|(with)|(w/)|(and)|(&))"
#     r"\s+(?P<feat>.*)")
# _SPLIT_RES = [
#     re.compile(r"%s%s%s" % (a, _BASE_SPLIT_PATTERN, b), re.IGNORECASE)
#     for a, b in ((r"\(", r"\)"), (r"\[", r"\]"), ("", ""))]
#     MAX_DIST = 10
#     MAX_NORM_DIST = 0.25
# def all():
# def sort_key(artist_name):
# def _standardize_simple(artist_name, whitelist, mappings):
# def _standardize(artist_name, whitelist, mappings):
# def standardize(artist_name):
# def is_standardized(artist_name):
# def split(artist_name):
# def split_and_standardize(artist_name):
# def suggest(name):
# def _seq_to_whitelist(seq_of_names):
# def reset_artist_whitelist(seq_of_names):
# def _read_artist_whitelist_from_file(file_obj):
# def _read_artist_mappings_from_file(file_obj):
# def _init():
# def merge_whitelist_and_mappings(whitelist, raw_mappings):


# Path: chirp/library/artists_test.py
import codecs
import cStringIO
import os
import sys
import unittest
from chirp.library import artists

        self.assertEqual(2, len(raw_mappings))

        # Check basic matching against the whitelist.
        for the_fall in ("fall", "fall, the", " the fall", "fall, the "):
            self.assertEqual(
                "The Fall",
                artists._standardize(the_fall, whitelist, mappings))
        self.assertEqual(
            "Bob Dylan",
            artists._standardize("dylan bob", whitelist, mappings))
        self.assertEqual(
            "Tom Petty & the Heartbreakers",
            artists._standardize("tom petty and his heartbreakers",
                                 whitelist, mappings))
        self.assertEqual(
            "John Lee Hooker",
            artists._standardize("john  lee hooker", whitelist, mappings))
        self.assertEqual(None,
                         artists._standardize("unknown", whitelist, mappings))

        # Check mappings.
        self.assertEqual(
            "John Lee Hooker",
            artists._standardize("john hooker", whitelist, mappings))
        self.assertEqual(
            "John Lee Hooker",
            artists._standardize("hooker, john", whitelist, mappings))

    def test_reset_fails_on_collisions(self):
        self.assertFalse(

            artists.reset_artist_whitelist(["Fall", "The Fall"]))