# Path: chirp/common/timestamp.py
# _TIMESTAMP_FORMAT = "%Y%m%d-%H%M%S"
# _PRETTY_FORMAT = "%c"
# PROCESS_START_TIME = time.time()  # time of importing this file
# _MIN_REASONABLE_TIMESTAMP = parse_human_readable("20081130-000000")
# _MAX_REASONABLE_TIMESTAMP = parse_human_readable("20380119-000000")
# _SECONDS_PER_MINUTE = 60
# _SECONDS_PER_HOUR = 60 * _SECONDS_PER_MINUTE
# _SECONDS_PER_DAY = 24 * _SECONDS_PER_HOUR
# def now():
# def now_ms():
# def process_start_time_ms():
# def process_age_ms():
# def get_human_readable(ts=None):
# def get_human_readable_ms(ms_ts):
# def get_pretty(ts=None):
# def get_pretty_ms(ms_ts):
# def parse_human_readable(human_readable_str):
# def is_valid(ts):
# def get_human_readable_duration(duration_s):
#     def _pluralize(n, unit):
# def get_human_readable_duration_ms(duration_ms):
# 
# 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/schema.py
# def audio_file_to_tuple(au_file):
# def tuple_to_audio_file(au_file_tuple):
# def id3_tag_to_tuple(fingerprint, timestamp, tag):


import sqlite3
import mutagen.id3
from chirp.common import timestamp
from chirp.library import audio_file
from chirp.library import schema
        Args:
          fingerprint: The audio file's fingerprint.

        Returns:
          An AudioFile object, or None if there is no file with the
          specified fingerprint.
        """
        sql = ("SELECT * FROM audio_files "
               " WHERE fingerprint=\"%s\"" % fingerprint)
        for au_file in _audio_file_generator(self._shared_conn, sql):
            return au_file
        return None

    def begin_add(self, volume, import_timestamp):
        """Begin a new transaction for adding files to the database.

        Args:
          volume: The volume identifier for the import associated with the
            transaction.
          import_timestamp: The timestamp of the import associated with
            the transaction.

        Returns:
          An _AddTransaction object.
        """
        conn = self._get_connection()
        return _AddTransaction(volume, import_timestamp, conn)

    def update(self, au_file, timestamp):
        conn = self._get_connection()

# Path: chirp/common/timestamp.py
# _TIMESTAMP_FORMAT = "%Y%m%d-%H%M%S"
# _PRETTY_FORMAT = "%c"
# PROCESS_START_TIME = time.time()  # time of importing this file
# _MIN_REASONABLE_TIMESTAMP = parse_human_readable("20081130-000000")
# _MAX_REASONABLE_TIMESTAMP = parse_human_readable("20380119-000000")
# _SECONDS_PER_MINUTE = 60
# _SECONDS_PER_HOUR = 60 * _SECONDS_PER_MINUTE
# _SECONDS_PER_DAY = 24 * _SECONDS_PER_HOUR
# def now():
# def now_ms():
# def process_start_time_ms():
# def process_age_ms():
# def get_human_readable(ts=None):
# def get_human_readable_ms(ms_ts):
# def get_pretty(ts=None):
# def get_pretty_ms(ms_ts):
# def parse_human_readable(human_readable_str):
# def is_valid(ts):
# def get_human_readable_duration(duration_s):
#     def _pluralize(n, unit):
# def get_human_readable_duration_ms(duration_ms):
# 
# 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/schema.py
# def audio_file_to_tuple(au_file):
# def tuple_to_audio_file(au_file_tuple):
# def id3_tag_to_tuple(fingerprint, timestamp, tag):


# Path: chirp/library/database.py
import sqlite3
import mutagen.id3
from chirp.common import timestamp
from chirp.library import audio_file
from chirp.library import schema

        Args:
          fingerprint: The audio file's fingerprint.

        Returns:
          An AudioFile object, or None if there is no file with the
          specified fingerprint.
        """
        sql = ("SELECT * FROM audio_files "
               " WHERE fingerprint=\"%s\"" % fingerprint)
        for au_file in _audio_file_generator(self._shared_conn, sql):
            return au_file
        return None

    def begin_add(self, volume, import_timestamp):
        """Begin a new transaction for adding files to the database.

        Args:
          volume: The volume identifier for the import associated with the
            transaction.
          import_timestamp: The timestamp of the import associated with
            the transaction.

        Returns:
          An _AddTransaction object.
        """
        conn = self._get_connection()
        return _AddTransaction(volume, import_timestamp, conn)

    def update(self, au_file, timestamp):
        conn = self._get_connection()

        _insert_tags(conn, au_file.fingerprint, timestamp, au_file.mutagen_id3)