Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# pylint: disable=missing-docstring
#
# Custom exception types used throughout the library. All exceptions derive
# from GMTError.
class GMTError(Exception):
"""
Base class for all GMT related errors.
"""
class GMTOSError(GMTError):
"""
Unsupported operating system.
"""
class GMTCLibError(GMTError):
"""
Error encountered when running a function from the GMT shared library.
"""
class GMTCLibNotFoundError(GMTCLibError):
"""
Could not find the GMT shared library.
"""
"""
class GMTCLibNotFoundError(GMTCLibError):
"""
Could not find the GMT shared library.
"""
class GMTCLibNoSessionError(GMTCLibError):
"""
Tried to access GMT API without a currently open GMT session.
"""
class GMTInvalidInput(GMTError):
"""
Raised when the input of a function/method is invalid.
"""
class GMTVersionError(GMTError):
"""
Raised when an incompatible version of GMT is being used.
# Module level variable to know which figures had their show method
# called. Needed for the sphinx-gallery scraper.
SHOWED_FIGURES.append(self)
if method not in ["static", "external"]:
raise GMTInvalidInput("Invalid show method '{}'.".format(method))
if method == "external":
pdf = self._preview(fmt="pdf", dpi=dpi, anti_alias=False, as_bytes=False)
launch_external_viewer(pdf)
img = None
elif method == "static":
png = self._preview(
fmt="png", dpi=dpi, anti_alias=True, as_bytes=True, transparent=True
)
if Image is None:
raise GMTError(
" ".join(
[
"Cannot find IPython.",
"Make sure you have it installed",
"or use 'external=True' to open in an external viewer.",
]
)
)
img = Image(data=png, width=width)
return img
"""
class GMTCLibNoSessionError(GMTCLibError):
"""
Tried to access GMT API without a currently open GMT session.
"""
class GMTInvalidInput(GMTError):
"""
Raised when the input of a function/method is invalid.
"""
class GMTVersionError(GMTError):
"""
Raised when an incompatible version of GMT is being used.
# from GMTError.
class GMTError(Exception):
"""
Base class for all GMT related errors.
"""
class GMTOSError(GMTError):
"""
Unsupported operating system.
"""
class GMTCLibError(GMTError):
"""
Error encountered when running a function from the GMT shared library.
"""
class GMTCLibNotFoundError(GMTCLibError):
"""
Could not find the GMT shared library.
"""
class GMTCLibNoSessionError(GMTCLibError):
"""
Tried to access GMT API without a currently open GMT session.
"""