nodes: 0, module; 1, function_definition; 2, function_name:diff; 3, parameters; 4, block; 5, list_splat_pattern; 6, dictionary_splat_pattern; 7, expression_statement; 8, comment:# TODO: The salt execution module "cp.get_file_str file:///..." is a; 9, comment:# non-obvious way to display the differences between files using; 10, comment:# survey.diff .  A more obvious method needs to be found or developed.; 11, import_statement; 12, expression_statement; 13, expression_statement; 14, for_statement; 15, return_statement; 16, identifier:args; 17, identifier:kwargs; 18, string:'''
      Return the DIFFERENCE of the result sets returned by each matching minion
      pool
  
      .. versionadded:: 2014.7.0
  
      These pools are determined from the aggregated and sorted results of
      a salt command.
  
      This command displays the "diffs" as a series of 2-way differences --
      namely the difference between the FIRST displayed minion pool
      (according to sort order) and EACH SUBSEQUENT minion pool result set.
  
      Differences are displayed according to the Python ``difflib.unified_diff()``
      as in the case of the salt execution module ``file.get_diff``.
  
      This command is submitted via a salt runner using the general form::
  
          salt-run survey.diff [survey_sort=up/down] <target>
                       <salt-execution-module> <salt-execution-module parameters>
  
      Optionally accept a ``survey_sort=`` parameter. Default:
      ``survey_sort=down``
  
      CLI Example #1: (Example to display the "differences of files")
  
      .. code-block:: bash
  
          salt-run survey.diff survey_sort=up "*" cp.get_file_str file:///etc/hosts
      '''; 19, dotted_name; 20, assignment; 21, assignment; 22, identifier:k; 23, identifier:bulk_ret; 24, block; 25, identifier:bulk_ret; 26, identifier:difflib; 27, identifier:bulk_ret; 28, call; 29, identifier:is_first_time; 30, True; 31, expression_statement; 32, expression_statement; 33, expression_statement; 34, expression_statement; 35, if_statement; 36, expression_statement; 37, expression_statement; 38, expression_statement; 39, expression_statement; 40, for_statement; 41, expression_statement; 42, for_statement; 43, expression_statement; 44, expression_statement; 45, expression_statement; 46, expression_statement; 47, identifier:_get_pool_results; 48, argument_list; 49, call; 50, call; 51, call; 52, call; 53, identifier:is_first_time; 54, block; 55, assignment; 56, call; 57, call; 58, assignment; 59, identifier:i; 60, call; 61, block; 62, assignment; 63, identifier:i; 64, call; 65, block; 66, assignment; 67, augmented_assignment; 68, call; 69, call; 70, list_splat; 71, dictionary_splat; 72, identifier:print; 73, argument_list; 74, identifier:print; 75, argument_list; 76, identifier:print; 77, argument_list; 78, identifier:print; 79, argument_list; 80, expression_statement; 81, expression_statement; 82, expression_statement; 83, expression_statement; 84, continue_statement; 85, identifier:outs; 86, call; 87, identifier:print; 88, argument_list; 89, identifier:print; 90, argument_list; 91, identifier:from_result; 92, call; 93, identifier:range; 94, argument_list; 95, expression_statement; 96, identifier:to_result; 97, call; 98, identifier:range; 99, argument_list; 100, expression_statement; 101, identifier:outs; 102, string; 103, identifier:outs; 104, call; 105, identifier:print; 106, argument_list; 107, identifier:print; 108, argument_list; 109, identifier:args; 110, identifier:kwargs; 111, concatenated_string; 112, subscript; 113, concatenated_string; 114, binary_operator:'    ' + six.text_type(len(k['pool'])); 115, assignment; 116, call; 117, call; 118, call; 119, attribute; 120, argument_list; 121, identifier:outs; 122, binary_operator:'-' * (len(outs) - 1); 123, attribute; 124, argument_list; 125, integer:0; 126, call; 127, augmented_assignment; 128, attribute; 129, argument_list; 130, integer:0; 131, call; 132, augmented_assignment; 133, attribute; 134, argument_list; 135, identifier:outs; 136, string; 137, string; 138, identifier:k; 139, string; 140, string; 141, string; 142, string; 143, call; 144, identifier:is_first_time; 145, False; 146, identifier:print; 147, argument_list; 148, identifier:print; 149, argument_list; 150, identifier:print; 151, argument_list; 152, parenthesized_expression; 153, identifier:format; 154, subscript; 155, string; 156, parenthesized_expression; 157, subscript; 158, identifier:splitlines; 159, identifier:len; 160, argument_list; 161, subscript; 162, string; 163, subscript; 164, identifier:splitlines; 165, identifier:len; 166, argument_list; 167, subscript; 168, string; 169, string; 170, identifier:join; 171, call; 172, string_content; 173, string_content:------------; 174, string_content:pool; 175, string_content; 176, string_content:----------; 177, string_content:; 178, attribute; 179, argument_list; 180, concatenated_string; 181, binary_operator:'    ' + bulk_ret[0]['result']; 182, string:'differences from "{0}" results :'; 183, subscript; 184, integer:0; 185, string_content:-; 186, binary_operator:len(outs) - 1; 187, subscript; 188, string; 189, identifier:from_result; 190, identifier:from_result; 191, identifier:i; 192, string_content; 193, identifier:k; 194, string; 195, identifier:to_result; 196, identifier:to_result; 197, identifier:i; 198, string_content; 199, attribute; 200, argument_list; 201, escape_sequence:\n; 202, escape_sequence:\n; 203, identifier:six; 204, identifier:text_type; 205, call; 206, string; 207, string; 208, string; 209, subscript; 210, subscript; 211, string; 212, call; 213, integer:1; 214, identifier:bulk_ret; 215, integer:0; 216, string_content:result; 217, escape_sequence:\n; 218, string_content:result; 219, escape_sequence:\n; 220, identifier:difflib; 221, identifier:unified_diff; 222, identifier:from_result; 223, identifier:to_result; 224, keyword_argument; 225, keyword_argument; 226, keyword_argument; 227, identifier:len; 228, argument_list; 229, string_content; 230, string_content:------------; 231, string_content:; 232, subscript; 233, string; 234, identifier:bulk_ret; 235, integer:0; 236, string_content:pool; 237, identifier:len; 238, argument_list; 239, identifier:fromfile; 240, subscript; 241, identifier:tofile; 242, subscript; 243, identifier:n; 244, integer:0; 245, subscript; 246, escape_sequence:\n; 247, identifier:bulk_ret; 248, integer:0; 249, string_content:result; 250, identifier:outs; 251, subscript; 252, integer:0; 253, subscript; 254, integer:0; 255, identifier:k; 256, string; 257, subscript; 258, string; 259, identifier:k; 260, string; 261, string_content:pool; 262, identifier:bulk_ret; 263, integer:0; 264, string_content:pool; 265, string_content:pool
code: def diff(*args, **kwargs):
      '''
      Return the DIFFERENCE of the result sets returned by each matching minion
      pool
  
      .. versionadded:: 2014.7.0
  
      These pools are determined from the aggregated and sorted results of
      a salt command.
  
      This command displays the "diffs" as a series of 2-way differences --
      namely the difference between the FIRST displayed minion pool
      (according to sort order) and EACH SUBSEQUENT minion pool result set.
  
      Differences are displayed according to the Python ``difflib.unified_diff()``
      as in the case of the salt execution module ``file.get_diff``.
  
      This command is submitted via a salt runner using the general form::
  
          salt-run survey.diff [survey_sort=up/down] <target>
                       <salt-execution-module> <salt-execution-module parameters>
  
      Optionally accept a ``survey_sort=`` parameter. Default:
      ``survey_sort=down``
  
      CLI Example #1: (Example to display the "differences of files")
  
      .. code-block:: bash
  
          salt-run survey.diff survey_sort=up "*" cp.get_file_str file:///etc/hosts
      '''
      # TODO: The salt execution module "cp.get_file_str file:///..." is a
      # non-obvious way to display the differences between files using
      # survey.diff .  A more obvious method needs to be found or developed.
  
      import difflib
  
      bulk_ret = _get_pool_results(*args, **kwargs)
  
      is_first_time = True
      for k in bulk_ret:
          print('minion pool :\n'
                '------------')
          print(k['pool'])
          print('pool size :\n'
                '----------')
          print('    ' + six.text_type(len(k['pool'])))
          if is_first_time:
              is_first_time = False
              print('pool result :\n'
                    '------------')
              print('    ' + bulk_ret[0]['result'])
              print()
              continue
  
          outs = ('differences from "{0}" results :').format(
              bulk_ret[0]['pool'][0])
          print(outs)
          print('-' * (len(outs) - 1))
          from_result = bulk_ret[0]['result'].splitlines()
          for i in range(0, len(from_result)):
              from_result[i] += '\n'
          to_result = k['result'].splitlines()
          for i in range(0, len(to_result)):
              to_result[i] += '\n'
          outs = ''
          outs += ''.join(difflib.unified_diff(from_result,
                                               to_result,
                                               fromfile=bulk_ret[0]['pool'][0],
                                               tofile=k['pool'][0],
                                               n=0))
          print(outs)
          print()
  
      return bulk_ret