def _AdjustSplitPenalty(uwline):
 bracket_level = 0
 for (index, token) in enumerate(uwline.tokens):
  if (index and (not bracket_level)):
   pytree_utils.SetNodeAnnotation(token.node, pytree_utils.Annotation.SPLIT_PENALTY, split_penalty.UNBREAKABLE)
  if (token.value in pytree_utils.OPENING_BRACKETS):
   bracket_level += 1
  elif (token.value in pytree_utils.CLOSING_BRACKETS):
   bracket_level -= 1

def _AdjustSplitPenalty ( uwline ) : bracket_level = 0 for ( index , token ) in enumerate ( uwline . tokens ) : if ( index and ( not bracket_level ) ) : pytree_utils . SetNodeAnnotation ( token . node , pytree_utils . Annotation . SPLIT_PENALTY , split_penalty . UNBREAKABLE ) if ( token . value in pytree_utils . OPENING_BRACKETS ) : bracket_level += 1 elif ( token . value in pytree_utils . CLOSING_BRACKETS ) : bracket_level -= 1
visit the node and adjust the split penalties if needed .