def WinChmod(filename, acl_list, user=None):
 if (user is None):
  user = win32api.GetUserName()
 if (not os.path.exists(filename)):
  raise RuntimeError(('filename %s does not exist' % filename))
 acl_bitmask = 0
 for acl in acl_list:
  acl_bitmask |= getattr(ntsecuritycon, acl)
 dacl = win32security.ACL()
 (win_user, _, _) = win32security.LookupAccountName('', user)
 dacl.AddAccessAllowedAce(win32security.ACL_REVISION, acl_bitmask, win_user)
 security_descriptor = win32security.GetFileSecurity(filename, win32security.DACL_SECURITY_INFORMATION)
 security_descriptor.SetSecurityDescriptorDacl(DACL_PRESENT, dacl, DACL_DEFAULT)
 win32security.SetFileSecurity(filename, win32security.DACL_SECURITY_INFORMATION, security_descriptor)

def WinChmod ( filename , acl_list , user = None ) : if ( user is None ) : user = win32api . GetUserName ( ) if ( not os . path . exists ( filename ) ) : raise RuntimeError ( ( 'filename %s does not exist' % filename ) ) acl_bitmask = 0 for acl in acl_list : acl_bitmask |= getattr ( ntsecuritycon , acl ) dacl = win32security . ACL ( ) ( win_user , _ , _ ) = win32security . LookupAccountName ( '' , user ) dacl . AddAccessAllowedAce ( win32security . ACL_REVISION , acl_bitmask , win_user ) security_descriptor = win32security . GetFileSecurity ( filename , win32security . DACL_SECURITY_INFORMATION ) security_descriptor . SetSecurityDescriptorDacl ( DACL_PRESENT , dacl , DACL_DEFAULT ) win32security . SetFileSecurity ( filename , win32security . DACL_SECURITY_INFORMATION , security_descriptor )
provide chmod-like functionality for windows .