Skip to content

Commit

Permalink
Implementation of headers only by passing a boolean to the Item class…
Browse files Browse the repository at this point in the history
… to include all or part of the item
  • Loading branch information
Jacob Daniel Bennett committed Nov 2, 2020
1 parent d93ed18 commit 1dd473c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
23 changes: 17 additions & 6 deletions api/ECNQueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
currentFileDirectory = os.path.dirname(currentFilePath)
currentFileDirectoryParent = os.path.dirname(currentFileDirectory)
queueDirectory = os.path.join(currentFileDirectoryParent, "q-snapshot")

#queueDirectory = "/home/pier/e/benne238/personalQueues"
# Queues to not load in getQueues()
queuesToIgnore = ["archives", "drafts", "inbox", "coral"]

Expand Down Expand Up @@ -106,7 +106,7 @@ class Item:
jsonData: A JSON serializable representation of the Item.
"""

def __init__(self, queue: str, number: int) -> None:
def __init__(self, queue: str, number: int, wholeItem: bool) -> None:
self.queue = queue
try:
self.number = int(number)
Expand All @@ -118,7 +118,10 @@ def __init__(self, queue: str, number: int) -> None:
self.lastUpdated = self.__getLastUpdated()
self.__rawItem = self.__getRawItem()
self.headers = self.__parseHeaders()
self.content = self.__parseSections()

if wholeItem:
self.content = self.__parseSections()

self.isLocked = self.__isLocked()
self.userEmail = self.__parseFromData(data="userEmail")
self.userName = self.__parseFromData(data="userName")
Expand All @@ -138,7 +141,7 @@ def __init__(self, queue: str, number: int) -> None:
"number": self.number,
"lastUpdated": self.lastUpdated,
"headers": self.headers,
"content": self.content,
#"content": self.content,
"isLocked": self.isLocked,
"userEmail": self.userEmail,
"userName": self.userName,
Expand All @@ -151,6 +154,8 @@ def __init__(self, queue: str, number: int) -> None:
"building": self.building,
"dateReceived": self.dateReceived
}
if wholeItem:
self.jsonData["content"] = self.content

def __getLastUpdated(self) -> str:
"""Returns last modified time of item reported by the filesystem in mm-dd-yy hh:mm am/pm format.
Expand Down Expand Up @@ -1247,7 +1252,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))
items.append(Item(self.name, item, False))

return items

Expand Down Expand Up @@ -1331,4 +1336,10 @@ def loadQueues() -> list:
for queue in getValidQueues():
queues.append(Queue(queue))

return queues
return queues
if __name__ == "__main__":
queueList = []
validQueues = getValidQueues()
for queue in validQueues:
queueList.append(Queue(queue).toJson())
print()
2 changes: 1 addition & 1 deletion api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get(self, queue: str, number: int) -> str:
Returns:
str: JSON representation of the item requested.
"""
return ECNQueue.Item(queue, number).toJson()
return ECNQueue.Item(queue, number, True).toJson()

class Queue(Resource):
def get(self, queue: str) -> str:
Expand Down

0 comments on commit 1dd473c

Please sign in to comment.