Nexus Generic Module#
- exception nexus.generic.NexusError[source]#
Bases:
ExceptionException for errors that are caused by a bug in Nexus.
- exception nexus.generic.FileFormatError[source]#
Bases:
ExceptionException raised when a file is not formatted as expected.
- exception nexus.generic.NotAnElementError[source]#
Bases:
ValueErrorException raised when a value can not be interpreted as an element.
- exception nexus.generic.NexusDevWarning(msg: str, indent: str = ' ', cls: str | None = None)[source]#
Bases:
Warning
- exception nexus.generic.NexusUserWarning(msg: str, indent: str = ' ', cls: str | None = None)[source]#
Bases:
NexusDevWarning
- nexus.generic.nxs_print(*items, indent: str | None = None, logfile: TextIO | None = None, n: int = 0) None[source]#
- nexus.generic.warn(msg: str, indent: str = ' ', warn_type: str = 'user', cls: str | None = None) None[source]#
Report a warning.
- Parameters:
- msg
str The message for the warning.
- indentstr. default=” “
The indentation for the warning message.
- warn_type{“user”, “dev”, “deprecate”, “class”}
See the notes for a description of when you should use each warning type.
- cls
str, optional Meant to be passed through
self.warn()in a class that derives fromobject_interface.
- msg
Notes
If you are a developer who wants to use this function but are unsure of what kind of warning type to use, here are some basic guidelines for choosing:
If the function you’re putting a warning in will be directly called by a user, you should use
"user", as this will show them where in their own script they’ve called the function.If the function you’re putting a warning in will be indirectly called by a function that a user has called, and if the problem is due to something the user has done you should use the class’s
self.warn()functionality if it inherits fromDevBase, otherwise use the warning type"class"and pass in the name of the class and/or function you’re calling from.If the function is called indirectly by a user and it is not necessarily their fault that something has gone awry, you should use
"dev". This should likely only be used in places where you are mostly sure there won’t be any problems but the code has not been thoroughly tested.If you are deprecating a function, use the
@nxs_deprecatedecorator and supply the version and the replacement that a user should use instead of the soon-to-be-removed function.