-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 🎨 Applying Ruff linting * 👷 Updating CI/CD to use Ruff * 🎨 Add Ruff formatter badge
- Loading branch information
Showing
17 changed files
with
375 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,57 @@ | ||
class BookshelfBaseException(Exception): | ||
|
||
def __init__(self, message: str): | ||
super().__init__(message) | ||
|
||
|
||
class BookshelfStoryException(BookshelfBaseException): | ||
|
||
def __init__(self, story_name: str, message_template: str, hint_template: str): | ||
self.terminal_message = self._construct_exception_message(story_name, message_template, hint_template) | ||
self.terminal_message = self._construct_exception_message( | ||
story_name, message_template, hint_template | ||
) | ||
super().__init__(message_template.format(story_name)) | ||
|
||
@staticmethod | ||
def _construct_exception_message(story_name: str, message_template: str, hint_template: str) -> str: | ||
return f'❌{message_template}\n💡{hint_template}'.format(story_name, story_name) | ||
def _construct_exception_message( | ||
story_name: str, message_template: str, hint_template: str | ||
) -> str: | ||
return f"❌{message_template}\n💡{hint_template}".format(story_name, story_name) | ||
|
||
|
||
class StoryNotFoundException(BookshelfStoryException): | ||
MESSAGE_TEMPLATE = 'Could not find story with name [bold]{}[/bold].' | ||
HINT_TEMPLATE = 'You can create one with [bold]bookshelf create {}[/bold].' | ||
MESSAGE_TEMPLATE = "Could not find story with name [bold]{}[/bold]." | ||
HINT_TEMPLATE = "You can create one with [bold]bookshelf create {}[/bold]." | ||
|
||
def __init__(self, story_name): | ||
super().__init__(story_name, self.MESSAGE_TEMPLATE, self.HINT_TEMPLATE) | ||
|
||
|
||
class StoryAlreadyExistsException(BookshelfStoryException): | ||
MESSAGE_TEMPLATE = 'The story [bold]{}[/bold] already exists.' | ||
HINT_TEMPLATE = 'Use [bold]bookshelf create {} --force [/bold] to override.' | ||
MESSAGE_TEMPLATE = "The story [bold]{}[/bold] already exists." | ||
HINT_TEMPLATE = "Use [bold]bookshelf create {} --force [/bold] to override." | ||
|
||
def __init__(self, story_name): | ||
super().__init__(story_name, self.MESSAGE_TEMPLATE, self.HINT_TEMPLATE) | ||
|
||
|
||
class StoryAlreadyFinishedException(BookshelfStoryException): | ||
MESSAGE_TEMPLATE = 'The story [bold]{}[/bold] is already finished.' | ||
HINT_TEMPLATE = 'Use [bold]bookshelf create {} [/bold] a new story.' | ||
MESSAGE_TEMPLATE = "The story [bold]{}[/bold] is already finished." | ||
HINT_TEMPLATE = "Use [bold]bookshelf create {} [/bold] a new story." | ||
|
||
def __init__(self, story_name): | ||
super().__init__(story_name, self.MESSAGE_TEMPLATE, self.HINT_TEMPLATE) | ||
|
||
|
||
class ChapterInProgressException(BookshelfStoryException): | ||
MESSAGE_TEMPLATE = 'The current chapter in [bold]{}[/bold] is in progress.' | ||
HINT_TEMPLATE = 'Use [bold]bookshelf stop {}[/bold] before starting a new one.' | ||
MESSAGE_TEMPLATE = "The current chapter in [bold]{}[/bold] is in progress." | ||
HINT_TEMPLATE = "Use [bold]bookshelf stop {}[/bold] before starting a new one." | ||
|
||
def __init__(self, story_name): | ||
super().__init__(story_name, self.MESSAGE_TEMPLATE, self.HINT_TEMPLATE) | ||
|
||
|
||
class ChapterNotInProgressException(BookshelfStoryException): | ||
MESSAGE_TEMPLATE = 'The current chapter in {} is not in progress.' | ||
HINT_TEMPLATE = 'Use [bold]bookshelf start {}[/bold] to start one.' | ||
MESSAGE_TEMPLATE = "The current chapter in {} is not in progress." | ||
HINT_TEMPLATE = "Use [bold]bookshelf start {}[/bold] to start one." | ||
|
||
def __init__(self, story_name): | ||
super().__init__(story_name, self.MESSAGE_TEMPLATE, self.HINT_TEMPLATE) |
Oops, something went wrong.