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

Removing html elements from events description. #19

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
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
14 changes: 13 additions & 1 deletion src/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,39 @@
from dateutil import parser


# import regular expression module
import re



Comment on lines +10 to +14
Copy link
Member

Choose a reason for hiding this comment

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

⛏️ There isn't a big need for this import to be separate from the other imports, and I think the comment isn't totally necessary

class Event:
"""Event records all the data from an event, and has methods to generate the
message from an event
"""

# pylint: disable=too-many-instance-attributes
# Events have lots of data that we need to save together


Comment on lines +22 to +23
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

⛏️ These lines can be removed


def __init__(
self, title, group_name, description, location, time, url, status, uuid
):
# pylint: disable=too-many-arguments
self.title = title
self.group_name = group_name
self.description = description
self.description = self.remove_html(description)
self.location = location
self.time = time
self.url = url
self.status = status
self.uuid = uuid

def remove_html(self, string):
Comment on lines +31 to +38
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
self.description = self.remove_html(description)
self.location = location
self.time = time
self.url = url
self.status = status
self.uuid = uuid
def remove_html(self, string):
self.description = self.__remove_html(description)
self.location = location
self.time = time
self.url = url
self.status = status
self.uuid = uuid
def __remove_html(self, string):

🔧 Since this function is only intended to be used in Event's __init__ constructor, we'll want to add two underscores in order to mark this as a private function that isn't intended to be used by other people. But otherwise, separating the HTML sanitation into a separate function is a great approach!

regex = re.compile(r'<[^>]+>')
return regex.sub('', string)


# creates a struct of event information used to compose different formats of the event message
@classmethod
def from_event_json(cls, event_json):
Expand Down