From b2e4a92e82e3a98288bac766ffd3f3e945d99112 Mon Sep 17 00:00:00 2001 From: Wesley Kerfoot Date: Sun, 28 Jul 2019 19:01:03 -0400 Subject: [PATCH] Rename `timestamp` to `date` to be consistent --- deletefb/tools/conversations.py | 14 +++++++------- deletefb/types.py | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/deletefb/tools/conversations.py b/deletefb/tools/conversations.py index c6f57fb..19d82ab 100644 --- a/deletefb/tools/conversations.py +++ b/deletefb/tools/conversations.py @@ -37,11 +37,11 @@ def get_conversations(driver): for convo in driver.find_elements_by_xpath("//a"): url = convo.get_attribute("href") - timestamp = None + date = None if url and "messages/read" in url: - timestamp = convo.find_element_by_xpath("../../..//abbr").text + date = convo.find_element_by_xpath("../../..//abbr").text conversation_name = convo.find_element_by_xpath("../../../div/div/header/h3").text.strip() assert(conversation_name) @@ -50,7 +50,7 @@ def get_conversations(driver): conversations.append( Conversation( url=url, - timestamp=timestamp, + date=date, name=conversation_name ) ) @@ -88,7 +88,7 @@ def get_convo_messages(driver): yield Message( name=data_store.get("author"), content=msg_text, - timestamp=data_store.get("timestamp") + date=data_store.get("timestamp") ) def archive_conversation(driver, convo): @@ -134,11 +134,11 @@ def delete_conversations(driver, year=None): convos = get_conversations(driver) for convo in convos: - # If the year is set and there is a timestamp + # If the year is set and there is a date # Then we want to only look at convos from this year - if year and convo.timestamp: - if convo.timestamp.year == int(year): + if year and convo.date: + if convo.date.year == int(year): archive_conversation(driver, convo) print(convo.messages) diff --git a/deletefb/types.py b/deletefb/types.py index 0e589d7..16a5c60 100644 --- a/deletefb/types.py +++ b/deletefb/types.py @@ -2,9 +2,9 @@ import attr import uuid import pendulum -def convert_timestamp(text): +def convert_date(text): """ - Tries to parse a timestamp into a DateTime instance + Tries to parse a date into a DateTime instance Returns `None` if it cannot be parsed """ try: @@ -35,7 +35,7 @@ class Comment: class Conversation: url = attr.ib() name = attr.ib() - timestamp = attr.ib(converter=convert_timestamp) + date = attr.ib(converter=convert_date) messages = attr.ib(default=[]) @attr.s @@ -43,8 +43,8 @@ class Message: name = attr.ib() content = attr.ib() - # Remove the last 3 digits from FB's timestamps. They are not standard. - timestamp = attr.ib(converter=lambda t: pendulum.from_timestamp(int(str(t)[0:-3]))) + # Remove the last 3 digits from FB's dates. They are not standard. + date = attr.ib(converter=lambda t: pendulum.from_timestamp(int(str(t)[0:-3]))) @attr.s class Page: