# Path: onecodex/exceptions.py
# class OneCodexException(Exception):
#     pass
# 
# class UploadException(Exception):
#     """An exception for when things go wrong with uploading."""
# 
#     pass


import os
import re
import logging
from unidecode import unidecode
from onecodex.exceptions import OneCodexException, UploadException
        return "fasta"
    elif ext in {".fq", ".fastq"}:
        return "fastq"
    else:
        raise UploadException(
            "{}: extension must be one of .fa, .fna, .fasta, .fq, .fastq".format(file_path)
        )


class FilePassthru(object):
    """Wrapper around `file` object that updates a progress bar and guesses mime-type.

    Parameters
    ----------
    file_path : `string`
        Path to file.
    progressbar : `click.progressbar`, optional
        The progress bar to update.
    """

    def __init__(self, file_path, progressbar=None):
        self._fp = open(file_path, mode="rb")
        self._fsize = os.path.getsize(file_path)

        self.progressbar = progressbar

        _, ext = os.path.splitext(file_path)
        self.filename = os.path.basename(file_path)

        if self._fsize == 0:

# Path: onecodex/exceptions.py
# class OneCodexException(Exception):
#     pass
# 
# class UploadException(Exception):
#     """An exception for when things go wrong with uploading."""
# 
#     pass


# Path: onecodex/lib/files.py
import os
import re
import logging
from unidecode import unidecode
from onecodex.exceptions import OneCodexException, UploadException

        return "fasta"
    elif ext in {".fq", ".fastq"}:
        return "fastq"
    else:
        raise UploadException(
            "{}: extension must be one of .fa, .fna, .fasta, .fq, .fastq".format(file_path)
        )


class FilePassthru(object):
    """Wrapper around `file` object that updates a progress bar and guesses mime-type.

    Parameters
    ----------
    file_path : `string`
        Path to file.
    progressbar : `click.progressbar`, optional
        The progress bar to update.
    """

    def __init__(self, file_path, progressbar=None):
        self._fp = open(file_path, mode="rb")
        self._fsize = os.path.getsize(file_path)

        self.progressbar = progressbar

        _, ext = os.path.splitext(file_path)
        self.filename = os.path.basename(file_path)

        if self._fsize == 0:

            raise UploadException("{}: empty files can not be uploaded".format(self.filename))