Skip to content

Commit

Permalink
update documentation for header-only and more efficient jsondata defi…
Browse files Browse the repository at this point in the history
…nition
  • Loading branch information
Jacob Daniel Bennett committed Nov 3, 2020
1 parent 1dd473c commit afaaf81
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions api/ECNQueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ def isValidItemName(name: str) -> bool:
# Classes
#------------------------------------------------------------------------------#
class Item:
"""A single issue.
"""A single whole issue or jsut the issues header information.
Example:
# Create an Item (ce100)
>>> item = Item("ce", 100)
>>> item = Item("ce", 100, 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.
content: A list of section dictionaries.
content: A list of section dictionaries (only included if wholeItem is True).
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 @@ -108,6 +108,7 @@ class Item:

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

try:
self.number = int(number)
except ValueError:
Expand All @@ -118,10 +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 wholeItem: self.content = self.__parseSections()
self.isLocked = self.__isLocked()
self.userEmail = self.__parseFromData(data="userEmail")
self.userName = self.__parseFromData(data="userName")
Expand All @@ -134,28 +132,32 @@ def __init__(self, queue: str, number: int, wholeItem: bool) -> None:
self.building = self.__getMostRecentHeaderByType("Building")
self.dateReceived = self.__getFormattedDate(
self.__getMostRecentHeaderByType("Date"))

# TODO: Autopopulate jsonData w/ __dir__() command. Exclude `^_` and `jsonData`.
self.jsonData = {
"queue": self.queue,
"number": self.number,
"lastUpdated": self.lastUpdated,
"headers": self.headers,
#"content": self.content,
"isLocked": self.isLocked,
"userEmail": self.userEmail,
"userName": self.userName,
"userAlias": self.userAlias,
"assignedTo": self.assignedTo,
"subject": self.subject,
"status": self.status,
"priority": self.priority,
"department": self.department,
"building": self.building,
"dateReceived": self.dateReceived
}
if wholeItem:
self.jsonData["content"] = self.content
self.jsonData = {}

for attribute in self.__dir__():
if "_" not in attribute and attribute != "toJson" and attribute != "jsonData":
self.jsonData[attribute] = self.__getattribute__(attribute)

# self.jsonData = {
# "queue": self.queue,
# "number": self.number,
# "lastUpdated": self.lastUpdated,
# "headers": self.headers,
# #"content": self.content,
# "isLocked": self.isLocked,
# "userEmail": self.userEmail,
# "userName": self.userName,
# "userAlias": self.userAlias,
# "assignedTo": self.assignedTo,
# "subject": self.subject,
# "status": self.status,
# "priority": self.priority,
# "department": self.department,
# "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 @@ -1338,8 +1340,5 @@ def loadQueues() -> list:

return queues
if __name__ == "__main__":
queueList = []
validQueues = getValidQueues()
for queue in validQueues:
queueList.append(Queue(queue).toJson())
item = Item("ce", 100, False)
print()

0 comments on commit afaaf81

Please sign in to comment.