nodes: 0, module; 1, function_definition; 2, function_name:repr_feature; 3, parameters; 4, block; 5, identifier:feature; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, if_statement; 12, assert_statement; 13, identifier:max_keys; 14, integer:100; 15, identifier:indent; 16, integer:8; 17, identifier:lexigraphic; 18, False; 19, string; 20, call; 21, block; 22, call; 23, block; 24, elif_clause; 25, else_clause; 26, False; 27, string; 28, string_content:generate a pretty-printed string for a feature
  
      Currently implemented:
        * StringCounter
  
      @max_keys: truncate long counters
  
      @indent: indent multi-line displays by this many spaces
  
      @lexigraphic: instead of sorting counters by count (default), sort
      keys lexigraphically; 29, identifier:isinstance; 30, argument_list; 31, try_statement; 32, identifier:isinstance; 33, argument_list; 34, return_statement; 35, call; 36, block; 37, block; 38, string_content:internal logic failure, no branch taken; 39, identifier:feature; 40, tuple; 41, block; 42, except_clause; 43, identifier:feature; 44, identifier:StringCounter; 45, call; 46, identifier:isinstance; 47, argument_list; 48, return_statement; 49, return_statement; 50, identifier:str; 51, identifier:bytes; 52, expression_statement; 53, return_statement; 54, comment:# failure to decode, not actually utf8, other binary data; 55, block; 56, identifier:repr_stringcounter; 57, argument_list; 58, identifier:feature; 59, identifier:unicode; 60, identifier:feature; 61, call; 62, assignment; 63, identifier:ustr; 64, return_statement; 65, identifier:feature; 66, identifier:max_keys; 67, identifier:indent; 68, identifier:lexigraphic; 69, identifier:repr; 70, argument_list; 71, identifier:ustr; 72, call; 73, call; 74, identifier:feature; 75, attribute; 76, argument_list; 77, identifier:repr; 78, argument_list; 79, identifier:feature; 80, identifier:decode; 81, string; 82, identifier:feature; 83, string_content:utf8
code: def repr_feature(feature, max_keys=100, indent=8, lexigraphic=False):
      '''
      generate a pretty-printed string for a feature
  
      Currently implemented:
        * StringCounter
  
      @max_keys: truncate long counters
  
      @indent: indent multi-line displays by this many spaces
  
      @lexigraphic: instead of sorting counters by count (default), sort
      keys lexigraphically
      '''
      if isinstance(feature, (str, bytes)):
          try:
              ustr = feature.decode('utf8')
              return ustr
          except:
              # failure to decode, not actually utf8, other binary data
              return repr(feature)
  
      if isinstance(feature, StringCounter):
          return repr_stringcounter(feature, max_keys, indent, lexigraphic)
      elif isinstance(feature, unicode):
          return feature
      else:
          return repr(feature)
  
      assert False, 'internal logic failure, no branch taken'