Skip to content
Open
Changes from 2 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
18 changes: 17 additions & 1 deletion dynamic/utility.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Required for replacing html escape characters with their corresponding ascii characters
Comment thread Fixed
Comment thread Fixed
import html
from termcolor import colored
import requests
from rich.console import Console
Expand Down Expand Up @@ -33,6 +35,8 @@
from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager



console = Console()


Expand Down Expand Up @@ -183,6 +187,18 @@ def __init__(self):
self.utility = Utility()
self.playbook = Playbook()

def unescape_html_characters(self, question_title):
Comment thread Fixed
"""
Function to replace HTML escape characters in question's title
to their corresponding ASCII characters
For example, if the title was something like this:
'"static const" vs "#define" vs "enum"'
the HTML escape characters would be replaced with their corresponding ASCII
characters and the resulting string would be:
'"static const" vs "#define" vs "enum"'
"""
return html.unescape(question_title)

def populate_question_data(self, questions_list):
"""
Function to populate question data property
Expand All @@ -199,7 +215,7 @@ def populate_question_data(self, questions_list):
sys.exit()
json_ques_data = resp.json()
self.questions_data = [
[item["title"].replace("|", ""), item["question_id"], item["link"]]
[self.unescape_html_characters(item["title"].replace("|", "")), item["question_id"], item["link"]]
Comment thread Fixed
Comment thread Fixed
for item in json_ques_data["items"]
]

Expand Down