# Path: media_nommer/utils/logger.py
# def debug(message):
# def info(message):
# def warning(message):
# def error(message_or_obj=None):
# 
# Path: media_nommer/core/storage_backends/exceptions.py
# class InfileNotFoundException(StorageException):
#     """
#     Raised by storage backends when the given source_path (the media to encode)
#     cannot be found. 
#     """
#     pass
# 
# Path: media_nommer/core/storage_backends/base_backend.py
# class BaseStorageBackend(object):
#     """
#     This class serves as a protocol for storage backends. Each storage backend
#     should override the following methods, if supported by whatever protocols
#     they interact with.
#     """
#     @classmethod
#     def download_file(cls, uri, fobj):
#         """
#         Given a URI, download the file to the ``fobj`` file-like object.
# 
#         :param str uri: The URI of a file to download.
#         :param file fobj: A file-like object to download the file to.
#         :rtype: file
#         :returns: A file handle to the downloaded file.
#         """
#         msg = "Backend doesn't implement download_file()"
#         raise NotImplementedError(msg)
# 
#     @classmethod
#     def upload_file(cls, uri, fobj):
#         """
#         Given a file-like object, upload it to the specified URI.
# 
#         :param str uri: The URI to upload the file to.
#         :param file fobj: The file-like object to upload.
#         :returns: Return value and type depends on backend.
#         """
#         msg = "Backend doesn't implement upload_file()"
#         raise NotImplementedError(msg)


import os
import urlparse
import shutil
from media_nommer.utils import logger
from media_nommer.core.storage_backends.exceptions import InfileNotFoundException
from media_nommer.core.storage_backends.base_backend import BaseStorageBackend
            raise InfileNotFoundException(message)

        logger.debug("FileBackend.download_file(): " \
                     "Opening of %s completed." % uri)

        infile = open(infile_path, 'rb')
        # Inefficient, but meh. We'll come up with something more clever later.
        for line in infile:
            fobj.write(line)
        
        return fobj

    @classmethod
    def upload_file(cls, uri, fobj):
        """
        Given a file-like object, copy it to the user's specified
        destination path (locally). We have to copy, since the encoded
        file resides in a temporary file that is deleted once the file-like
        object is garbage collected.

        :param str uri: The URI to copy the finished encoding to.
        :param file fobj: The file-like object of the finished encoding.
        :rtype: str
        :returns: The path to the final destination for the encoding.
        """
        # This is the path to the temp file that the encoding was saved to.
        tempfile_path = fobj.name
        # This is the path of the eventual destination file.
        outfile_path = cls._get_path_from_uri(uri)


# Path: media_nommer/utils/logger.py
# def debug(message):
# def info(message):
# def warning(message):
# def error(message_or_obj=None):
# 
# Path: media_nommer/core/storage_backends/exceptions.py
# class InfileNotFoundException(StorageException):
#     """
#     Raised by storage backends when the given source_path (the media to encode)
#     cannot be found. 
#     """
#     pass
# 
# Path: media_nommer/core/storage_backends/base_backend.py
# class BaseStorageBackend(object):
#     """
#     This class serves as a protocol for storage backends. Each storage backend
#     should override the following methods, if supported by whatever protocols
#     they interact with.
#     """
#     @classmethod
#     def download_file(cls, uri, fobj):
#         """
#         Given a URI, download the file to the ``fobj`` file-like object.
# 
#         :param str uri: The URI of a file to download.
#         :param file fobj: A file-like object to download the file to.
#         :rtype: file
#         :returns: A file handle to the downloaded file.
#         """
#         msg = "Backend doesn't implement download_file()"
#         raise NotImplementedError(msg)
# 
#     @classmethod
#     def upload_file(cls, uri, fobj):
#         """
#         Given a file-like object, upload it to the specified URI.
# 
#         :param str uri: The URI to upload the file to.
#         :param file fobj: The file-like object to upload.
#         :returns: Return value and type depends on backend.
#         """
#         msg = "Backend doesn't implement upload_file()"
#         raise NotImplementedError(msg)


# Path: media_nommer/core/storage_backends/file.py
import os
import urlparse
import shutil
from media_nommer.utils import logger
from media_nommer.core.storage_backends.exceptions import InfileNotFoundException
from media_nommer.core.storage_backends.base_backend import BaseStorageBackend

            raise InfileNotFoundException(message)

        logger.debug("FileBackend.download_file(): " \
                     "Opening of %s completed." % uri)

        infile = open(infile_path, 'rb')
        # Inefficient, but meh. We'll come up with something more clever later.
        for line in infile:
            fobj.write(line)
        
        return fobj

    @classmethod
    def upload_file(cls, uri, fobj):
        """
        Given a file-like object, copy it to the user's specified
        destination path (locally). We have to copy, since the encoded
        file resides in a temporary file that is deleted once the file-like
        object is garbage collected.

        :param str uri: The URI to copy the finished encoding to.
        :param file fobj: The file-like object of the finished encoding.
        :rtype: str
        :returns: The path to the final destination for the encoding.
        """
        # This is the path to the temp file that the encoding was saved to.
        tempfile_path = fobj.name
        # This is the path of the eventual destination file.
        outfile_path = cls._get_path_from_uri(uri)


        logger.debug("FileBackend.upload_file(): "\