-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelper_functions.py
34 lines (25 loc) · 1.1 KB
/
helper_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
helper_functions.py
A file that defines some shared helper functions and imports for the RSS readers.
"""
from deephaven.time import to_datetime
from dateutil import parser
from datetime import datetime
def datetime_converter_reddit(entry):
dt = datetime.fromisoformat(entry["updated"])
dts = dt.strftime("%Y-%m-%dT%H:%M:%S") + " UTC"
return to_datetime(dts)
def datetime_converter_hackernews(entry):
dt = parser.parse(entry["published"])
dts = dt.strftime("%Y-%m-%dT%H:%M:%S") + " UTC"
return to_datetime(dts)
def datetime_converter_seeking_alpha(entry):
dt = parser.parse(entry["published"])
dts = dt.strftime("%Y-%m-%dT%H:%M:%S") + " NY"
return to_datetime(dts)
def rss_attributes_method_reddit(entry):
return (entry["title"], datetime_converter_reddit(entry), entry["title_detail"]["base"])
def rss_attributes_method_hackernews(entry):
return (entry["title"], datetime_converter_hackernews(entry), entry["title_detail"]["base"])
def rss_attributes_seeking_alpha(entry):
return (entry["title"], datetime_converter_seeking_alpha(entry), entry["title_detail"]["base"])