code: def win32_restrict_file_to_user(fname):
      """Secure a windows file to read-only access for the user.
      Follows guidance from win32 library creator:
      http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html
  
      This method should be executed against an already generated file which
      has no secrets written to it yet.
  
      Parameters
      ----------
  
      fname : unicode
          The path to the file to secure
      """
      import win32api
      import win32security
      import ntsecuritycon as con
  
      # everyone, _domain, _type = win32security.LookupAccountName("", "Everyone")
      admins = win32security.CreateWellKnownSid(
          win32security.WinBuiltinAdministratorsSid
      )
      user, _domain, _type = win32security.LookupAccountName(
          "", win32api.GetUserNameEx(win32api.NameSamCompatible)
      )
  
      sd = win32security.GetFileSecurity(
          fname, win32security.DACL_SECURITY_INFORMATION
      )
  
      dacl = win32security.ACL()
      # dacl.AddAccessAllowedAce(win32security.ACL_REVISION, con.FILE_ALL_ACCESS, everyone)
      dacl.AddAccessAllowedAce(
          win32security.ACL_REVISION,
          con.FILE_GENERIC_READ | con.FILE_GENERIC_WRITE,
          user,
      )
      dacl.AddAccessAllowedAce(
          win32security.ACL_REVISION, con.FILE_ALL_ACCESS, admins
      )
  
      sd.SetSecurityDescriptorDacl(1, dacl, 0)
      win32security.SetFileSecurity(
          fname, win32security.DACL_SECURITY_INFORMATION, sd
      )
  
imports: import os
  import sys
  import stat
  import errno
  import tempfile
  import warnings
  from ipython_genutils import py3compat
  from contextlib import contextmanager
  from distutils.util import strtobool
  from ipython_genutils import py3compat
label_desc: Use image node_id 12 for calling a global function with example usage: win32_restrict_file_to_user(fname) without return types