def select_edges(docgraph, conditions, data):
    """yields all edges that meet the conditions given as eval strings"""
    for (src_id, target_id, edge_attribs) in docgraph.edges(data=True):
        # if all conditions are fulfilled
        # we need to add edge_attribs to the namespace eval is working in
        if all((eval(cond, {'edge_attribs': edge_attribs})
                for cond in conditions)):
            if data:
                yield (src_id, target_id, edge_attribs)
            else:
                yield (src_id, target_id)
def select_edges ( docgraph , conditions , data ) : for ( src_id , target_id , edge_attribs ) in docgraph . edges ( data = True ) : if all ( ( eval ( cond , { 'edge_attribs' : edge_attribs } ) for cond in conditions ) ) : if data : yield ( src_id , target_id , edge_attribs ) else : yield ( src_id , target_id )
yields all edges that meet the conditions given as eval strings