Source code for Chemistry.exceptions.ParseErrors

# Copyright (c) 2014 Dan Obermiller
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# You should have received a copy of the MIT License along with this program.
# If not, see <http://opensource.org/licenses/MIT>


"""Specific exceptions and errors raised during the parsing of chemical data
files.  Deprecated, along with the entire Chemistry.parsing package.  Will be
removed once complete support of OpenBabel is achieved.
"""


[docs]class ParsingException(Exception): """A generic exception to be thrown if there is an error with the parsing of a chemical data file. Parameters ---------- filetype : string The type of file that was being parsed. msg : string, optional The error message. A default message is provided, however an actual message is encouraged. """ message = "An error occurred while parsing a {} file" def __init__(self, filetype, msg=message): self.filetype = filetype self.message = msg.format(self.filetype) def __str__(self): return self.message def __repr__(self): return str(self)
[docs]class UnsupportedFileTypeException(ParsingException): """Exception to be raised if a file is supplied for parsing that is not yet supported. Parameters ---------- msg : string The error message. filetype : string The filetype that is not currently supported. """ def __init__(self, msg, filetype): super(UnsupportedFileTypeException, self).__init__(filetype, msg)