本文整理汇总了Python中bleachbit.FileUtilities.children_in_directory方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtilities.children_in_directory方法的具体用法?Python FileUtilities.children_in_directory怎么用?Python FileUtilities.children_in_directory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bleachbit.FileUtilities
的用法示例。
在下文中一共展示了FileUtilities.children_in_directory方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_updates
# 需要导入模块: from bleachbit import FileUtilities [as 别名]
# 或者: from bleachbit.FileUtilities import children_in_directory [as 别名]
def delete_updates():
"""Returns commands for deleting Windows Updates files"""
windir = bleachbit.expandvars('$windir')
dirs = glob.glob(os.path.join(windir, '$NtUninstallKB*'))
dirs += [bleachbit.expandvars('$windir\\SoftwareDistribution\\Download')]
dirs += [bleachbit.expandvars('$windir\\ie7updates')]
dirs += [bleachbit.expandvars('$windir\\ie8updates')]
if not dirs:
# if nothing to delete, then also do not restart service
return
import win32serviceutil
wu_running = win32serviceutil.QueryServiceStatus('wuauserv')[1] == 4
args = ['net', 'stop', 'wuauserv']
def wu_service():
General.run_external(args)
return 0
if wu_running:
yield Command.Function(None, wu_service, " ".join(args))
for path1 in dirs:
for path2 in FileUtilities.children_in_directory(path1, True):
yield Command.Delete(path2)
if os.path.exists(path1):
yield Command.Delete(path1)
args = ['net', 'start', 'wuauserv']
if wu_running:
yield Command.Function(None, wu_service, " ".join(args))
示例2: get_recycle_bin
# 需要导入模块: from bleachbit import FileUtilities [as 别名]
# 或者: from bleachbit.FileUtilities import children_in_directory [as 别名]
def get_recycle_bin():
"""Yield a list of files in the recycle bin"""
pidl = shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_BITBUCKET)
desktop = shell.SHGetDesktopFolder()
h = desktop.BindToObject(pidl, None, shell.IID_IShellFolder)
for item in h:
path = h.GetDisplayNameOf(item, shellcon.SHGDN_FORPARSING)
if os.path.isdir(path):
for child in FileUtilities.children_in_directory(path, True):
yield child
yield path
else:
yield path
示例3: get_walk_all
# 需要导入模块: from bleachbit import FileUtilities [as 别名]
# 或者: from bleachbit.FileUtilities import children_in_directory [as 别名]
def get_walk_all(top):
"""Delete files and directories inside a directory but not the top directory"""
for expanded in glob.iglob(top):
any_match = False
for path in FileUtilities.children_in_directory(
expanded, True):
any_match = True
yield path
# This is a lint checker because this scenario may
# indicate the cleaner developer made a mistake.
if not any_match and os.path.isfile(expanded):
logger.debug(
_('search="walk.all" used with regular file path="%s"'), expanded)
示例4: get_recycle_bin
# 需要导入模块: from bleachbit import FileUtilities [as 别名]
# 或者: from bleachbit.FileUtilities import children_in_directory [as 别名]
def get_recycle_bin():
"""Yield a list of files in the recycle bin"""
pidl = shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_BITBUCKET)
desktop = shell.SHGetDesktopFolder()
h = desktop.BindToObject(pidl, None, shell.IID_IShellFolder)
for item in h:
path = h.GetDisplayNameOf(item, shellcon.SHGDN_FORPARSING)
if os.path.isdir(path):
if not is_link(path):
# Return the contents of a normal directory, but do
# not recurse Windows symlinks in the Recycle Bin.
for child in FileUtilities.children_in_directory(path, True):
yield child
yield path
示例5: get_walk_files
# 需要导入模块: from bleachbit import FileUtilities [as 别名]
# 或者: from bleachbit.FileUtilities import children_in_directory [as 别名]
def get_walk_files(top):
for expanded in glob.iglob(top):
for path in FileUtilities.children_in_directory(expanded, False):
yield path
示例6: get_commands
# 需要导入模块: from bleachbit import FileUtilities [as 别名]
# 或者: from bleachbit.FileUtilities import children_in_directory [as 别名]
def get_commands(self, option_id):
# cache
if 'posix' == os.name and 'cache' == option_id:
dirname = expanduser("~/.cache/")
for filename in children_in_directory(dirname, True):
if not self.whitelisted(filename):
yield Command.Delete(filename)
# custom
if 'custom' == option_id:
for (c_type, c_path) in options.get_custom_paths():
if 'file' == c_type:
yield Command.Delete(c_path)
elif 'folder' == c_type:
yield Command.Delete(c_path)
for path in children_in_directory(c_path, True):
yield Command.Delete(path)
else:
raise RuntimeError(
'custom folder has invalid type %s' % c_type)
# menu
menu_dirs = ['~/.local/share/applications',
'~/.config/autostart',
'~/.gnome/apps/',
'~/.gnome2/panel2.d/default/launchers',
'~/.gnome2/vfolders/applications/',
'~/.kde/share/apps/RecentDocuments/',
'~/.kde/share/mimelnk',
'~/.kde/share/mimelnk/application/ram.desktop',
'~/.kde2/share/mimelnk/application/',
'~/.kde2/share/applnk']
if 'posix' == os.name and 'desktop_entry' == option_id:
for dirname in menu_dirs:
for filename in [fn for fn in children_in_directory(dirname, False)
if fn.endswith('.desktop')]:
if Unix.is_broken_xdg_desktop(filename):
yield Command.Delete(filename)
# unwanted locales
if 'posix' == os.name and 'localizations' == option_id:
for path in Unix.locales.localization_paths(locales_to_keep=options.get_languages()):
if os.path.isdir(path):
for f in FileUtilities.children_in_directory(path, True):
yield Command.Delete(f)
yield Command.Delete(path)
# Windows logs
if 'nt' == os.name and 'logs' == option_id:
paths = (
'$ALLUSERSPROFILE\\Application Data\\Microsoft\\Dr Watson\\*.log',
'$ALLUSERSPROFILE\\Application Data\\Microsoft\\Dr Watson\\user.dmp',
'$LocalAppData\\Microsoft\\Windows\\WER\\ReportArchive\\*\\*',
'$LocalAppData\\Microsoft\\Windows\WER\\ReportQueue\\*\\*',
'$programdata\\Microsoft\\Windows\\WER\\ReportArchive\\*\\*',
'$programdata\\Microsoft\\Windows\\WER\\ReportQueue\\*\\*',
'$localappdata\\Microsoft\\Internet Explorer\\brndlog.bak',
'$localappdata\\Microsoft\\Internet Explorer\\brndlog.txt',
'$windir\\*.log',
'$windir\\imsins.BAK',
'$windir\\OEWABLog.txt',
'$windir\\SchedLgU.txt',
'$windir\\ntbtlog.txt',
'$windir\\setuplog.txt',
'$windir\\REGLOCS.OLD',
'$windir\\Debug\\*.log',
'$windir\\Debug\\Setup\\UpdSh.log',
'$windir\\Debug\\UserMode\\*.log',
'$windir\\Debug\\UserMode\\ChkAcc.bak',
'$windir\\Debug\\UserMode\\userenv.bak',
'$windir\\Microsoft.NET\Framework\*\*.log',
'$windir\\pchealth\\helpctr\\Logs\\hcupdate.log',
'$windir\\security\\logs\\*.log',
'$windir\\security\\logs\\*.old',
'$windir\\SoftwareDistribution\\*.log',
'$windir\\SoftwareDistribution\\DataStore\\Logs\\*',
'$windir\\system32\\TZLog.log',
'$windir\\system32\\config\\systemprofile\\Application Data\\Microsoft\\Internet Explorer\\brndlog.bak',
'$windir\\system32\\config\\systemprofile\\Application Data\\Microsoft\\Internet Explorer\\brndlog.txt',
'$windir\\system32\\LogFiles\\AIT\\AitEventLog.etl.???',
'$windir\\system32\\LogFiles\\Firewall\\pfirewall.log*',
'$windir\\system32\\LogFiles\\Scm\\SCM.EVM*',
'$windir\\system32\\LogFiles\\WMI\\Terminal*.etl',
'$windir\\system32\\LogFiles\\WMI\\RTBackup\EtwRT.*etl',
'$windir\\system32\\wbem\\Logs\\*.lo_',
'$windir\\system32\\wbem\\Logs\\*.log', )
for path in paths:
expanded = expandvars(path)
for globbed in glob.iglob(expanded):
yield Command.Delete(globbed)
# memory
if sys.platform.startswith('linux') and 'memory' == option_id:
yield Command.Function(None, Memory.wipe_memory, _('Memory'))
# memory dump
# how to manually create this file
# http://www.pctools.com/guides/registry/detail/856/
#.........这里部分代码省略.........
示例7: get_walk_files
# 需要导入模块: from bleachbit import FileUtilities [as 别名]
# 或者: from bleachbit.FileUtilities import children_in_directory [as 别名]
def get_walk_files(top):
"""Delete files inside a directory but not any directories"""
for expanded in glob.iglob(top):
for path in FileUtilities.children_in_directory(expanded, False):
yield path