本文整理汇总了Python中FileUtils.readDirectoryWithSubDirectories方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.readDirectoryWithSubDirectories方法的具体用法?Python FileUtils.readDirectoryWithSubDirectories怎么用?Python FileUtils.readDirectoryWithSubDirectories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils.readDirectoryWithSubDirectories方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readDirectoryWithSubDirectories [as 别名]
import Core
if Core.checkMandatoryModules():
from Core.MyObjects import *
import FileUtils as fu
fu.initStartupVariables()
from Core import Universals as uni
from Core import Execute
proFile = fu.joinPath(fu.HamsiManagerDirectory, "HamsiManager.pro")
proFileContent = "SOURCES = %SOURCES% \nTRANSLATIONS = %TRANSLATIONS%"""
SOURCES = ""
TRANSLATIONS = ""
directoriesAndFiles = fu.readDirectoryWithSubDirectories(fu.HamsiManagerDirectory)
for fileName in directoriesAndFiles:
if (fu.isFile(fileName) and fileName.find(".py") > -1 and
fileName.find(".pyc") == -1 and fileName.find(".pyw") == -1):
SOURCES += fileName.replace(fu.HamsiManagerDirectory + fu.sep, "") + " \\\n "
for fileName in ["Languages" + fu.sep + "HamsiManager_tr_TR.ts",
"Languages" + fu.sep + "HamsiManager_untranslated.ts"]:
TRANSLATIONS += fileName + " \\\n "
proFileContent = proFileContent.replace("%SOURCES%", SOURCES)
proFileContent = proFileContent.replace("%TRANSLATIONS%", TRANSLATIONS)
fu.writeToFile(proFile, proFileContent)
args = ["pylupdate4"]
示例2: install
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readDirectoryWithSubDirectories [as 别名]
def install(self):
try:
MApplication.processEvents()
self.installationDirectory = str(self.leInstallationDirectory.text())
if len(self.installationDirectory) > 0:
if self.installationDirectory[-1] == fu.sep:
self.installationDirectory = self.installationDirectory[:-1]
if self.installationDirectory == fu.HamsiManagerDirectory:
self.pageNo -= 1
self.lblActions.setText("")
Dialogs.showError(translate("Install", "The path you selected is not valid."),
translate("Install",
"The selected path is Hamsi Manager source directory.<br>Please choose a valid installation path."))
elif fu.isFile(self.installationDirectory) is False:
isMakeInstall = True
if fu.isDir(self.installationDirectory) is False:
self.lblActions.setText(translate("Install", "Creating Installation Folder..."))
fu.makeDirs(self.installationDirectory)
elif len(fu.listDir(self.installationDirectory)) > 0:
currenctAnswer = Dialogs.askSpecial(
translate("Install", "The Installation Path You Selected Is Not Empty."),
translate("Install",
"If the path you selected is an \"Hamsi Manager\" installation path, <b>I recommend you to delete the older files.</b><br>Do you want me to clear the installation path/folder for you?<br><b>Note: </b> Your personal settings are <b>never deleted</b>."),
translate("Install", "Yes (Recommended)"),
translate("Install", "No (Overwrite)"),
translate("Install", "Cancel"))
if currenctAnswer == translate("Install", "Yes (Recommended)"):
self.lblActions.setText(translate("Install", "Clearing Installation Path..."))
try:fu.removeFileOrDir(self.installationDirectory)
except:pass
fu.makeDirs(self.installationDirectory)
isMakeInstall = True
elif currenctAnswer == translate("Install", "No (Overwrite)"):
isMakeInstall = True
else:
isMakeInstall = False
if isMakeInstall:
Settings.setUniversalSetting("pathOfInstallationDirectory", self.installationDirectory)
directoriesAndFiles = fu.readDirectoryWithSubDirectories(fu.HamsiManagerDirectory)
self.prgbState.setRange(0, len(directoriesAndFiles))
self.lblActions.setText(translate("Install", "Copying Files And Folders..."))
installFileName = Execute.findExecutableBaseName("HamsiManagerInstaller")
for fileNo, fileName in enumerate(directoriesAndFiles):
MApplication.processEvents()
newFileName = self.installationDirectory + fileName.replace(fu.HamsiManagerDirectory,"")
if fu.isDir(fileName) and fileName.find(".svn") == -1:
try: fu.makeDirs(newFileName)
except: pass
elif (fu.isFile(fileName) and fu.getBaseName(fileName) != "install.py" and
fu.getBaseName(fileName) != installFileName and fileName.find(".svn") == -1):
try:
fu.copyFileOrDir(fileName, newFileName)
except:
fileContent = fu.readFromBinaryFile(fileName)
fu.writeToBinaryFile(newFileName, fileContent)
self.prgbState.setValue(fileNo + 1)
self.pageNo += 1
MyConfigure.installKDE4Languages()
else:
self.pageNo -= 1
else:
self.pageNo -= 1
self.lblActions.setText("")
Dialogs.showError(translate("Install", "The path you selected is not valid."),
translate("Install",
"The selected path points to a file not a folder.<br>Please choose a valid installation path."))
else:
self.pageNo -= 1
self.lblActions.setText("")
Dialogs.showError(translate("Install", "The path you selected is not valid."),
translate("Install",
"The selected path points to a file not a folder.<br>Please choose a valid installation path."))
self.pageChanged(True)
except:
from Core import ReportBug
ReportBug.ReportBug()