def get_diff(minionfile, masterfile, saltenv='base'):
 minionfile = os.path.expanduser(minionfile)
 ret = ''
 if (not os.path.exists(minionfile)):
  ret = 'File {0} does not exist on the minion'.format(minionfile)
  return ret
 sfn = __salt__['cp.cache_file'](masterfile, saltenv)
 if sfn:
  with salt.utils.fopen(sfn, 'r') as src:
   slines = src.readlines()
  with salt.utils.fopen(minionfile, 'r') as name_:
   nlines = name_.readlines()
  if (''.join(nlines) != ''.join(slines)):
   bdiff = _binary_replace(minionfile, sfn)
   if bdiff:
    ret += bdiff
   else:
    ret += ''.join(difflib.unified_diff(nlines, slines, minionfile, masterfile))
 else:
  ret = 'Failed to copy file from master'
 return ret

def get_diff ( minionfile , masterfile , saltenv = 'base' ) : minionfile = os . path . expanduser ( minionfile ) ret = '' if ( not os . path . exists ( minionfile ) ) : ret = 'File {0} does not exist on the minion' . format ( minionfile ) return ret sfn = __salt__ [ 'cp.cache_file' ] ( masterfile , saltenv ) if sfn : with salt . utils . fopen ( sfn , 'r' ) as src : slines = src . readlines ( ) with salt . utils . fopen ( minionfile , 'r' ) as name_ : nlines = name_ . readlines ( ) if ( '' . join ( nlines ) != '' . join ( slines ) ) : bdiff = _binary_replace ( minionfile , sfn ) if bdiff : ret += bdiff else : ret += '' . join ( difflib . unified_diff ( nlines , slines , minionfile , masterfile ) ) else : ret = 'Failed to copy file from master' return ret
return the difference between 2 versions .