-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactor to split reporter backends and outputs. #3
Refactor to split reporter backends and outputs. #3
Conversation
class ReporterHandlerBase(ABC): | ||
class ReporterRendererBase(ABC): | ||
""" | ||
Base class for all reporter handlers. | ||
Base class for all reporter renderers. | ||
""" | ||
|
||
def render(self, data: Any, **kwargs) -> str: | ||
def default(self, data: Any, **kwargs) -> str: | ||
""" | ||
How to render the data by default | ||
""" | ||
return str(data) | ||
|
||
@abstractmethod | ||
def detail_view(self, data: dict[str, str | int | bool], **kwargs) -> str: | ||
def table(self, data: Any, **kwargs) -> str: | ||
""" | ||
Render the output in a "tabular" format. | ||
Renders the data in a tabular format. | ||
""" | ||
|
||
@abstractmethod | ||
def envs_list(self, data, **kwargs) -> str: | ||
def list(self, data: Any, **kwargs) -> str: | ||
""" | ||
Render a list of environments | ||
Renders the data in a plain list | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a key change in how it handles render styles, should give us some flexibility for future expansion.
""" | ||
|
||
name: str | ||
description: str | ||
handler: ReporterHandlerBase | ||
renderer: ReporterRendererBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"handlers" are way overused
""" | ||
|
||
name: str | ||
description: str | ||
get_output_io: Callable[[], ContextManager] | ||
stream: Callable[[], ContextManager] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the output has a stream to write to
will take a look at the test failures tomorrow |
This is my suggestion to tweak the naming and implementation complexity of this new exciting feature Xrefs conda#13868