nodes: 0, module; 1, function_definition; 2, function_name:finish; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, expression_statement; 13, comment:# If we have any items, add them. Items are optional here.; 14, if_statement; 15, if_statement; 16, comment:# Attempt to set a view_mode if given; 17, if_statement; 18, comment:# Finalize the directory items; 19, expression_statement; 20, comment:# Return the cached list of all the list items that were added; 21, return_statement; 22, identifier:items; 23, None; 24, identifier:sort_methods; 25, None; 26, identifier:succeeded; 27, True; 28, identifier:update_listing; 29, False; 30, identifier:cache_to_disc; 31, True; 32, identifier:view_mode; 33, None; 34, string; 35, identifier:items; 36, block; 37, identifier:sort_methods; 38, block; 39, comparison_operator:view_mode is not None; 40, comment:# First check if we were given an integer or parseable integer; 41, block; 42, call; 43, attribute; 44, string_content:Adds the provided items to the XBMC interface.
  
          :param items: an iterable of items where each item is either a
              dictionary with keys/values suitable for passing to
              :meth:`xbmcswift2.ListItem.from_dict` or an instance of
              :class:`xbmcswift2.ListItem`.
          :param sort_methods: a list of valid XBMC sort_methods. Each item in
                               the list can either be a sort method or a tuple of
                               ``sort_method, label2_mask``. See
                               :meth:`add_sort_method` for
                               more detail concerning valid sort_methods.
  
                               Example call with sort_methods::
  
                                  sort_methods = ['label', 'title', ('date', '%D')]
                                  plugin.finish(items, sort_methods=sort_methods)
  
          :param view_mode: can either be an integer (or parseable integer
              string) corresponding to a view_mode or the name of a type of view.
              Currrently the only view type supported is 'thumbnail'.
          :returns: a list of all ListItems added to the XBMC interface.; 45, expression_statement; 46, for_statement; 47, identifier:view_mode; 48, None; 49, try_statement; 50, if_statement; 51, attribute; 52, argument_list; 53, identifier:self; 54, identifier:added_items; 55, call; 56, identifier:sort_method; 57, identifier:sort_methods; 58, block; 59, block; 60, except_clause; 61, comparison_operator:view_mode_id is not None; 62, block; 63, identifier:self; 64, identifier:end_of_directory; 65, identifier:succeeded; 66, identifier:update_listing; 67, identifier:cache_to_disc; 68, attribute; 69, argument_list; 70, if_statement; 71, expression_statement; 72, identifier:ValueError; 73, comment:# Attempt to lookup a view mode; 74, block; 75, identifier:view_mode_id; 76, None; 77, expression_statement; 78, identifier:self; 79, identifier:add_items; 80, identifier:items; 81, boolean_operator; 82, block; 83, else_clause; 84, assignment; 85, expression_statement; 86, call; 87, not_operator; 88, call; 89, expression_statement; 90, block; 91, identifier:view_mode_id; 92, call; 93, assignment; 94, attribute; 95, argument_list; 96, call; 97, identifier:hasattr; 98, argument_list; 99, call; 100, expression_statement; 101, identifier:int; 102, argument_list; 103, identifier:view_mode_id; 104, call; 105, identifier:self; 106, identifier:set_view_mode; 107, identifier:view_mode_id; 108, identifier:isinstance; 109, argument_list; 110, identifier:sort_method; 111, string; 112, attribute; 113, argument_list; 114, call; 115, identifier:view_mode; 116, attribute; 117, argument_list; 118, identifier:sort_method; 119, identifier:basestring; 120, string_content:__len__; 121, identifier:self; 122, identifier:add_sort_method; 123, list_splat; 124, attribute; 125, argument_list; 126, identifier:self; 127, identifier:get_view_mode_id; 128, identifier:view_mode; 129, identifier:sort_method; 130, identifier:self; 131, identifier:add_sort_method; 132, identifier:sort_method
code: def finish(self, items=None, sort_methods=None, succeeded=True,
                 update_listing=False, cache_to_disc=True, view_mode=None):
          '''Adds the provided items to the XBMC interface.
  
          :param items: an iterable of items where each item is either a
              dictionary with keys/values suitable for passing to
              :meth:`xbmcswift2.ListItem.from_dict` or an instance of
              :class:`xbmcswift2.ListItem`.
          :param sort_methods: a list of valid XBMC sort_methods. Each item in
                               the list can either be a sort method or a tuple of
                               ``sort_method, label2_mask``. See
                               :meth:`add_sort_method` for
                               more detail concerning valid sort_methods.
  
                               Example call with sort_methods::
  
                                  sort_methods = ['label', 'title', ('date', '%D')]
                                  plugin.finish(items, sort_methods=sort_methods)
  
          :param view_mode: can either be an integer (or parseable integer
              string) corresponding to a view_mode or the name of a type of view.
              Currrently the only view type supported is 'thumbnail'.
          :returns: a list of all ListItems added to the XBMC interface.
          '''
          # If we have any items, add them. Items are optional here.
          if items:
              self.add_items(items)
          if sort_methods:
              for sort_method in sort_methods:
                  if not isinstance(sort_method, basestring) and hasattr(sort_method, '__len__'):
                      self.add_sort_method(*sort_method)
                  else:
                      self.add_sort_method(sort_method)
  
          # Attempt to set a view_mode if given
          if view_mode is not None:
              # First check if we were given an integer or parseable integer
              try:
                  view_mode_id = int(view_mode)
              except ValueError:
                  # Attempt to lookup a view mode
                  view_mode_id = self.get_view_mode_id(view_mode)
  
              if view_mode_id is not None:
                  self.set_view_mode(view_mode_id)
  
          # Finalize the directory items
          self.end_of_directory(succeeded, update_listing, cache_to_disc)
  
          # Return the cached list of all the list items that were added
          return self.added_items