You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
809 B
35 lines
809 B
import attr
|
|
import uuid
|
|
import datetime
|
|
|
|
def timestamp_now():
|
|
"""
|
|
Returns: a timestamp for this instant, in ISO 8601 format
|
|
"""
|
|
return datetime.datetime.isoformat(datetime.datetime.now())
|
|
|
|
# Data type definitions of posts and comments
|
|
@attr.s
|
|
class Post:
|
|
content = attr.ib()
|
|
comments = attr.ib(default=[])
|
|
date = attr.ib(factory=timestamp_now)
|
|
name = attr.ib(factory=lambda: uuid.uuid4().hex)
|
|
|
|
@attr.s
|
|
class Comment:
|
|
commenter = attr.ib()
|
|
content = attr.ib()
|
|
date = attr.ib(factory=timestamp_now)
|
|
name = attr.ib(factory=lambda: uuid.uuid4().hex)
|
|
|
|
@attr.s
|
|
class Conversation:
|
|
recipient = attr.ib()
|
|
name = attr.ib()
|
|
last_message_time = attr.ib(factory=timestamp_now)
|
|
|
|
@attr.s
|
|
class Page:
|
|
name = attr.ib()
|
|
date = attr.ib(factory=timestamp_now)
|
|
|