Skip to content

Commit

Permalink
Change wholeItem to headersOnly and add to Item, Queue and loadAllQueues
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Campbell committed Nov 29, 2020
1 parent 0123593 commit db08a0f
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions api/ECNQueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ class Item:
Example:
# Create an Item (ce100)
>>> item = Item("ce", 100, True)
>>> item = Item("ce", 100, headersOnly=false)
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.
content: A list of section dictionaries (only included if wholeItem is True).
content: A list of section dictionaries (only included if headersOnly is False).
isLocked: A boolean showing whether or not a lockfile for the item is present.
userEmail: The email address of the person who this item is from.
userName: The real name of the person who this item is from.
Expand All @@ -106,7 +106,7 @@ class Item:
jsonData: A JSON serializable representation of the Item.
"""

def __init__(self, queue: str, number: int, wholeItem: bool) -> None:
def __init__(self, queue: str, number: int, headersOnly: bool = False) -> None:
self.queue = queue

try:
Expand All @@ -119,7 +119,7 @@ def __init__(self, queue: str, number: int, wholeItem: bool) -> None:
self.lastUpdated = self.__getLastUpdated()
self.__rawItem = self.__getRawItem()
self.headers = self.__parseHeaders()
if wholeItem: self.content = self.__parseSections()
if not headersOnly: self.content = self.__parseSections()
self.isLocked = self.__isLocked()
self.userEmail = self.__parseFromData(data="userEmail")
self.userName = self.__parseFromData(data="userName")
Expand Down Expand Up @@ -1209,8 +1209,9 @@ class Queue:
jsonData: A JSON serializable representation of the Queue.
"""

def __init__(self, name: str) -> None:
def __init__(self, name: str, headersOnly: bool = True) -> None:
self.name = name
self.headersOnly = headersOnly
self.__directory = queueDirectory + "/" + self.name + "/"
self.items = self.__getItems()

Expand All @@ -1233,7 +1234,7 @@ def __getItems(self) -> list:
isFile = True if os.path.isfile(itemPath) else False

if isFile and isValidItemName(item):
items.append(Item(self.name, item, False))
items.append(Item(self.name, item, headersOnly=self.headersOnly))

return items

Expand Down Expand Up @@ -1306,7 +1307,7 @@ def getQueueCounts() -> list:
return queueInfo


def loadQueues() -> list:
def loadAllQueues(headersOnly: bool = True) -> list:
"""Return a list of Queues for each queue.
Returns:
Expand All @@ -1315,9 +1316,6 @@ def loadQueues() -> list:
queues = []

for queue in getValidQueues():
queues.append(Queue(queue))
queues.append(Queue(queue, headersOnly=headersOnly))

return queues
if __name__ == "__main__":
item = Item("ce", 100, False)
print()
return queues

0 comments on commit db08a0f

Please sign in to comment.