本文整理汇总了Python中win32api.SetFileAttributes方法的典型用法代码示例。如果您正苦于以下问题:Python win32api.SetFileAttributes方法的具体用法?Python win32api.SetFileAttributes怎么用?Python win32api.SetFileAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32api
的用法示例。
在下文中一共展示了win32api.SetFileAttributes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rmtree
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import SetFileAttributes [as 别名]
def rmtree(self, path):
path = cygwin2nt(path)
for fname in os.listdir(path):
file_or_dir = os.path.join(path, fname)
if os.path.isdir(file_or_dir) and not os.path.islink(file_or_dir):
self.rmtree(file_or_dir) #it's a directory reucursive call to function again
else:
try:
os.remove(file_or_dir) #it's a file, delete it
except:
#probably failed because it is not a normal file
win32api.SetFileAttributes(file_or_dir, win32file.FILE_ATTRIBUTE_NORMAL)
os.remove(file_or_dir) #it's a file, delete it
os.rmdir(path) #delete the directory here
# os.path delegates
示例2: MakeDocumentWritable
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import SetFileAttributes [as 别名]
def MakeDocumentWritable(self):
pretend_ss = 0 # Set to 1 to test this without source safe :-)
if not self.scModuleName and not pretend_ss: # No Source Control support.
win32ui.SetStatusText("Document is read-only, and no source-control system is configured")
win32api.MessageBeep()
return 0
# We have source control support - check if the user wants to use it.
msg = "Would you like to check this file out?"
defButton = win32con.MB_YESNO
if self.IsModified():
msg = msg + "\r\n\r\nALL CHANGES IN THE EDITOR WILL BE LOST"
defButton = win32con.MB_YESNO
if win32ui.MessageBox(msg, None, defButton)!=win32con.IDYES:
return 0
if pretend_ss:
print "We are only pretending to check it out!"
win32api.SetFileAttributes(self.GetPathName(), win32con.FILE_ATTRIBUTE_NORMAL)
self.ReloadDocument()
return 1
# Now call on the module to do it.
if self.scModule is None:
try:
self.scModule = __import__(self.scModuleName)
for part in self.scModuleName.split('.')[1:]:
self.scModule = getattr(self.scModule, part)
except:
traceback.print_exc()
print "Error loading source control module."
return 0
if self.scModule.CheckoutFile(self.GetPathName()):
self.ReloadDocument()
return 1
return 0
示例3: SetFileAttributes
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import SetFileAttributes [as 别名]
def SetFileAttributes(self, name, flags):
name = cygwin2nt(name)
return win32file.SetFileAttributes(name, flags)
示例4: create_hidden_folder
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import SetFileAttributes [as 别名]
def create_hidden_folder(self):
if os.path.exists(path_to_files):
pass
else:
os.makedirs(path_to_files)
win32api.SetFileAttributes(path_to_files, win32con.FILE_ATTRIBUTE_HIDDEN)
示例5: set_hidden
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import SetFileAttributes [as 别名]
def set_hidden(self):
"""
Hides the settings file if possible.
"""
try:
import win32con
import win32api
win32api.SetFileAttributes(self.settings_file, win32con.FILE_ATTRIBUTE_HIDDEN)
except ImportError:
pass
示例6: tearDown
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import SetFileAttributes [as 别名]
def tearDown(self):
file = os.path.expanduser('~/.ctSESAM_test.pws')
if os.path.isfile(file):
try:
import win32con
import win32api
win32api.SetFileAttributes(file, win32con.FILE_ATTRIBUTE_NORMAL)
except ImportError:
pass
os.remove(file)
示例7: hide_file
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import SetFileAttributes [as 别名]
def hide_file(file_name):
"""Set a file as hidden."""
try:
win32api.SetFileAttributes(file_name, win32con.FILE_ATTRIBUTE_HIDDEN)
except win32api.error:
return False
return True
示例8: show_file
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import SetFileAttributes [as 别名]
def show_file(file_name):
"""Unset a file as hidden."""
try:
win32api.SetFileAttributes(file_name, win32con.FILE_ATTRIBUTE_NORMAL)
except win32api.error:
return False
return True
示例9:
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import SetFileAttributes [as 别名]
def 構建工程(工程路徑, 標題, 圖標=None):
if 圖標:
subprocess.Popen(f'{此處}\\構建用\\ResourceHacker.exe -open {此處}\\構建用\\沒有窗口的虛僞的exe.exe -save {標題}.exe -action addoverwrite -res {圖標} -mask ICONGROUP,1,0')
else:
os.system(f'copy {此處}\\構建用\\沒有窗口的虛僞的exe.exe {標題}.exe')
if os.path.isfile(f'_{標題}.kuzu'):
win32api.SetFileAttributes(f'_{標題}.kuzu', win32con.FILE_ATTRIBUTE_NORMAL)
with open(f'_{標題}.kuzu', 'w') as f:
f.write(f'Librian.py --project "{工程路徑}"')
win32api.SetFileAttributes(f'_{標題}.kuzu', win32con.FILE_ATTRIBUTE_HIDDEN)