# Path: dput/exceptions.py
# class DscFileException(DputError):
#     """
#     Thrown when there's an error processing / verifying a .dsc file
#     (most often via the :class:`dput.changes.Dsc` object)
#     """
#     pass


import os
import os.path
from debian import deb822
from dput.exceptions import DscFileException
    """

    def __init__(self, filename=None, string=None):
        """
        Object constructor. The object allows the user to specify **either**:

        #. a path to a *changes* file to parse
        #. a string with the *changes* file contents.

        ::

        a = Dsc(filename='/tmp/packagename_version.changes')
        b = Dsc(string='Source: packagename\\nMaintainer: ...')

        ``filename``
            Path to *changes* file to parse.

        ``string``
            *dsc* file in a string to parse.
        """
        if (filename and string) or (not filename and not string):
            raise TypeError

        if filename:
            self._absfile = os.path.abspath(filename)
            self._data = deb822.Dsc(file(filename))
        else:
            self._data = deb822.Dsc(string)

        if len(self._data) == 0:

# Path: dput/exceptions.py
# class DscFileException(DputError):
#     """
#     Thrown when there's an error processing / verifying a .dsc file
#     (most often via the :class:`dput.changes.Dsc` object)
#     """
#     pass


# Path: dput/dsc.py
import os
import os.path
from debian import deb822
from dput.exceptions import DscFileException

    """

    def __init__(self, filename=None, string=None):
        """
        Object constructor. The object allows the user to specify **either**:

        #. a path to a *changes* file to parse
        #. a string with the *changes* file contents.

        ::

        a = Dsc(filename='/tmp/packagename_version.changes')
        b = Dsc(string='Source: packagename\\nMaintainer: ...')

        ``filename``
            Path to *changes* file to parse.

        ``string``
            *dsc* file in a string to parse.
        """
        if (filename and string) or (not filename and not string):
            raise TypeError

        if filename:
            self._absfile = os.path.abspath(filename)
            self._data = deb822.Dsc(file(filename))
        else:
            self._data = deb822.Dsc(string)

        if len(self._data) == 0:

            raise DscFileException('Changes file could not be parsed.')