code: def stat_file(path, saltenv='base', octal=True):
      '''
      Return the permissions of a file, to get the permissions of a file on the
      salt master file server prepend the path with salt://<file on server>
      otherwise, prepend the file with / for a local file.
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' cp.stat_file salt://path/to/file
      '''
      path, senv = salt.utils.url.split_env(path)
      if senv:
          saltenv = senv
  
      stat = _client().hash_and_stat_file(path, saltenv)[1]
      if stat is None:
          return stat
      return salt.utils.files.st_mode_to_octal(stat[0]) if octal is True else stat[0f stat_file(path, saltenv='base', octal=True):
      '''
      Return the permissions of a file, to get the permissions of a file on the
      salt master file server prepend the path with salt://<file on server>
      otherwise, prepend the file with / for a local file.
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' cp.stat_file salt://path/to/file
      '''
      path, senv = salt.utils.url.split_env(path)
      if senv:
          saltenv = senv
  
      stat = _client().hash_and_stat_file(path, saltenv)[1]
      if stat is None:
          return stat
      return salt.utils.files.st_mode_to_octal(stat[0]) if octal is True else stat[0]
docs: Return the permissions of a file, to get the permissions of a file on the
      salt master file server prepend the path with salt://<file on server>
      otherwise, prepend the file with / for a local file.
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' cp.stat_file salt://path/to/file