File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change 1
1
from datetime import datetime
2
+ from typing import Optional
2
3
3
4
def get_attribute (attributes , id ) -> str :
4
5
attribute = [attribute for attribute in attributes if attribute ["id" ] == id ]
@@ -10,17 +11,23 @@ def get_attribute(attributes, id) -> str:
10
11
11
12
return attribute [0 ]["value" ]
12
13
13
- def get_title (attributes ) -> str :
14
- return get_attribute (attributes , 1 )
14
+ def get_title (attributes ) -> Optional [str ]:
15
+ try :
16
+ return get_attribute (attributes , 1 )
17
+ except Exception :
18
+ return None
15
19
16
- def get_description (attributes ):
20
+ def get_description (attributes ) -> Optional [ str ] :
17
21
try :
18
22
return get_attribute (attributes , 3 )
19
23
except Exception :
20
- return ""
24
+ return None
21
25
22
- def get_location (attributes ):
23
- return get_attribute (attributes , 50 )
26
+ def get_location (attributes ) -> Optional [str ]:
27
+ try :
28
+ return get_attribute (attributes , 50 )
29
+ except Exception :
30
+ return None
24
31
25
32
def parse_date (date_string : str ) -> datetime :
26
33
return datetime .strptime (date_string , "%Y-%m-%d %H:%M:%S" )
You can’t perform that action at this time.
0 commit comments