def load_graph_xml(xml, filename, load_all=False):
 ret = []
 try:
  root = objectify.fromstring(xml)
 except Exception:
  return []
 if (root.tag != 'graphs'):
  return []
 if (not hasattr(root, 'graph')):
  return []
 for g in root.graph:
  name = g.attrib['name']
  expressions = [e.text for e in g.expression]
  if load_all:
   ret.append(GraphDefinition(name, e, g.description.text, expressions, filename))
   continue
  if have_graph(name):
   continue
  for e in expressions:
   if expression_ok(e):
    ret.append(GraphDefinition(name, e, g.description.text, expressions, filename))
    break
 return ret

def load_graph_xml ( xml , filename , load_all = False ) : ret = [ ] try : root = objectify . fromstring ( xml ) except Exception : return [ ] if ( root . tag != 'graphs' ) : return [ ] if ( not hasattr ( root , 'graph' ) ) : return [ ] for g in root . graph : name = g . attrib [ 'name' ] expressions = [ e . text for e in g . expression ] if load_all : ret . append ( GraphDefinition ( name , e , g . description . text , expressions , filename ) ) continue if have_graph ( name ) : continue for e in expressions : if expression_ok ( e ) : ret . append ( GraphDefinition ( name , e , g . description . text , expressions , filename ) ) break return ret
load a graph from one xml string .