Skip to content

Commit

Permalink
forgot to remove the LessonBookmark class
Browse files Browse the repository at this point in the history
  • Loading branch information
tundebabzy committed Oct 27, 2023
1 parent 7b3f4c2 commit d67faa1
Showing 1 changed file with 0 additions and 51 deletions.
51 changes: 0 additions & 51 deletions lms/www/batch/learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,57 +105,6 @@ def get_page_extensions(context):
e.set_context(context)
return extensions

class LessonBookmark:
"""
This represents a simple data structure to represent a lesson bookmark.
"""
def __init__(self, lesson_number: str) -> None:
self.__test_param_or_raise_exception(lesson_number)
_lesson_number = f"{lesson_number}." if not "." in lesson_number else lesson_number
first, second = _lesson_number.split(".")

self.__value = (int(first), int(second) or 0) # second would be "" if `lesson_number` is something like "7"

def __eq__(self, other: object) -> bool:
if isinstance(other, self.__class__):
return self.__value == other.value
return NotImplemented

def __gt__(self, other: object) -> bool:
if isinstance(other, self.__class__):
return self.__value > other.value
return False

def __repr__(self) -> str:
return f"{self.__value[0]}.{self.__value[1]}"

def __test_param_or_raise_exception(self, string: str) -> None:
"""
Tests that a given string is in the format "n" or "n.n" where n is a numeric
character. If the string does not match the expected format, `TypeError` is
raised.
"""
import re
import sys
expected_format = r'^\d+\.?\d*$'

try:
if not re.match(expected_format, string):
raise TypeError("""Expected a 'str' in the format 'n' or 'n.n' where n
is a numeric character. Example: '7' or '7.10""")
except TypeError as e:
tb = sys.exc_info()[2]
raise TypeError("""Expected a 'str' in the format 'n' or 'n.n' where n
is a numeric character. Example: '7' or '7.10""").with_traceback(tb)

@property
def value(self):
return self.__value

@property
def readable_value(self):
return self.__repr__()


def get_neighbours(current, lessons):
numbers = [lesson.number for lesson in lessons]
Expand Down

0 comments on commit d67faa1

Please sign in to comment.