diff --git a/api/ECNQueue.py b/api/ECNQueue.py index f9b6fce..3189423 100644 --- a/api/ECNQueue.py +++ b/api/ECNQueue.py @@ -58,7 +58,10 @@ #------------------------------------------------------------------------------# def isValidItemName(name: str) -> bool: - """Returns true if file name is a valid item name + """Returns true if file name is a valid item name. + + A file name is true if it contains between 1 and 3 integer numbers allowing for + any integer between 0 and 999. Example: isValidItemName("21") -> true @@ -87,6 +90,11 @@ class Item: # Create an Item without parsing its contents (ce100) >>> item = Item("ce", 100, headersOnly=True) + Args: + queue (str): The name of the Item's queue. + number (int): The number of the Item. + headersOnly (bool, optional): Whether or not to parse headers only. Defaults to True. + Attributes: lastUpdated: An ISO 8601 formatted time string showing the last time the file was updated according to the filesystem. headers: A list of dictionaries containing header keys and values. @@ -1192,7 +1200,6 @@ def toJson(self) -> dict: def __repr__(self) -> str: return self.queue + str(self.number) -# TODO: Make Queue iterable using __iter__. See: https://thispointer.com/python-how-to-make-a-class-iterable-create-iterator-class-for-it/ class Queue: """A collection of Items. @@ -1202,6 +1209,10 @@ class Queue: # Create a queue without parsing item contents (ce) >>> queue = Queue("ce", headersOnly=False) + Args: + queue (str): The name of the queue. + headersOnly (bool, optional): Whether or not to parse headers only. Defaults to True. + Attributes: name: The name of the queue. items: A list of Items in the queue. @@ -1213,6 +1224,7 @@ def __init__(self, name: str, headersOnly: bool = True) -> None: self.headersOnly = headersOnly self.__directory = queueDirectory + "/" + self.name + "/" self.items = self.__getItems() + self._index = 0 self.jsonData = { "name": self.name,