nodes: 0, module; 1, function_definition; 2, function_name:by_type; 3, parameters; 4, block; 5, identifier:blocks; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, return_statement; 14, identifier:slist; 15, None; 16, comment:"""Sort blocks into layout, internal volume, data or unknown
  
      Arguments:
      Obj:blocks   -- List of block objects.
      List:slist   -- (optional) List of block indexes.
  
      Returns:
      List:layout  -- List of block indexes of blocks containing the
                      volume table records.
      List:data    -- List of block indexes containing filesystem data.
      List:int_vol -- List of block indexes  containing volume ids 
                      greater than UBI_INTERNAL_VOL_START that are not
                      layout volumes.
      List:unknown -- List of block indexes of blocks that failed validation
                      of crc in ed_hdr or vid_hdr.
      """; 17, assignment; 18, assignment; 19, assignment; 20, assignment; 21, identifier:i; 22, identifier:blocks; 23, block; 24, expression_list; 25, identifier:layout; 26, list; 27, identifier:data; 28, list; 29, identifier:int_vol; 30, list; 31, identifier:unknown; 32, list; 33, if_statement; 34, if_statement; 35, identifier:layout; 36, identifier:data; 37, identifier:int_vol; 38, identifier:unknown; 39, boolean_operator; 40, block; 41, boolean_operator; 42, block; 43, elif_clause; 44, elif_clause; 45, else_clause; 46, identifier:slist; 47, comparison_operator:i not in slist; 48, continue_statement; 49, attribute; 50, attribute; 51, expression_statement; 52, boolean_operator; 53, block; 54, attribute; 55, block; 56, block; 57, identifier:i; 58, identifier:slist; 59, subscript; 60, identifier:is_vtbl; 61, subscript; 62, identifier:is_valid; 63, call; 64, attribute; 65, attribute; 66, expression_statement; 67, subscript; 68, identifier:is_valid; 69, expression_statement; 70, expression_statement; 71, identifier:blocks; 72, identifier:i; 73, identifier:blocks; 74, identifier:i; 75, attribute; 76, argument_list; 77, subscript; 78, identifier:is_internal_vol; 79, subscript; 80, identifier:is_valid; 81, call; 82, identifier:blocks; 83, identifier:i; 84, call; 85, call; 86, identifier:layout; 87, identifier:append; 88, identifier:i; 89, identifier:blocks; 90, identifier:i; 91, identifier:blocks; 92, identifier:i; 93, attribute; 94, argument_list; 95, attribute; 96, argument_list; 97, attribute; 98, argument_list; 99, identifier:int_vol; 100, identifier:append; 101, identifier:i; 102, identifier:data; 103, identifier:append; 104, identifier:i; 105, identifier:unknown; 106, identifier:append; 107, identifier:i
code: def by_type(blocks, slist=None):
      """Sort blocks into layout, internal volume, data or unknown
  
      Arguments:
      Obj:blocks   -- List of block objects.
      List:slist   -- (optional) List of block indexes.
  
      Returns:
      List:layout  -- List of block indexes of blocks containing the
                      volume table records.
      List:data    -- List of block indexes containing filesystem data.
      List:int_vol -- List of block indexes  containing volume ids 
                      greater than UBI_INTERNAL_VOL_START that are not
                      layout volumes.
      List:unknown -- List of block indexes of blocks that failed validation
                      of crc in ed_hdr or vid_hdr.
      """
  
      layout = []
      data = []
      int_vol = []
      unknown = []
      
      for i in blocks:
          if slist and i not in slist:
              continue
  
          if blocks[i].is_vtbl and blocks[i].is_valid:
              layout.append(i)
  
          elif blocks[i].is_internal_vol and blocks[i].is_valid:
              int_vol.append(i)
  
          elif blocks[i].is_valid:
              data.append(i)
  
          else:
              unknown.append(i)
  
      return layout, data, int_vol, unknown