5 changed files with 49 additions and 30 deletions
@ -1,35 +1,39 @@ |
|||||
import attr |
import attr |
||||
import uuid |
import uuid |
||||
import datetime |
import pendulum |
||||
|
|
||||
def timestamp_now(): |
def convert_timestamp(text): |
||||
""" |
try: |
||||
Returns: a timestamp for this instant, in ISO 8601 format |
return pendulum.from_format(text, "DD/M/YYYY") |
||||
""" |
except ValueError: |
||||
return datetime.datetime.isoformat(datetime.datetime.now()) |
try: |
||||
|
return (pendulum.from_format(text, "DD MMM") |
||||
|
.set(year=pendulum.now().year)) |
||||
|
except ValueError: |
||||
|
return None |
||||
|
|
||||
# Data type definitions of posts and comments |
# Data type definitions of posts and comments |
||||
@attr.s |
@attr.s |
||||
class Post: |
class Post: |
||||
content = attr.ib() |
content = attr.ib() |
||||
comments = attr.ib(default=[]) |
comments = attr.ib(default=[]) |
||||
date = attr.ib(factory=timestamp_now) |
date = attr.ib(factory=pendulum.now) |
||||
name = attr.ib(factory=lambda: uuid.uuid4().hex) |
name = attr.ib(factory=lambda: uuid.uuid4().hex) |
||||
|
|
||||
@attr.s |
@attr.s |
||||
class Comment: |
class Comment: |
||||
commenter = attr.ib() |
commenter = attr.ib() |
||||
content = attr.ib() |
content = attr.ib() |
||||
date = attr.ib(factory=timestamp_now) |
date = attr.ib(factory=pendulum.now) |
||||
name = attr.ib(factory=lambda: uuid.uuid4().hex) |
name = attr.ib(factory=lambda: uuid.uuid4().hex) |
||||
|
|
||||
@attr.s |
@attr.s |
||||
class Conversation: |
class Conversation: |
||||
url = attr.ib() |
url = attr.ib() |
||||
name = attr.ib() |
name = attr.ib() |
||||
timestamp = attr.ib(default=None) |
timestamp = attr.ib(converter=convert_timestamp) |
||||
|
|
||||
@attr.s |
@attr.s |
||||
class Page: |
class Page: |
||||
name = attr.ib() |
name = attr.ib() |
||||
date = attr.ib(factory=timestamp_now) |
date = attr.ib(factory=pendulum.now) |
||||
|
@ -1,13 +1,25 @@ |
|||||
attrs==19.1.0 |
attrs==19.1.0 |
||||
bitarray==0.9.3 |
bitarray==0.9.3 |
||||
|
bleach==3.1.0 |
||||
certifi==2018.11.29 |
certifi==2018.11.29 |
||||
chardet==3.0.4 |
chardet==3.0.4 |
||||
|
docutils==0.14 |
||||
idna==2.8 |
idna==2.8 |
||||
|
pendulum==2.0.5 |
||||
|
pkginfo==1.5.0.1 |
||||
pybloom-live==3.0.0 |
pybloom-live==3.0.0 |
||||
|
Pygments==2.4.2 |
||||
|
python-dateutil==2.8.0 |
||||
|
pytzdata==2019.2 |
||||
|
readme-renderer==24.0 |
||||
requests==2.22.0 |
requests==2.22.0 |
||||
requests-file==1.4.3 |
requests-file==1.4.3 |
||||
|
requests-toolbelt==0.9.1 |
||||
selenium==3.141.0 |
selenium==3.141.0 |
||||
selenium-requests==1.3 |
selenium-requests==1.3 |
||||
six==1.12.0 |
six==1.12.0 |
||||
tldextract==2.2.0 |
tldextract==2.2.0 |
||||
|
tqdm==4.32.2 |
||||
|
twine==1.13.0 |
||||
urllib3==1.25.2 |
urllib3==1.25.2 |
||||
|
webencodings==0.5.1 |
||||
|
Loading…
Reference in new issue