Skip to content

Commit

Permalink
Add metaclass over ImageType to raise error upon wrong usage
Browse files Browse the repository at this point in the history
  • Loading branch information
saihv committed Mar 16, 2021
1 parent 8ffcfe2 commit 85b2fa3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions PythonClient/airsim/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,33 @@ class ImageType:
SurfaceNormals = 6
Infrared = 7

class _ImageType(type):
@property
def Scene(cls):
return 0
def DepthPlanar(cls):
return 1
def DepthPerspective(cls):
return 2
def DepthVis(cls):
return 3
def DisparityNormalized(cls):
return 4
def Segmentation(cls):
return 5
def SurfaceNormals(cls):
return 6
def Infrared(cls):
return 7

def __getattr__(self, key):
if key == 'DepthPlanner':
print('\033[31m'+"DepthPlanner has been (correctly) renamed to DepthPlanar. Please use ImageType.DepthPlanar instead."+'\033[0m')
raise AttributeError

class ImageType(metaclass=_ImageType):
pass

class DrivetrainType:
MaxDegreeOfFreedom = 0
ForwardOnly = 1
Expand Down

0 comments on commit 85b2fa3

Please sign in to comment.