(yml)
return yo_deco
decorator for classes that needs to dump/load objects
    The tag for such objects is taken from the class attribute yaml_tag (or the
    class name in lowercase in case unavailable)
    If methods to_yaml and/or from_yaml are available, these are called for dumping resp.
    loading, default routines (dumping a mapping of the attributes) used otherwise.
decorator for classes that needs to dump/load objects
    The tag for such objects is taken from the class attribute yaml_tag (or the
    class name in lowercase in case unavailable)
    If methods to_yaml and/or from_yaml are available, these are called for dumping resp.
    loading, default routines (dumping a mapping of the attributes) used otherwise.
decorator for classes that needs to dump / load objects The tag for such objects is taken from the class attribute yaml_tag ( or the class name in lowercase in case unavailable ) If methods to_yaml and / or from_yaml are available these are called for dumping resp . loading default routines ( dumping a mapping of the attributes ) used otherwise .
def yaml_object(yml):
    # type: (Any) -> Any
    """ decorator for classes that needs to dump/load objects
    The tag for such objects is taken from the class attribute yaml_tag (or the
    class name in lowercase in case unavailable)
    If methods to_yaml and/or from_yaml are available, these are called for dumping resp.
    loading, default routines (dumping a mapping of the attributes) used otherwise.
    """

    def yo_deco(cls):
        # type: (Any) -> Any
        tag = getattr(cls, "yaml_tag", "!" + cls.__name__)
        try:
            yml.representer.add_representer(cls, cls.to_yaml)
        except AttributeError:

            def t_y(representer, data):
                # type: (Any, Any) -> Any
                return representer.represent_yaml_object(
                    tag, data, cls, flow_style=representer.default_flow_style
                )

            yml.representer.add_representer(cls, t_y)
        try:
            yml.constructor.add_constructor(tag, cls.from_yaml)
        except AttributeError:

            def f_y(constructor, node):
                # type: (Any, Any) -> Any
                return constructor.construct_yaml_object(node, cls)

            yml.constructor.add_constructor(tag, f_y)
        return cls

    return yo_deco
def yaml_object ( yml ) : # type: (Any) -> Any def yo_deco ( cls ) : # type: (Any) -> Any tag = getattr ( cls , "yaml_tag" , "!" + cls . __name__ ) try : yml . representer . add_representer ( cls , cls . to_yaml ) except AttributeError : def t_y ( representer , data ) : # type: (Any, Any) -> Any return representer . represent_yaml_object ( tag , data , cls , flow_style = representer . default_flow_style ) yml . representer . add_representer ( cls , t_y ) try : yml . constructor . add_constructor ( tag , cls . from_yaml ) except AttributeError : def f_y ( constructor , node ) : # type: (Any, Any) -> Any return constructor . construct_yaml_object ( node , cls ) yml . constructor . add_constructor ( tag , f_y ) return cls return yo_deco