示例#1
0
    def type_reducer(o):
        attrs = OrderedDict()
        for name in o.__dict__:
            if name.startswith('_'):
                continue
            attrs[axon.as_name(name)] = getattr(o, name)

        return axon.node(axon.as_name(cls.__name__), attrs, None)
示例#2
0
    def type_reducer(o):
        attrs = []
        for name in o.__dict__:
            if name.startswith('_'):
                continue
            attrs.append((axon.as_name(name), getattr(o, name)))

        return axon.node(axon.as_name(cls.__name__), attrs, None)
示例#3
0
def reduce_ElementTree(e):
	attrs = {axon.as_unicode(name):val for name,val in e.attrib.items()}
	if e.text:
		vals = [e.text]
	else:
		vals = []
	for child in e.getchildren():
		vals.append(child)
		if child.tail:
			vals.append(child.tail)
			child.tail = None
	if len(attrs) == 0:
		attrs = None
	if len(vals) == 0:
		vals = None
	return axon.node(axon.as_unicode(e.tag), attrs, vals)
示例#4
0
文件: utils.py 项目: gelstudios/paper
def reduce_ElementTree(e):
	attrs = {axon.as_unicode(name):val for name,val in e.attrib.items()}
	if e.text:
		vals = [e.text]
	else:
		vals = []
	for child in e.getchildren():
		vals.append(child)
		if child.tail:
			vals.append(child.tail)
			child.tail = None
	if len(attrs) == 0:
		attrs = None
	if len(vals) == 0:
		vals = None
	return axon.node(axon.as_unicode(e.tag), attrs, vals)
示例#5
0
def reduce_edge(edge):
    return axon.node('edge', None, [edge.p1, edge.p2])
示例#6
0
def reduce_node(node):
    return axon.node('node', None, [node.x, node.y])
示例#7
0
def reduce_graph(graph):
    return axon.node('graph', {'nodes':graph.nodes, 
                               'edges':graph.edges}, None)
示例#8
0
def reduce_edge(edge):
    return axon.node('edge', None, [edge.p1, edge.p2])
示例#9
0
def reduce_node(node):
    return axon.node('node', None, [node.x, node.y])
示例#10
0
def reduce_graph(graph):
    return axon.node('graph', {'nodes':graph.nodes, 
                               'edges':graph.edges}, None)