This function takes a reddit object and returns the post id
(reddit_obj: dict, field: Optional[str] = "thread_id")
| 5 | |
| 6 | |
| 7 | def extract_id(reddit_obj: dict, field: Optional[str] = "thread_id"): |
| 8 | """ |
| 9 | This function takes a reddit object and returns the post id |
| 10 | """ |
| 11 | if field not in reddit_obj.keys(): |
| 12 | raise ValueError(f"Field '{field}' not found in reddit object") |
| 13 | reddit_id = re.sub(r"[^\w\s-]", "", reddit_obj[field]) |
| 14 | return reddit_id |
no outgoing calls
no test coverage detected