Skip to content

Commit

Permalink
Refactor if statements
Browse files Browse the repository at this point in the history
  • Loading branch information
lunkwill42 committed Oct 4, 2023
1 parent 1a7e088 commit ebebe7c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/zino/tasks/linkstatetask.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,14 @@ def _get_or_create_port(self, ifindex: int):

def _is_interface_watched(self, data: BaseInterfaceRow):
# If watch pattern exists, only watch matching interfaces
if self.device.watchpat:
if not re.match(self.device.watchpat, data.descr):
_logger.debug("%s intf %s not watched", self.device.name, data.descr)
return False
if self.device.watchpat and not re.match(self.device.watchpat, data.descr):
_logger.debug("%s intf %s not watched", self.device.name, data.descr)
return False

# If ignore pattern exists, ignore matching interfaces
if self.device.ignorepat:
if re.match(self.device.ignorepat, data.descr):
_logger.debug("%s intf %s ignored", self.device.name, data.descr)
return False
if self.device.ignorepat and re.match(self.device.ignorepat, data.descr):
_logger.debug("%s intf %s ignored", self.device.name, data.descr)
return False

return True

Expand Down

0 comments on commit ebebe7c

Please sign in to comment.