MCPcopy Create free account
hub / github.com/ZhengdiYu/SignAvatars / ExceptionModule

Class ExceptionModule

visualizer/aitviewer/utils/exceptions.py:19–39  ·  view source on GitHub ↗

Source: Trimesh package @ https://github.com/mikedh/trimesh/blob/master/trimesh/exceptions.py Create a dummy module which will raise an exception when attributes are accessed. For soft dependencies we want to survive failing to import but we would like to raise an appropriate e

Source from the content-addressed store, hash-verified

17
18
19class ExceptionModule(object):
20 """
21 Source: Trimesh package @ https://github.com/mikedh/trimesh/blob/master/trimesh/exceptions.py
22
23 Create a dummy module which will raise an exception when attributes
24 are accessed.
25 For soft dependencies we want to survive failing to import but
26 we would like to raise an appropriate error when the functionality is
27 actually requested so the user gets an easily debuggable message.
28 """
29
30 def __init__(self, exc):
31 self.exc = exc
32
33 def __getattribute__(self, *args, **kwargs):
34 # if it's asking for our class type return None
35 # this allows isinstance() checks to not re-raise
36 if args[0] == "__class__":
37 return None.__class__
38 # otherwise raise our original exception
39 raise super(ExceptionModule, self).__getattribute__("exc")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected