def SpliceContinuations(tree):
 def RecSplicer(node):
  'Inserts a continuation marker into the node.'
  if isinstance(node, pytree.Leaf):
   if node.prefix.lstrip().startswith('\\\n'):
    new_lineno = (node.lineno - node.prefix.count('\n'))
    return pytree.Leaf(type=format_token.CONTINUATION, value=node.prefix, context=('', (new_lineno, 0)))
   return None
  num_inserted = 0
  for (index, child) in enumerate(node.children[:]):
   continuation_node = RecSplicer(child)
   if continuation_node:
    node.children.insert((index + num_inserted), continuation_node)
    num_inserted += 1
 RecSplicer(tree)

def SpliceContinuations ( tree ) : def RecSplicer ( node ) : if isinstance ( node , pytree . Leaf ) : if node . prefix . lstrip ( ) . startswith ( '\\\n' ) : new_lineno = ( node . lineno - node . prefix . count ( '\n' ) ) return pytree . Leaf ( type = format_token . CONTINUATION , value = node . prefix , context = ( '' , ( new_lineno , 0 ) ) ) return None num_inserted = 0 for ( index , child ) in enumerate ( node . children [ : ] ) : continuation_node = RecSplicer ( child ) if continuation_node : node . children . insert ( ( index + num_inserted ) , continuation_node ) num_inserted += 1 RecSplicer ( tree )
given a pytree .