def _group_lengths(grouping):
 from itertools import chain, repeat
 if (not grouping):
  return []
 elif ((grouping[(-1)] == 0) and (len(grouping) >= 2)):
  return chain(grouping[:(-1)], repeat(grouping[(-2)]))
 elif (grouping[(-1)] == _locale.CHAR_MAX):
  return grouping[:(-1)]
 else:
  raise ValueError('unrecognised format for grouping')

def _group_lengths ( grouping ) : from itertools import chain , repeat if ( not grouping ) : return [ ] elif ( ( grouping [ ( - 1 ) ] == 0 ) and ( len ( grouping ) >= 2 ) ) : return chain ( grouping [ : ( - 1 ) ] , repeat ( grouping [ ( - 2 ) ] ) ) elif ( grouping [ ( - 1 ) ] == _locale . CHAR_MAX ) : return grouping [ : ( - 1 ) ] else : raise ValueError ( 'unrecognised format for grouping' )
convert a localeconv-style grouping into a iterable of integers representing group lengths .