Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/meetup_manager/meetup_manager/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import json
import re


def parser(issue: str):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we test it works in al cases?

Very rare case, but what if a speaker intentionally leaves out a section intentionally? What happens then?

Need to add more error handling

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested manually on test cases that i can think of.
If speaker leaves out a section, then value corresponding to that section will be empty. I will add tests, that will clear a lot of things.

"""
Extracts out:
- Title of the talk
- Abstract
- Category
- Duration
- Level of Audience
- Speaker's Bio
"""

# Regex for comments
comments = r"(\<|\d+\.|One).+(-|\>|\.)$"
details = re.sub(comments, "", issue, flags=re.M).strip()

issue = re.split(r"\*\*.+\*\*", details, 7, flags=re.M)
talk_details = {
"title": None,
"abstract": None,
"category": None,
"duration": None,
"level": None,
"bio": None,
"pre-req": None,
}

j = 1 # Index zero in list is empty
for i in talk_details.keys():
if j < len(issue):
talk_details[i] = issue[j].strip()
j += 1
else:
break

return json.dumps(talk_details)