Be more pythonic

This commit is contained in:
Alex Forencich 2018-06-30 00:21:02 -07:00
parent c5837daa2f
commit 2ebffeb223

View File

@ -261,7 +261,7 @@ class AXIStreamSource(object):
return len(self.queue) return len(self.queue)
def empty(self): def empty(self):
return self.count() == 0 return not self.queue
def create_logic(self, def create_logic(self,
clk, clk,
@ -376,12 +376,12 @@ class AXIStreamSink(object):
self.read_queue = [] self.read_queue = []
def recv(self): def recv(self):
if len(self.queue) > 0: if self.queue:
return self.queue.pop(0) return self.queue.pop(0)
return None return None
def read(self, count=-1): def read(self, count=-1):
while len(self.queue) > 0: while self.queue:
self.read_queue.extend(self.queue.pop(0).data) self.read_queue.extend(self.queue.pop(0).data)
if count < 0: if count < 0:
count = len(self.read_queue) count = len(self.read_queue)
@ -393,7 +393,7 @@ class AXIStreamSink(object):
return len(self.queue) return len(self.queue)
def empty(self): def empty(self):
return self.count() == 0 return not self.queue
def create_logic(self, def create_logic(self,
clk, clk,