def touch(name, atime=None, mtime=None):
 name = os.path.expanduser(name)
 if (atime and atime.isdigit()):
  atime = int(atime)
 if (mtime and mtime.isdigit()):
  mtime = int(mtime)
 try:
  if (not os.path.exists(name)):
   with salt.utils.fopen(name, 'a') as fhw:
    fhw.write('')
  if ((not atime) and (not mtime)):
   times = None
  elif ((not mtime) and atime):
   times = (atime, time.time())
  elif ((not atime) and mtime):
   times = (time.time(), mtime)
  else:
   times = (atime, mtime)
  os.utime(name, times)
 except TypeError:
  raise SaltInvocationError('atime and mtime must be integers')
 except (IOError, OSError) as exc:
  raise CommandExecutionError(exc.strerror)
 return os.path.exists(name)

def touch ( name , atime = None , mtime = None ) : name = os . path . expanduser ( name ) if ( atime and atime . isdigit ( ) ) : atime = int ( atime ) if ( mtime and mtime . isdigit ( ) ) : mtime = int ( mtime ) try : if ( not os . path . exists ( name ) ) : with salt . utils . fopen ( name , 'a' ) as fhw : fhw . write ( '' ) if ( ( not atime ) and ( not mtime ) ) : times = None elif ( ( not mtime ) and atime ) : times = ( atime , time . time ( ) ) elif ( ( not atime ) and mtime ) : times = ( time . time ( ) , mtime ) else : times = ( atime , mtime ) os . utime ( name , times ) except TypeError : raise SaltInvocationError ( 'atime and mtime must be integers' ) except ( IOError , OSError ) as exc : raise CommandExecutionError ( exc . strerror ) return os . path . exists ( name )
touch generated files that are older than their sources after an update .