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

Refactor to split reporter backends and outputs. #3

Conversation

jezdez
Copy link

@jezdez jezdez commented Jun 6, 2024

This is my suggestion to tweak the naming and implementation complexity of this new exciting feature Xrefs conda#13868

Comment on lines -216 to 235
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
"""
Copy link
Author

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
Copy link
Author

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]
Copy link
Author

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

@jezdez jezdez marked this pull request as draft June 6, 2024 20:19
@jezdez
Copy link
Author

jezdez commented Jun 6, 2024

will take a look at the test failures tomorrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant