<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def display_callback(self, component, **kwargs):
 """ Display given component in this environment. .. note:: To be overridden by inheriting classes An example of a introducing a custom display environment. .. doctest:: import cqparts from cqparts.display.environment import DisplayEnvironment, map_environment def is_text_env():
 # function that returns True if it's run in the # desired environment. import sys # Python 2.x if sys.version_info[0] == 2: return isinstance(sys.stdout, file) # Python 3.x import io return isinstance(sys.stdout, io.TextIOWrapper) @map_environment( name="text", order=0, # force display to be first priority condition=is_text_env, ) class TextDisplay(DisplayEnvironment):
 def display_callback(self, component, **kwargs):
 # Print component details to STDOUT if isinstance(component, cqparts.Assembly):
 sys.stdout.write(component.tree_str(add_repr=True)) else: # assumed to be a cqparts.Part sys.stdout.write("%r\\n" % (component)) ``is_text_env()`` checks if there's a valid ``sys.stdout`` to write to, ``TextDisplay`` defines how to display any given component, and the ``@map_environment`` decorator adds the display paired with its environment test function. When using :meth:`display() <cqparts.display.display>`, this display will be used if ``is_text_env()`` returns ``True``, and no previously mapped environment with a smaller ``order`` tested ``True``: .. doctest:: # create component to display from cqparts_misc.basic.primatives import Cube cube = Cube() # display component from cqparts.display import display display(cube) The ``display_callback`` will be called via :meth:`display() <DisplayEnvironment.display>`. So to call this display method directly: .. doctest:: TextDisplay().display(cube) :raises: NotImplementedError if not overridden """

        if type(self) is DisplayEnvironment:
            raise RuntimeError(
                ("%r is not a functional display environment, " % (type(self))) +
                "it's meant to be inherited by an implemented environment"
            )
        raise NotImplementedError(
            "display_callback function not overridden by %r" % (type(self))
        )