-
Notifications
You must be signed in to change notification settings - Fork 0
Feature load queue and length of queue #104
Conversation
…ns directly accessible in the ECNQueue module
This is functional but it doesn't follow the DRY (don't repeat yourself) principle. Rather than copy code from the existing If we analyze the current
def getQueues() -> list:
"""Return a list of Queues for each queue.
Returns:
list: list of Queues for each queue.
"""
queues = []
for file in os.listdir(queueDirectory):
currentFile = queueDirectory + "/" + file
isDirectory = os.path.isdir(currentFile)
isValid = file not in queuesToIgnore
if isDirectory and isValid:
queues.append(Queue(file))
return queues During queue creation,
def __getItems(self) -> list:
"""Returns a list of items for this Queue
Returns:
list: a list of items for this Queue
"""
items = []
for item in os.listdir(self.__directory):
itemPath = self.__directory + "/" + item
isFile = True if os.path.isfile(itemPath) else False
itemPattern = re.compile("^[0123456789]{1,3}$")
isItem = True if itemPattern.match(item) else False
if isFile and isItem:
items.append( Item(self.name, item) )
return items We need to break these two functions apart to allow for the new sets of data we need to return. Those sets of data are:
This would start with extracting functionality like building a list of queues, and validating Item file names into separate functions and recombining those functions to get the desired outputs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Common functionality needs extracted into callable functions rather than repeated.
No description provided.