# Path: chirp/common/printing.py
# class CustomPrint(object):
#     def __init__(self):
#     def __call__(self, message=None, **kwargs):
#     def default_write(self, message=None, **kwargs):
#     def use_write_function(self, func):
# 
# Path: chirp/library/album.py
# class AlbumError(Exception):
# class Album(object):
# def _compute_album_id(all_au_files):
# def _standardize_tags(all_au_files, new_album_name=None):
#     def __init__(self, all_au_files):
#     def _sort(self):
#     def standardize(self, new_album_name=None):
#     def set_volume_and_import_timestamp(self, vol, imp_ts):
#     def drop_payloads(self):
#     def ensure_payloads(self):
#     def title(self):
#     def tags(self):
#     def _get_tpe1_breakdown(self):
#     def is_compilation(self):
#     def artist_name(self):
#     def all_artist_names():
#     def import_timestamp(self):
#     def __str__(self):
# def from_directory(dirpath, fast=False):
# 
# 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/import_file.py
# class ImportFileError(Exception):
# def _fix_file_tags(au_file):
# def standardize_file(au_file):
# def write_file(au_file, prefix):
# 
# Path: chirp/library/ufid.py
# def ufid(volume, import_timestamp, fingerprint):
#     """Returns a full UFID string.
# 
#     Args:
#       volume: An integer volume number
#       import_timestamp: A integer timestamp
#       fingerprint: A string containing a fingerprint
# 
#     Returns:
#       A string containing a UFID.
#     """
#     return ufid_prefix(volume, import_timestamp) + fingerprint


import os
import sys
from chirp.common.printing import cprint
from chirp.library import album
from chirp.library import audio_file
from chirp.library import import_file
from chirp.library import ufid
        # Write the files to our temporary prefix.
        for au_file in alb.all_au_files:
            # Might raise an ImportFileError.
            if not self._dry_run:
                import_file.write_file(au_file, self._tmp_prefix)
        # We forget the payloads immediately to save RAM.
        alb.drop_payloads()

        # Everything checks out!
        self._all_au_files.extend(alb.all_au_files)
        self.num_albums += 1
        self.total_size_in_bytes += sum(
            au.frame_size for au in alb.all_au_files)

    def commit(self, target_prefix):
        if self._dry_run:
            return
        # Start a database transaction to add the files.
        txn = self._db.begin_add(self._volume, self._import_timestamp)
        # Write each new file into the database.
        for au_file in self._all_au_files:
            txn.add(au_file)
        ufid_prefix = ufid.ufid_prefix(self._volume, self._import_timestamp)
        # Strip off trailing "/"
        if ufid_prefix.endswith("/"):
            ufid_prefix = ufid_prefix[:-1]
        tmp_dir = os.path.join(self._tmp_prefix, ufid_prefix)
        real_dir = os.path.join(target_prefix, ufid_prefix)
        cprint("*** Committing %d albums / %d bytes" % (
            self.num_albums, self.total_size_in_bytes))

# Path: chirp/common/printing.py
# class CustomPrint(object):
#     def __init__(self):
#     def __call__(self, message=None, **kwargs):
#     def default_write(self, message=None, **kwargs):
#     def use_write_function(self, func):
# 
# Path: chirp/library/album.py
# class AlbumError(Exception):
# class Album(object):
# def _compute_album_id(all_au_files):
# def _standardize_tags(all_au_files, new_album_name=None):
#     def __init__(self, all_au_files):
#     def _sort(self):
#     def standardize(self, new_album_name=None):
#     def set_volume_and_import_timestamp(self, vol, imp_ts):
#     def drop_payloads(self):
#     def ensure_payloads(self):
#     def title(self):
#     def tags(self):
#     def _get_tpe1_breakdown(self):
#     def is_compilation(self):
#     def artist_name(self):
#     def all_artist_names():
#     def import_timestamp(self):
#     def __str__(self):
# def from_directory(dirpath, fast=False):
# 
# 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/import_file.py
# class ImportFileError(Exception):
# def _fix_file_tags(au_file):
# def standardize_file(au_file):
# def write_file(au_file, prefix):
# 
# Path: chirp/library/ufid.py
# def ufid(volume, import_timestamp, fingerprint):
#     """Returns a full UFID string.
# 
#     Args:
#       volume: An integer volume number
#       import_timestamp: A integer timestamp
#       fingerprint: A string containing a fingerprint
# 
#     Returns:
#       A string containing a UFID.
#     """
#     return ufid_prefix(volume, import_timestamp) + fingerprint


# Path: chirp/library/import_transaction.py
import os
import sys
from chirp.common.printing import cprint
from chirp.library import album
from chirp.library import audio_file
from chirp.library import import_file
from chirp.library import ufid

        # Write the files to our temporary prefix.
        for au_file in alb.all_au_files:
            # Might raise an ImportFileError.
            if not self._dry_run:
                import_file.write_file(au_file, self._tmp_prefix)
        # We forget the payloads immediately to save RAM.
        alb.drop_payloads()

        # Everything checks out!
        self._all_au_files.extend(alb.all_au_files)
        self.num_albums += 1
        self.total_size_in_bytes += sum(
            au.frame_size for au in alb.all_au_files)

    def commit(self, target_prefix):
        if self._dry_run:
            return
        # Start a database transaction to add the files.
        txn = self._db.begin_add(self._volume, self._import_timestamp)
        # Write each new file into the database.
        for au_file in self._all_au_files:
            txn.add(au_file)
        ufid_prefix = ufid.ufid_prefix(self._volume, self._import_timestamp)
        # Strip off trailing "/"
        if ufid_prefix.endswith("/"):
            ufid_prefix = ufid_prefix[:-1]
        tmp_dir = os.path.join(self._tmp_prefix, ufid_prefix)
        real_dir = os.path.join(target_prefix, ufid_prefix)
        cprint("*** Committing %d albums / %d bytes" % (
            self.num_albums, self.total_size_in_bytes))

        cprint("*** tmp_dir=%s" % tmp_dir)