本文整理汇总了Python中Core.Organizer类的典型用法代码示例。如果您正苦于以下问题:Python Organizer类的具体用法?Python Organizer怎么用?Python Organizer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Organizer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: emendDirectoryWithContents
def emendDirectoryWithContents(self):
try:
_path = self.checkSource(str(QuickMakeParameters[1]), "directory")
if _path is not None:
if uni.getBoolValue("isShowQuickMakeWindow"):
newEmendedName = str(self.leNewValue.text())
else:
newEmendedName = Organizer.emend(_path, fu.getObjectType(_path))
fu.activateSmartCheckIcon()
oldFileName = _path
newDirName = fu.moveOrChange(oldFileName, newEmendedName, "directory")
if newDirName != oldFileName:
fileAndDirectoryNames = fu.readDirectory(newDirName, "fileAndDirectory")
for fileAndDirs in fileAndDirectoryNames:
objectType = fu.getObjectType(fu.joinPath(newDirName, fileAndDirs))
fu.moveOrChange(fu.joinPath(newDirName, fileAndDirs),
fu.joinPath(newDirName, Organizer.emend(fileAndDirs, objectType)), objectType)
if uni.isActiveDirectoryCover and uni.getBoolValue(
"isActiveAutoMakeIconToDirectory") and uni.getBoolValue(
"isAutoMakeIconToDirectoryWhenFileMove"):
fu.checkIcon(newDirName)
if fu.isDir(newDirName):
fu.completeSmartCheckIcon()
Dialogs.show(translate("QuickMake", "Directory And Contents Emended"),
str(translate("QuickMake",
"\"%s\" is emended based on the criteria you set.This directory is \"%s\" now.")) %
(Organizer.getLink(_path), Organizer.getLink(newDirName)))
self.close()
except:
ReportBug.ReportBug()
示例2: changeFile
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"])
示例3: correctTable
def correctTable(self):
for rowNo in range(self.rowCount()):
for coloumKey in self.getWritableColumnKeys():
coloumNo = self.getColumnNoFromKey(coloumKey)
if self.isChangeableItem(rowNo, coloumKey):
if coloumKey == "baseNameOfDirectory":
newString = Organizer.emend(str(self.item(rowNo, coloumNo).text()), "directory")
else:
newString = Organizer.emend(str(self.item(rowNo, coloumNo).text()), "file")
self.item(rowNo, coloumNo).setText(str(newString))
示例4: apply
def apply(self):
self.checkCompleters()
self.reFillCompleters()
getMainTable().createHistoryPoint()
getMainTable().isAskShowHiddenColumn = True
selectedColumnKey = self.columns.currentData()
if selectedColumnKey == "all":
columnKeys = getMainTable().getWritableColumnKeys()
else:
columnKeys = [selectedColumnKey]
for columnKey in columnKeys:
columnNo = getMainTable().getColumnNoFromKey(columnKey)
if getMainTable().checkReadOnlyColumn(columnKey) is False:
continue
if getMainTable().checkHiddenColumn(columnKey, False) is False:
continue
for rowNo in range(getMainTable().rowCount()):
if getMainTable().isChangeableItem(rowNo, columnKey):
newString = str(getMainTable().item(rowNo, columnNo).text())
newString = uni.trDecode(newString, "utf-8")
informationSectionX = self.specialTools.cbInformationSectionX.value()
informationSectionY = self.specialTools.cbInformationSectionY.value()
isCaseInsensitive = self.cckbCaseInsensitive.isChecked()
oldString = str(self.leClear.text())
cbClearType = self.cbClearType.currentText()
isRegExp = self.cckbRegExp.isChecked()
myString = None
if self.specialTools.cbInformationSection.currentIndex() == 0:
myString = Organizer.clear(cbClearType, newString,
oldString, isCaseInsensitive, isRegExp)
elif self.specialTools.cbInformationSection.currentIndex() == 1:
myString = Organizer.clear(cbClearType, newString[:informationSectionX],
oldString, isCaseInsensitive, isRegExp)
myString += newString[informationSectionX:]
elif self.specialTools.cbInformationSection.currentIndex() == 2:
myString = newString[:informationSectionX]
myString += Organizer.clear(cbClearType, newString[informationSectionX:],
oldString, isCaseInsensitive, isRegExp)
elif self.specialTools.cbInformationSection.currentIndex() == 3:
myString = Organizer.clear(cbClearType, newString[:-informationSectionX],
oldString, isCaseInsensitive, isRegExp)
myString += newString[-informationSectionX:]
elif self.specialTools.cbInformationSection.currentIndex() == 4:
myString = newString[:-informationSectionX]
myString += Organizer.clear(cbClearType, newString[-informationSectionX:],
oldString, isCaseInsensitive, isRegExp)
elif self.specialTools.cbInformationSection.currentIndex() == 5:
myString = newString[:informationSectionX]
myString += Organizer.clear(cbClearType, newString[informationSectionX:informationSectionY],
oldString, isCaseInsensitive, isRegExp)
myString += newString[informationSectionY:]
elif self.specialTools.cbInformationSection.currentIndex() == 6:
myString = Organizer.clear(cbClearType, newString[:informationSectionX],
oldString, isCaseInsensitive, isRegExp)
myString += newString[informationSectionX:informationSectionY]
myString += Organizer.clear(cbClearType, newString[informationSectionY:],
oldString, isCaseInsensitive, isRegExp)
getMainTable().item(rowNo, columnNo).setText(str(myString))
示例5: changeFilePath
def changeFilePath(_oldPath, _newPath):
_oldPath, _newPath = str(_oldPath), str(_newPath)
withOutDevicePointValues, withOutDeviceValues = [], []
for devicePoint in getDevices():
if devicePoint[1] + "/" == _oldPath[:len(devicePoint[1]) + 1]:
if devicePoint[1] + "/" == _newPath[:len(devicePoint[1]) + 1]:
withOutDevicePointValues.append({"id": devicePoint[0],
"oldPath": Databases.correctForSql(_oldPath[len(devicePoint[1]):]),
"newPath": Databases.correctForSql(_newPath[len(devicePoint[1]):])
})
else:
withOutDeviceValues.append({"id": devicePoint[0],
"oldPath": Databases.correctForSql(_oldPath[len(devicePoint[1]):]),
"newPath": Databases.correctForSql(_newPath)
})
_oldPath, _newPath = Databases.correctForSql(_oldPath), Databases.correctForSql(_newPath)
_oldPathUrl, _newPathUrl = Databases.correctForSql(Organizer.quote(_oldPath)), Databases.correctForSql(Organizer.quote(_newPath))
db = Amarok.checkAndGetDB()
db.query("UPDATE urls SET rpath='.%s' WHERE rpath='.%s'" % (_newPath, _oldPath))
for withOutDevice in withOutDeviceValues:
directoryID = getOrInsertDirectory(fu.getDirName(withOutDevice["newPath"]), "-1")
db.query("UPDATE urls SET rpath='.%s', directory=%s, deviceid = -1 WHERE deviceid = %s and rpath = '.%s' " % (
withOutDevice["newPath"], directoryID, withOutDevice["id"], withOutDevice["oldPath"]))
for withOutDevicePoint in withOutDevicePointValues:
directoryID = getOrInsertDirectory(fu.getDirName(withOutDevicePoint["newPath"]), withOutDevicePoint["id"])
db.query("UPDATE urls SET rpath='.%s', directory=%s WHERE deviceid = %s and rpath = '.%s'" % (
withOutDevicePoint["newPath"], directoryID, withOutDevicePoint["id"], withOutDevicePoint["oldPath"]))
db.query("UPDATE images SET path='%s' WHERE path='%s'" % (_newPath, _oldPath))
db.query("UPDATE lyrics SET url='.%s' WHERE url='.%s'" % (_newPath, _oldPath))
db.query("UPDATE statistics_permanent SET url='file://%s' WHERE url='file://%s'" % (_newPathUrl, _oldPathUrl))
db.commit()
return True
示例6: readMusicFile
def readMusicFile(_filePath, _isAlertWhenNotAvailable=True):
_directoryPath = fu.getDirName(_filePath)
isCanNoncompatible = False
if fu.isReadableFileOrDir(_filePath):
tagger = Taggers.getTagger()
try:
tagger.loadFile(_filePath)
except:
Dialogs.showError(translate("FileUtils/Musics", "Incorrect Tag"),
str(translate("FileUtils/Musics",
"\"%s\" : this file has the incorrect tag so can't read tags.")
) % Organizer.getLink(_filePath))
if tagger.isAvailableFile() is False:
isCanNoncompatible = True
content = {}
content["path"] = _filePath
content["baseNameOfDirectory"] = fu.getBaseName(_directoryPath)
content["baseName"] = fu.getBaseName(_filePath)
content["artist"] = tagger.getArtist()
content["title"] = tagger.getTitle()
content["album"] = tagger.getAlbum()
content["albumArtist"] = tagger.getAlbumArtist()
content["trackNum"] = tagger.getTrackNum()
content["year"] = tagger.getYear()
content["genre"] = tagger.getGenre()
content["firstComment"] = tagger.getFirstComment()
content["firstLyrics"] = tagger.getFirstLyrics()
content["images"] = tagger.getImages()
if isCanNoncompatible and _isAlertWhenNotAvailable:
Dialogs.show(translate("FileUtils/Musics", "Possible ID3 Mismatch"),
translate("FileUtils/Musics",
"Some of the files presented in the table may not support ID3 technology.<br>Please check the files and make sure they support ID3 information before proceeding."))
return content
示例7: addImage
def addImage(self):
try:
if self.isActiveAddImage is False:
self.isActiveAddImage = True
self.pbtnAddImage.setText(translate("MusicDetails", "OK"))
self.pbtnSelectImage.show()
self.leImagePath.show()
self.lblImagePath.show()
self.lblImageType.show()
self.cbImageType.show()
self.pbtnCancelAddImage.show()
self.pbtnDeleteImage.hide()
self.pbtnSaveAsImage.hide()
else:
if fu.isFile(self.leImagePath.text()):
imageType = Taggers.getTagger().getImageTypesNo()[self.cbImageType.currentIndex()]
description = str(imageType)
Musics.writeMusicFile(self.musicValues, None, True, imageType, str(self.leImagePath.text()),
description)
self.changeFile(self.musicFile)
self.cancelAddImage()
else:
Dialogs.showError(translate("MusicDetails", "Image Does Not Exist"),
str(translate("MusicDetails", "\"%s\" does not exist.")
) % Organizer.getLink(str(self.leImagePath.text())))
except:
ReportBug.ReportBug()
示例8: changeDirectoryPath
def changeDirectoryPath(_oldPath, _newPath):
_oldPath, _newPath = str(_oldPath), str(_newPath)
withOutDevicePointValues, withOutDeviceValues = [], []
for devicePoint in getDevices():
if devicePoint[1] + "/" == _oldPath[:len(devicePoint[1]) + 1]:
if devicePoint[1] + "/" == _newPath[:len(devicePoint[1]) + 1]:
withOutDevicePointValues.append({"id": devicePoint[0],
"oldPath": Databases.correctForSql(_oldPath[len(devicePoint[1]):]),
"newPath": Databases.correctForSql(_newPath[len(devicePoint[1]):])
})
else:
withOutDeviceValues.append({"id": devicePoint[0],
"oldPath": Databases.correctForSql(_oldPath[len(devicePoint[1]):]),
"newPath": Databases.correctForSql(_newPath)
})
_oldPath, _newPath = Databases.correctForSql(_oldPath), Databases.correctForSql(_newPath)
_oldPathUrl, _newPathUrl = Databases.correctForSql(Organizer.quote(_oldPath)), Databases.correctForSql(Organizer.quote(_newPath))
db = Amarok.checkAndGetDB()
db.query("UPDATE directories SET dir=REPLACE(dir, '.%s/', '.%s/')" % (_oldPath, _newPath))
db.query("UPDATE urls SET rpath=REPLACE(rpath, '.%s/', '.%s/')" % (_oldPath, _newPath))
for withOutDevice in withOutDeviceValues:
db.query("UPDATE directories SET dir=REPLACE(dir, '.%s/', '.%s/'), deviceid = -1 WHERE deviceid = %s " % (
withOutDevice["oldPath"], withOutDevice["newPath"], withOutDevice["id"]))
db.query("UPDATE urls SET rpath=REPLACE(rpath, '.%s/', '.%s/'), deviceid = -1 WHERE deviceid = %s " % (
withOutDevice["oldPath"], withOutDevice["newPath"], withOutDevice["id"]))
for withOutDevicePoint in withOutDevicePointValues:
db.query("UPDATE directories SET dir=REPLACE(dir, '.%s/', '.%s/') WHERE deviceid = %s " % (
withOutDevicePoint["oldPath"], withOutDevicePoint["newPath"], withOutDevicePoint["id"]))
db.query("UPDATE urls SET rpath=REPLACE(rpath, '.%s/', '.%s/') WHERE deviceid = %s " % (
withOutDevicePoint["oldPath"], withOutDevicePoint["newPath"], withOutDevicePoint["id"]))
db.query("UPDATE images SET path=REPLACE(path, '%s/', '%s/')" % (_oldPath, _newPath))
db.query("UPDATE statistics_permanent SET url=REPLACE(url, '%s/', '%s/')" % (_oldPathUrl, _newPathUrl))
db.commit()
return True
示例9: getFromAmarok
def getFromAmarok(self):
try:
import Amarok
Dialogs.showState(translate("CoverTable", "Checking For Amarok..."), 0, 1)
if Amarok.checkAmarok():
from Amarok import Operations
directoriesAndValues = Operations.getDirectoriesAndValues()
Dialogs.showState(translate("CoverTable", "Values Are Being Processed"), 1, 1)
if directoriesAndValues is not None:
for rowNo in range(self.rowCount()):
if (getMainWindow().checkHiddenColumn("sourceCover") and
getMainWindow().checkHiddenColumn("destinationCover")):
if self.isChangeableItem(rowNo, "sourceCover"):
directoryPath = fu.joinPath(
fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
str(self.item(rowNo, 0).text()), str(self.item(rowNo, 1).text()))
if directoryPath in directoriesAndValues:
directoryAndValues = directoriesAndValues[directoryPath]
self.item(rowNo, 3).setText(
directoryAndValues["coverPath"][0].replace(directoryPath, "."))
self.item(rowNo, 4).setText("./" + Organizer.getIconName(
directoryAndValues["artist"][0],
directoryAndValues["album"][0],
directoryAndValues["genre"][0],
directoryAndValues["year"][0]))
except:
ReportBug.ReportBug()
示例10: __init__
def __init__(self, _filePath, _isOpenDetailsOnNewWindow):
global currentDialogs
_filePath = fu.checkSource(_filePath, "file")
if _filePath is not None:
if _isOpenDetailsOnNewWindow is False:
isHasOpenedDialog = False
for dialog in currentDialogs:
if dialog.isVisible():
isHasOpenedDialog = True
dialog.changeFile(_filePath)
dialog.activateWindow()
dialog.raise_()
break
if isHasOpenedDialog is False:
_isOpenDetailsOnNewWindow = True
if _isOpenDetailsOnNewWindow:
currentDialogs.append(self)
MDialog.__init__(self, MApplication.activeWindow())
if isActivePyKDE4:
self.setButtons(MDialog.NoDefault)
self.charSet = MComboBox()
self.charSet.addItems(uni.getCharSets())
self.charSet.setCurrentIndex(self.charSet.findText(uni.MySettings["fileSystemEncoding"]))
self.infoLabels = {}
self.infoValues = {}
self.fileValues = {}
pbtnClose = MPushButton(translate("TextDetails", "Close"))
pbtnSave = MPushButton(translate("TextDetails", "Save Changes"))
pbtnSave.setIcon(MIcon("Images:save.png"))
MObject.connect(pbtnClose, SIGNAL("clicked()"), self.close)
MObject.connect(pbtnSave, SIGNAL("clicked()"), self.save)
self.labels = [translate("TextDetails", "File Path : "),
translate("TextDetails", "Content : ")]
self.pnlMain = MWidget()
self.vblMain = MVBoxLayout(self.pnlMain)
self.pnlClearable = None
self.changeFile(_filePath, True)
HBOXs, VBOXs = [], []
VBOXs.append(MVBoxLayout())
HBOXs.append(MHBoxLayout())
HBOXs[-1].addWidget(self.charSet, 1)
HBOXs[-1].addWidget(pbtnSave, 4)
VBOXs[0].addLayout(HBOXs[-1])
VBOXs[0].addWidget(pbtnClose)
self.vblMain.addLayout(VBOXs[0], 1)
if isActivePyKDE4:
self.setMainWidget(self.pnlMain)
else:
self.setLayout(self.vblMain)
self.show()
self.setMinimumWidth(700)
self.setMinimumHeight(500)
else:
Dialogs.showError(translate("TextDetails", "File Does Not Exist"),
str(translate("TextDetails",
"\"%s\" does not exist.<br>Table will be refreshed automatically!<br>Please retry.")
) % Organizer.getLink(str(_filePath)))
if hasattr(getMainWindow(),
"FileManager") and getMainWindow().FileManager is not None: getMainWindow().FileManager.makeRefresh()
示例11: cellDoubleClickedTable
def cellDoubleClickedTable(self, _row, _column):
try:
if uni.getBoolValue("isRunOnDoubleClick"):
self.showTableDetails(_row, _column)
except:
Dialogs.showError(translate("SubFolderTable", "Cannot Open File"),
str(translate("SubFolderTable",
"\"%s\" : cannot be opened. Please make sure that you selected a text file.")
) % Organizer.getLink(self.values[_row]["path"]))
示例12: correctTable
def correctTable(self):
for rowNo in range(self.rowCount()):
for coloumKey in self.getWritableColumnKeys():
coloumNo = self.getColumnNoFromKey(coloumKey)
if self.isChangeableItem(rowNo, coloumKey):
newString = None
if coloumKey == "correctedArtist":
newString = Organizer.emend(str(self.item(rowNo, coloumNo).text()))
self.item(rowNo, coloumNo).setText(str(newString))
示例13: emendDirectory
def emendDirectory(self):
try:
_path = self.checkSource(str(QuickMakeParameters[1]), "directory")
if _path is not None:
if uni.getBoolValue("isShowQuickMakeWindow"):
newEmendedName = str(self.leNewValue.text())
else:
newEmendedName = Organizer.emend(_path, fu.getObjectType(_path))
oldFileName = _path
newDirName = fu.moveOrChange(oldFileName, newEmendedName, "directory")
if newDirName != oldFileName:
Dialogs.show(translate("QuickMake", "Directory Emended"),
str(translate("QuickMake",
"\"%s\" is emended based on the criteria you set.This directory is \"%s\" now.")) %
(Organizer.getLink(_path), Organizer.getLink(newDirName)))
self.close()
except:
ReportBug.ReportBug()
示例14: sendAndClose
def sendAndClose(self):
try:
uni.isCanBeShowOnMainWindow = False
self.namMain = MNetworkAccessManager(self)
self.connect(self.namMain, SIGNAL("finished (QNetworkReply *)"), self.sendFinished)
self.nrqPost = MNetworkRequest(MUrl("http://hamsiapps.com/ForMyProjects/SuggestIdea.php"))
self.nrpBack = self.namMain.post(self.nrqPost,
"p=HamsiManager&l=" + str(uni.MySettings["language"]) + "&v=" + str(
uni.intversion) +
"&thankYouMessages=new style" +
"&userNotes=" + Organizer.quote(str(self.teIdea.toHtml())) +
"&nameAndSurname=" + Organizer.quote(str(self.leName.text())) +
"&mail=" + Organizer.quote(str(self.leEMailAddress.text()))
)
self.connect(self.nrpBack, SIGNAL("downloadProgress (qint64,qint64)"), self.sending)
Dialogs.showState(translate("SuggestIdea", "Sending Your Idea"), 0, 100, True, self.cancelSending)
except:
ReportBug.ReportBug()
示例15: createWindow
def createWindow(self, _actionName, _makeThisAction, _isShowEmendWidgets):
from Options import OptionsForm
newOrChangedKeys = uni.newSettingsKeys + uni.changedDefaultValuesKeys
wOptionsPanel = OptionsForm.OptionsForm(None, QuickMakeParameters[0], None, newOrChangedKeys)
if MyDialogType == "MDialog":
if isActivePyKDE4:
self.setButtons(MyDialog.NoDefault)
elif MyDialogType == "MMainWindow":
self.setObjectName("Packager")
setMainWindow(self)
self.setWindowTitle(_actionName)
pnlMain = MWidget(self)
vblMain = MVBoxLayout(pnlMain)
pnlInfo = MWidget()
vblInfo = MVBoxLayout(pnlInfo)
vblInfo.addStretch(3)
if _isShowEmendWidgets:
lblOldValue = MLabel(translate("QuickMake", "Old Value : "))
lblNewValue = MLabel(translate("QuickMake", "New Value : "))
leOldValue = MLineEdit(str(fu.getRealPath(QuickMakeParameters[1])))
leOldValue.setEnabled(False)
self.leNewValue = MLineEdit(str(Organizer.emend(fu.getRealPath(QuickMakeParameters[1]),
fu.getObjectType(fu.getRealPath(QuickMakeParameters[1])))))
vblInfo.addWidget(lblOldValue)
vblInfo.addWidget(leOldValue)
vblInfo.addWidget(lblNewValue)
vblInfo.addWidget(self.leNewValue)
else:
lblValue = MLabel(translate("QuickMake", "Value : "))
leValue = MLineEdit(str(fu.getRealPath(QuickMakeParameters[1])))
leValue.setEnabled(False)
vblInfo.addWidget(lblValue)
vblInfo.addWidget(leValue)
vblInfo.addStretch(3)
pbtnApply = MPushButton(_actionName)
pbtnClose = MPushButton(translate("QuickMake", "Cancel"))
MObject.connect(pbtnApply, SIGNAL("clicked()"), _makeThisAction)
MObject.connect(pbtnClose, SIGNAL("clicked()"), self.close)
tabwTabs = MTabWidget()
tabwTabs.addTab(pnlInfo, translate("QuickMake", "Quick Make"))
tabwTabs.addTab(wOptionsPanel, translate("QuickMake", "Quick Make Options"))
vblMain.addWidget(tabwTabs)
hblBox = MHBoxLayout()
hblBox.addWidget(pbtnClose, 2)
hblBox.addWidget(pbtnApply, 3)
vblInfo.addLayout(hblBox)
if MyDialogType == "MDialog":
if isActivePyKDE4:
self.setMainWidget(pnlMain)
else:
self.setLayout(vblMain)
elif MyDialogType == "MMainWindow":
self.setCentralWidget(pnlMain)
moveToCenter(self)
self.setMinimumSize(450, 350)