# This file was automatically generated by SWIG (https://www.swig.org).
# Version 4.1.1
#
# Do not make changes to this file unless you know what you are doing - modify
# the SWIG interface file instead.

from sys import version_info as _swig_python_version_info
# Import the low-level C/C++ module
if __package__ or "." in __name__:
    from . import _ooferror
else:
    import _ooferror

try:
    import builtins as __builtin__
except ImportError:
    import __builtin__

def _swig_repr(self):
    try:
        strthis = "proxy of " + self.this.__repr__()
    except __builtin__.Exception:
        strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)


def _swig_setattr_nondynamic_instance_variable(set):
    def set_instance_attr(self, name, value):
        if name == "this":
            set(self, name, value)
        elif name == "thisown":
            self.this.own(value)
        elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
            set(self, name, value)
        else:
            raise AttributeError("You cannot add instance attributes to %s" % self)
    return set_instance_attr


def _swig_setattr_nondynamic_class_variable(set):
    def set_class_attr(cls, name, value):
        if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
            set(cls, name, value)
        else:
            raise AttributeError("You cannot add class attributes to %s" % cls)
    return set_class_attr


def _swig_add_metaclass(metaclass):
    """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
    def wrapper(cls):
        return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
    return wrapper


class _SwigNonDynamicMeta(type):
    """Meta class to enforce nondynamic attributes (no new attributes) for a class"""
    __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)



from ooflib.common import ooferrorwrappers


def pyErrorInit(pythonCallable):
    return _ooferror.pyErrorInit(pythonCallable)
class ErrError(object):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr

    def summary(self):
        return _ooferror.ErrError_summary(self)

    def details(self):
        return _ooferror.ErrError_details(self)
    __swig_destroy__ = _ooferror.delete_ErrError

# Register ErrError in _ooferror:
_ooferror.ErrError_swigregister(ErrError)

  # Does this work?
ErrError.__str__ = ErrError.__repr__

class ErrProgrammingError(ErrError):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, msg, file, l):
        _ooferror.ErrProgrammingError_swiginit(self, _ooferror.new_ErrProgrammingError(msg, file, l))

    def filename(self):
        return _ooferror.ErrProgrammingError_filename(self)

    def lineno(self):
        return _ooferror.ErrProgrammingError_lineno(self)
    __swig_destroy__ = _ooferror.delete_ErrProgrammingError

    def __repr__(self):
        return _ooferror.ErrProgrammingError___repr__(self)

# Register ErrProgrammingError in _ooferror:
_ooferror.ErrProgrammingError_swigregister(ErrProgrammingError)


class PyErrProgrammingError(ooferrorwrappers.PyOOFError):
  def __init__(self, *args, **kwargs):
    self.cexcept = kwargs.get("cexcept", None)
    if self.cexcept is None:
      self.cexcept = ErrProgrammingError(*args, **kwargs)
  def __getattr__(self, attr):
    return getattr(self.cexcept, attr)
  def __repr__(self):
    return self.cexcept.summary()
  def __str__(self):
    return self.cexcept.summary()
ooferrorwrappers.pyErrorWrappers[ErrProgrammingError] = PyErrProgrammingError

class ErrPyProgrammingError(ErrError):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2, arg3, arg4):
        _ooferror.ErrPyProgrammingError_swiginit(self, _ooferror.new_ErrPyProgrammingError(arg2, arg3, arg4))
    __swig_destroy__ = _ooferror.delete_ErrPyProgrammingError

    def __repr__(self):
        return _ooferror.ErrPyProgrammingError___repr__(self)

# Register ErrPyProgrammingError in _ooferror:
_ooferror.ErrPyProgrammingError_swigregister(ErrPyProgrammingError)


class PyErrPyProgrammingError(ooferrorwrappers.PyOOFError):
  def __init__(self, *args, **kwargs):
    self.cexcept = kwargs.get("cexcept", None)
    if self.cexcept is None:
      self.cexcept = ErrPyProgrammingError(*args, **kwargs)
  def __getattr__(self, attr):
    return getattr(self.cexcept, attr)
  def __repr__(self):
    return self.cexcept.summary()
  def __str__(self):
    return self.cexcept.summary()
ooferrorwrappers.pyErrorWrappers[ErrPyProgrammingError] = PyErrPyProgrammingError


  # Monkeypatch the __init__ so that line number and file
  # are inserted automatically.
oldinit = PyErrPyProgrammingError.__init__
def PyErrPyProgrammingError_init(self, msg):
  stack = traceback.extract_stack()
  (phile, lineno, func, txt) = stack[-2]
  oldinit(self, msg, phile, lineno)
PyErrPyProgrammingError.__init__ = PyErrPyProgrammingError_init

class ErrResourceShortage(ErrError):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, m):
        _ooferror.ErrResourceShortage_swiginit(self, _ooferror.new_ErrResourceShortage(m))
    __swig_destroy__ = _ooferror.delete_ErrResourceShortage

    def __repr__(self):
        return _ooferror.ErrResourceShortage___repr__(self)

# Register ErrResourceShortage in _ooferror:
_ooferror.ErrResourceShortage_swigregister(ErrResourceShortage)


class PyErrResourceShortage(ooferrorwrappers.PyOOFError):
  def __init__(self, *args, **kwargs):
    self.cexcept = kwargs.get("cexcept", None)
    if self.cexcept is None:
      self.cexcept = ErrResourceShortage(*args, **kwargs)
  def __getattr__(self, attr):
    return getattr(self.cexcept, attr)
  def __repr__(self):
    return self.cexcept.summary()
  def __str__(self):
    return self.cexcept.summary()
ooferrorwrappers.pyErrorWrappers[ErrResourceShortage] = PyErrResourceShortage

class ErrBoundsError(ErrError):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, m):
        _ooferror.ErrBoundsError_swiginit(self, _ooferror.new_ErrBoundsError(m))
    __swig_destroy__ = _ooferror.delete_ErrBoundsError

    def __repr__(self):
        return _ooferror.ErrBoundsError___repr__(self)

# Register ErrBoundsError in _ooferror:
_ooferror.ErrBoundsError_swigregister(ErrBoundsError)


class PyErrBoundsError(ooferrorwrappers.PyOOFError):
  def __init__(self, *args, **kwargs):
    self.cexcept = kwargs.get("cexcept", None)
    if self.cexcept is None:
      self.cexcept = ErrBoundsError(*args, **kwargs)
  def __getattr__(self, attr):
    return getattr(self.cexcept, attr)
  def __repr__(self):
    return self.cexcept.summary()
  def __str__(self):
    return self.cexcept.summary()
ooferrorwrappers.pyErrorWrappers[ErrBoundsError] = PyErrBoundsError

class ErrBadIndex(ErrError):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2, arg3, arg4):
        _ooferror.ErrBadIndex_swiginit(self, _ooferror.new_ErrBadIndex(arg2, arg3, arg4))
    __swig_destroy__ = _ooferror.delete_ErrBadIndex

    def __repr__(self):
        return _ooferror.ErrBadIndex___repr__(self)

# Register ErrBadIndex in _ooferror:
_ooferror.ErrBadIndex_swigregister(ErrBadIndex)


class PyErrBadIndex(ooferrorwrappers.PyOOFError):
  def __init__(self, *args, **kwargs):
    self.cexcept = kwargs.get("cexcept", None)
    if self.cexcept is None:
      self.cexcept = ErrBadIndex(*args, **kwargs)
  def __getattr__(self, attr):
    return getattr(self.cexcept, attr)
  def __repr__(self):
    return self.cexcept.summary()
  def __str__(self):
    return self.cexcept.summary()
ooferrorwrappers.pyErrorWrappers[ErrBadIndex] = PyErrBadIndex

class ErrUserError(ErrError):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2):
        _ooferror.ErrUserError_swiginit(self, _ooferror.new_ErrUserError(arg2))
    __swig_destroy__ = _ooferror.delete_ErrUserError

    def __repr__(self):
        return _ooferror.ErrUserError___repr__(self)

# Register ErrUserError in _ooferror:
_ooferror.ErrUserError_swigregister(ErrUserError)


class PyErrUserError(ooferrorwrappers.PyOOFError):
  def __init__(self, *args, **kwargs):
    self.cexcept = kwargs.get("cexcept", None)
    if self.cexcept is None:
      self.cexcept = ErrUserError(*args, **kwargs)
  def __getattr__(self, attr):
    return getattr(self.cexcept, attr)
  def __repr__(self):
    return self.cexcept.summary()
  def __str__(self):
    return self.cexcept.summary()
ooferrorwrappers.pyErrorWrappers[ErrUserError] = PyErrUserError

class ErrSetupError(ErrError):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2):
        _ooferror.ErrSetupError_swiginit(self, _ooferror.new_ErrSetupError(arg2))
    __swig_destroy__ = _ooferror.delete_ErrSetupError

    def __repr__(self):
        return _ooferror.ErrSetupError___repr__(self)

# Register ErrSetupError in _ooferror:
_ooferror.ErrSetupError_swigregister(ErrSetupError)


class PyErrSetupError(ooferrorwrappers.PyOOFError):
  def __init__(self, *args, **kwargs):
    self.cexcept = kwargs.get("cexcept", None)
    if self.cexcept is None:
      self.cexcept = ErrSetupError(*args, **kwargs)
  def __getattr__(self, attr):
    return getattr(self.cexcept, attr)
  def __repr__(self):
    return self.cexcept.summary()
  def __str__(self):
    return self.cexcept.summary()
ooferrorwrappers.pyErrorWrappers[ErrSetupError] = PyErrSetupError

class ErrInterrupted(ErrError):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self):
        _ooferror.ErrInterrupted_swiginit(self, _ooferror.new_ErrInterrupted())
    __swig_destroy__ = _ooferror.delete_ErrInterrupted

    def __repr__(self):
        return _ooferror.ErrInterrupted___repr__(self)

# Register ErrInterrupted in _ooferror:
_ooferror.ErrInterrupted_swigregister(ErrInterrupted)


class PyErrInterrupted(ooferrorwrappers.PyOOFError):
  def __init__(self, *args, **kwargs):
    self.cexcept = kwargs.get("cexcept", None)
    if self.cexcept is None:
      self.cexcept = ErrInterrupted(*args, **kwargs)
  def __getattr__(self, attr):
    return getattr(self.cexcept, attr)
  def __repr__(self):
    return self.cexcept.summary()
  def __str__(self):
    return self.cexcept.summary()
ooferrorwrappers.pyErrorWrappers[ErrInterrupted] = PyErrInterrupted

class ErrNoProgress(ErrError):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self):
        _ooferror.ErrNoProgress_swiginit(self, _ooferror.new_ErrNoProgress())
    __swig_destroy__ = _ooferror.delete_ErrNoProgress

    def __repr__(self):
        return _ooferror.ErrNoProgress___repr__(self)

# Register ErrNoProgress in _ooferror:
_ooferror.ErrNoProgress_swigregister(ErrNoProgress)


class PyErrNoProgress(ooferrorwrappers.PyOOFError):
  def __init__(self, *args, **kwargs):
    self.cexcept = kwargs.get("cexcept", None)
    if self.cexcept is None:
      self.cexcept = ErrNoProgress(*args, **kwargs)
  def __getattr__(self, attr):
    return getattr(self.cexcept, attr)
  def __repr__(self):
    return self.cexcept.summary()
  def __str__(self):
    return self.cexcept.summary()
ooferrorwrappers.pyErrorWrappers[ErrNoProgress] = PyErrNoProgress

class ErrDataFileError(ErrError):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2):
        _ooferror.ErrDataFileError_swiginit(self, _ooferror.new_ErrDataFileError(arg2))
    __swig_destroy__ = _ooferror.delete_ErrDataFileError

    def __repr__(self):
        return _ooferror.ErrDataFileError___repr__(self)

# Register ErrDataFileError in _ooferror:
_ooferror.ErrDataFileError_swigregister(ErrDataFileError)


class PyErrDataFileError(ooferrorwrappers.PyOOFError):
  def __init__(self, *args, **kwargs):
    self.cexcept = kwargs.get("cexcept", None)
    if self.cexcept is None:
      self.cexcept = ErrDataFileError(*args, **kwargs)
  def __getattr__(self, attr):
    return getattr(self.cexcept, attr)
  def __repr__(self):
    return self.cexcept.summary()
  def __str__(self):
    return self.cexcept.summary()
ooferrorwrappers.pyErrorWrappers[ErrDataFileError] = PyErrDataFileError

class ErrWarning(ErrError):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2):
        _ooferror.ErrWarning_swiginit(self, _ooferror.new_ErrWarning(arg2))
    __swig_destroy__ = _ooferror.delete_ErrWarning

    def __repr__(self):
        return _ooferror.ErrWarning___repr__(self)

# Register ErrWarning in _ooferror:
_ooferror.ErrWarning_swigregister(ErrWarning)


class PyErrWarning(ooferrorwrappers.PyOOFError):
  def __init__(self, *args, **kwargs):
    self.cexcept = kwargs.get("cexcept", None)
    if self.cexcept is None:
      self.cexcept = ErrWarning(*args, **kwargs)
  def __getattr__(self, attr):
    return getattr(self.cexcept, attr)
  def __repr__(self):
    return self.cexcept.summary()
  def __str__(self):
    return self.cexcept.summary()
ooferrorwrappers.pyErrorWrappers[ErrWarning] = PyErrWarning

# -*- python -*-

# This software was produced by NIST, an agency of the U.S. government,
# and by statute is not subject to copyright in the United States.
# Recipients of this software assume all responsibilities associated
# with its operation, modification and maintenance. However, to
# facilitate maintenance we ask that before distributing modified
# versions of this software, you first contact the authors at
# oof_manager@nist.gov. 

from ooflib.common import debug

import traceback


# Set up the callback that converts C++ exceptions to Python
# exceptions.  This is done when this module is imported, which
# guarantees that the callback will be in place before any high-level
# calls from "pure Python" happen.

# The %exception typemap swigs the C++ error (via pythonexportable)
# and passes it to pyErrorCallback (aka ErrError::pyconverter).
# pyErrorCallback raises the Python version of the error, which is a
# wrapper around the swigged object.  The wrapper class is created
# automatically from the C++ class by the WRAP_OOFERROR_CLASS swig
# macro in ooferror.swg.

# The wrapper is required because Python exceptions must be derived
# from Exception, which cexcept is not.  For each swigged C++
# exception type, ERR, pyErrorWrappers contains a python class named
# pyERR derived from Exception, and which contains a swigged C++
# exception.

from ooflib.common import ooferrorwrappers
PyOOFError = ooferrorwrappers.PyOOFError

def pyErrorCallback(cexcept):
    raise ooferrorwrappers.pyErrorWrappers[cexcept.__class__](cexcept=cexcept)

pyErrorInit(pyErrorCallback)



