本文整理汇总了Python中FileUtils.readTextFile方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.readTextFile方法的具体用法?Python FileUtils.readTextFile怎么用?Python FileUtils.readTextFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils.readTextFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: changeFile
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readTextFile [as 别名]
def changeFile(self, _filePath, _isNew=False):
self.fileValues = fu.readTextFile(_filePath, uni.MySettings["fileSystemEncoding"])
self.setWindowTitle(str(fu.getBaseName(self.fileValues["path"])))
if self.pnlClearable is not None:
clearAllChildren(self.pnlClearable, True)
self.pnlClearable = MWidget()
self.vblMain.insertWidget(0, self.pnlClearable, 20)
vblClearable = MVBoxLayout(self.pnlClearable)
self.infoLabels["path"] = MLabel(self.labels[0])
self.infoLabels["content"] = MLabel(self.labels[1])
dirPath = fu.getDirName(self.fileValues["path"])
baseName = fu.getBaseName(self.fileValues["path"])
self.infoValues["path"] = MLineEdit(str(fu.joinPath(dirPath, Organizer.emend(baseName, "file"))))
self.infoValues["content"] = MPlainTextEdit(
str(Organizer.emend(self.fileValues["content"], "text", False, True)))
self.infoValues["content"].setLineWrapMode(MPlainTextEdit.NoWrap)
self.sourceCharSet = MComboBox()
self.sourceCharSet.addItems(uni.getCharSets())
self.sourceCharSet.setCurrentIndex(self.sourceCharSet.findText(uni.MySettings["fileSystemEncoding"]))
MObject.connect(self.sourceCharSet, SIGNAL("currentIndexChanged(int)"), self.sourceCharSetChanged)
HBOXs = []
HBOXs.append(MHBoxLayout())
HBOXs[-1].addWidget(self.infoLabels["path"])
HBOXs[-1].addWidget(self.infoValues["path"])
HBOXs[-1].addWidget(self.sourceCharSet)
for hbox in HBOXs:
vblClearable.addLayout(hbox)
vblClearable.addWidget(self.infoLabels["content"])
vblClearable.addWidget(self.infoValues["content"])
示例2: fillValues
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readTextFile [as 别名]
def fillValues(self):
filePath = str(self.leFilePath.text())
if fu.isFile(filePath) and fu.isReadableFileOrDir(filePath):
self.fileValues = fu.readTextFile(filePath, str(self.sourceCharSet.currentText()))
self.pteFileContent.setPlainText(str(Organizer.emend(self.fileValues["content"], "text", False, True)))
self.isChangeSourceCharSetChanged = True
self.pbtnSave.setEnabled(True)
else:
self.isChangeSourceCharSetChanged = False
self.pbtnSave.setEnabled(False)
示例3: sourceCharSetChanged
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readTextFile [as 别名]
def sourceCharSetChanged(self):
try:
self.fileValues = fu.readTextFile(self.fileValues["path"], str(self.sourceCharSet.currentText()))
self.infoValues["content"].setPlainText(
str(Organizer.emend(self.fileValues["content"], "text", False, True)))
except:
Dialogs.showError(translate("TextDetails", "Incorrect File Encoding"),
str(translate("TextDetails",
"File can not decode by \"%s\" codec.<br>Please select another file encoding type.")
) % str(self.sourceCharSet.currentText()))