Skip to content

Commit

Permalink
Removed the use of abc for NotImplementedError (#78)
Browse files Browse the repository at this point in the history
* Removing abc for NotImplementedError

* Reducing a docstring to fit line length
  • Loading branch information
kiddinn authored Jan 30, 2020
1 parent 2f8ef7f commit 1b159eb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
3 changes: 1 addition & 2 deletions l2tscaffolder/definitions/interface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
"""Interface defining how a project class looks like."""
import abc

from l2tscaffolder.lib import definitions

Expand All @@ -9,7 +8,6 @@ class ScaffolderDefinition:

NAME = definitions.DEFINITION_UNDEFINED

@abc.abstractmethod
def ValidatePath(self, root_path: str) -> bool:
"""Validates the path to the root directory of the project.
Expand All @@ -19,3 +17,4 @@ def ValidatePath(self, root_path: str) -> bool:
Returns:
bool: whether the given path is the correct root path of the project.
"""
raise NotImplementedError
19 changes: 9 additions & 10 deletions l2tscaffolder/frontend/output_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
1. Relay information back to the user.
2. Gather input from an end user and presenting it back to the tool.
"""
import abc


class BaseOutputHandler:
"""Interface for the output handler."""

@abc.abstractmethod
def Confirm(self, text: str, default=True, abort=True):
"""Returns a bool from a yes/no question presented to the end user.
Expand All @@ -26,47 +24,47 @@ def Confirm(self, text: str, default=True, abort=True):
Returns:
bool: False if the user entered no, True if the user entered yes
"""
raise NotImplementedError

@abc.abstractmethod
def PrintError(self, text: str):
"""Presents an error message.
Args:
text (str): the error message to present.
"""
raise NotImplementedError

@abc.abstractmethod
def PrintInfo(self, text: str):
"""Presents the user with an informational text.
Args:
text (str): the text to present.
"""
raise NotImplementedError

@abc.abstractmethod
def PrintNewLine(self):
"""Adds a new or blank line to the output."""
raise NotImplementedError

@abc.abstractmethod
def PrintOutput(self, text: str):
"""Presents the user with output from the tool.
Args:
text (str): the text to present the user with.
"""
raise NotImplementedError

@abc.abstractmethod
def PromptError(self, text: str) -> str:
"""Presents the user with an error message prompt and return back the answer.
"""Presents the user with an error message prompt and returns the answer.
Args:
text (str): the text to prompt
Returns:
str: the user input.
"""
raise NotImplementedError

@abc.abstractmethod
def PromptInfo(self, text: str) -> str:
"""Presents the user with a message prompt and return back the answer.
Expand All @@ -76,8 +74,8 @@ def PromptInfo(self, text: str) -> str:
Returns:
str: the user input.
"""
raise NotImplementedError

@abc.abstractmethod
def PromptInfoWithDefault(
self, text: str, input_type: type, default: object) -> str:
"""Presents the user with a prompt with a default return value and a type.
Expand All @@ -93,3 +91,4 @@ def PromptInfoWithDefault(
Returns:
object: the user input, using the supplied input type.
"""
raise NotImplementedError
6 changes: 2 additions & 4 deletions l2tscaffolder/scaffolders/interface.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
"""The scaffolder interface classes."""
import abc

from typing import Dict
from typing import Iterator
from typing import List
Expand Down Expand Up @@ -116,13 +114,13 @@ def __init__(self):
super(Scaffolder, self).__init__()
self._output_name = ''

@abc.abstractmethod
def GetInitFileChanges(self) -> Iterator[Tuple[str, str]]:
"""Generate a list of init files that need changing and the changes to them.
Yields:
tuple (str, str): path to the init file and the entry to add to it.
"""
raise NotImplementedError

def GetJinjaContext(self) -> Dict[str, object]:
"""Returns a dict that can be used as a context for Jinja2 templates.
Expand All @@ -142,13 +140,13 @@ def GetQuestions(self) -> List[BaseQuestion]:
"""
return self.QUESTIONS

@abc.abstractmethod
def GenerateFiles(self) -> Iterator[Tuple[str, str]]:
"""Generates files this scaffolder provides.
Yields:
list: file name and content of the file to be written to disk.
"""
raise NotImplementedError

def GetFilesToCopy(self) -> Iterator[Tuple[str, str]]:
"""Return a list of files that need to be copied.
Expand Down
2 changes: 1 addition & 1 deletion test_data/turbinia_job_output.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Google Inc.
# Copyright 2020 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 1b159eb

Please sign in to comment.