Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Used html module to unescape html characters #194

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
17 changes: 16 additions & 1 deletion dynamic/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager

# Required for replacing html escape characters with their corresponding ascii characters
import html
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed

console = Console()


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

def replaceHtmlEscapeCharacters(self, question_title):
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
Fixed Show fixed Hide 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 +214,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.replaceHtmlEscapeCharacters(item["title"].replace("|", "")), item["question_id"], item["link"]]
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
for item in json_ques_data["items"]
]

Expand Down