Skip to content

Commit

Permalink
Added __contains__ function to Device so it compares value to fx.poin…
Browse files Browse the repository at this point in the history
…ts_names for super quick verification of point existence

Signed-off-by: Christian Tremblay <christian.tremblay@servisys.com>
  • Loading branch information
ChristianTremblay committed Nov 18, 2015
1 parent 0223b65 commit 39c5a8a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions BAC0/core/devices/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,11 @@ def poll(self, command='start', *, delay=10):
def __getitem__(self, point_name):
"""
Get a point based on its name
If a list is passed, will return a dataframe
:param point_name: (str) name of the point
:param point_name: (str) name of the point or list of point_names
:type point_name: str
:returns: (Point) the point (can be Numeric, Boolean or Enum)
:returns: (Point) the point (can be Numeric, Boolean or Enum) or pd.DataFrame
"""
if isinstance(point_name,list):
return self.df(point_name)
Expand All @@ -287,6 +288,10 @@ def __iter__(self):
"""
for each in self.points:
yield each

def __contains__(self, value):
"When using in..."
return value in self.points_name

@property
def points_name(self):
Expand Down

0 comments on commit 39c5a8a

Please sign in to comment.