Function represent_data

Synopsis

def represent_data(self, data)

Description

No description yet.

Source

Lines 33-64 in lib3/yaml/representer.py.

def represent_data(self, data):
    if self.ignore_aliases(data):
        self.alias_key = None
    else:
        self.alias_key = id(data)
    if self.alias_key is not None:
        if self.alias_key in self.represented_objects:
            node = self.represented_objects[self.alias_key]
            #if node is None:
            #    raise RepresenterError("recursive objects are not allowed: %r" % data)
            return node
        #self.represented_objects[alias_key] = None
        self.object_keeper.append(data)
    data_types = type(data).__mro__
    if data_types[0] in self.yaml_representers:
        node = self.yaml_representers[data_types[0]](self, data)
    else:
        for data_type in data_types:
            if data_type in self.yaml_multi_representers:
                node = self.yaml_multi_representers[data_type](self, data)
                break
        else:
            if None in self.yaml_multi_representers:
                node = self.yaml_multi_representers[None](self, data)
            elif None in self.yaml_representers:
                node = self.yaml_representers[None](self, data)
            else:
                node = ScalarNode(None, str(data))
    #if alias_key is not None:
    #    self.represented_objects[alias_key] = node
    return node





Add Discussion as Guest

Log in