Example #1
0
def changeArtistValues(_values):
    uni.startThreadAction()
    allItemNumber = len(_values)
    Dialogs.showState(translate("Amarok/Operations", "Writing Music Tags"), 0, allItemNumber, True)
    for x, value in enumerate(_values):
        isContinueThreadAction = uni.isContinueThreadAction()
        if isContinueThreadAction:
            try:
                musicFilePathAndArtist = Commands.changeArtistValue(value)
                if musicFilePathAndArtist is not None:
                    artistName = musicFilePathAndArtist[0]
                    for musicFilePath in musicFilePathAndArtist[1]:
                        if fu.isWritableFileOrDir(musicFilePath, False, True):
                            Records.add(str(translate("Amarok/Operations", "File will be updated")), str(musicFilePath))
                            currentArtistName = ""
                            tagger = Taggers.getTagger()
                            if tagger is not None:
                                try:
                                    tagger.loadFileForWrite(musicFilePath)
                                    currentArtistName = tagger.getArtist()
                                except:
                                    tagger.loadFileForWrite(musicFilePath)
                                tagger.setArtist(artistName)
                                tagger.update()
                                Records.add(str(translate("Amarok/Operations", "Artist")), str(currentArtistName),
                                            artistName)
                    for musicFilePath in musicFilePathAndArtist[2]:
                        if fu.isWritableFileOrDir(musicFilePath, False, True):
                            Records.add(str(translate("Amarok/Operations", "File will be updated")), str(musicFilePath))
                            currentArtistName = ""
                            tagger = Taggers.getTagger()
                            if tagger is not None:
                                try:
                                    tagger.loadFileForWrite(musicFilePath)
                                    currentArtistName = tagger.getAlbumArtist()
                                except:
                                    tagger.loadFileForWrite(musicFilePath)
                                tagger.setAlbumArtist(artistName)
                                tagger.update()
                                Records.add(str(translate("Amarok/Operations", "albumArtist")), str(currentArtistName),
                                            artistName)
            except:
                ReportBug.ReportBug()
        else:
            allItemNumber = x + 1
        Dialogs.showState(translate("Amarok/Operations", "Writing Music Tags"), x + 1, allItemNumber, True)
        if isContinueThreadAction is False:
            break
    uni.finishThreadAction()
Example #2
0
 def checkSource(self, _oldPath, _objectType="fileAndDirectory", _isCheckWritable=True):
     _path = fu.checkSource(_oldPath, _objectType, False)
     if _path is None:
         if _objectType == "file":
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find File"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a file with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
         elif _objectType == "directory":
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find Directory"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a folder with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
         else:
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find File Or Directory"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a file or directory with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
     if _isCheckWritable:
         if fu.isWritableFileOrDir(_oldPath) is False:
             return None
     return _path
Example #3
0
 def clearEmptyDirectories(self):
     try:
         _path = self.checkSource(str(QuickMakeParameters[1]), "directory")
         if _path is not None:
             if fu.isWritableFileOrDir(_path):
                 fu.activateSmartCheckIcon()
                 fu.checkEmptyDirectories(_path, True, True, True, True)
                 if fu.isDir(_path):
                     fu.completeSmartCheckIcon()
                 Dialogs.show(translate("QuickMake", "Directory Cleaned"),
                              str(translate("QuickMake",
                                            "\"%s\" is cleaned based on the criteria you set.")) % Organizer.getLink(
                                  _path))
         self.close()
     except:
         ReportBug.ReportBug()
Example #4
0
 def reConfigure(self):
     try:
         oldPathOfExecutableHamsi = Settings.getUniversalSetting("HamsiManagerExecutableLinkPath", "/usr/bin/hamsi")
         if fu.isFile(fu.joinPath(fu.HamsiManagerDirectory, "HamsiManager.desktop")):
             if fu.isWritableFileOrDir(fu.joinPath(fu.HamsiManagerDirectory, "HamsiManager.desktop")):
                 MyConfigure.reConfigureFile(fu.joinPath(fu.HamsiManagerDirectory, "HamsiManager.desktop"))
         if self.isCreateDesktopShortcut is not None:
             if self.isCreateDesktopShortcut.checkState() == Mt.Checked:
                 desktopPath = uni.getUserDesktopPath()
                 if uni.isWindows:
                     MyConfigure.createShortCutFile(fu.joinPath(desktopPath, "Hamsi Manager.lnk"))
                 else:
                     fileContent = MyConfigure.getConfiguredDesktopFileContent()
                     fu.writeToFile(fu.joinPath(desktopPath, "HamsiManager.desktop"), fileContent)
         if uni.isRunningAsRoot():
             executableLink = str(self.leExecutableLink.text())
             if self.isCreateExecutableLink is not None:
                 if self.isCreateExecutableLink.checkState() == Mt.Checked:
                     if executableLink.strip() != "":
                         HamsiManagerFileName = Execute.findExecutableBaseName("HamsiManager")
                         if fu.isFile(executableLink):
                             fu.removeFileOrDir(executableLink)
                         fu.createSymLink(fu.joinPath(fu.HamsiManagerDirectory, HamsiManagerFileName),
                                          executableLink)
                         Settings.setUniversalSetting("HamsiManagerExecutableLinkPath", executableLink)
                         if oldPathOfExecutableHamsi != executableLink:
                             if fu.isFile(oldPathOfExecutableHamsi):
                                 answer = Dialogs.ask(translate("Reconfigure", "Other Hamsi Manager Was Detected"),
                                                      str(translate("Reconfigure",
                                                                    "Other Hamsi Manager executable file was detected. Are you want to delete old executable file? You can delete this old executable file : \"%s\"")) % (
                                                          oldPathOfExecutableHamsi))
                                 if answer != Dialogs.Yes:
                                     fu.removeFile(oldPathOfExecutableHamsi)
                     if fu.isDir("/usr/share/applications/"):
                         fileContent = MyConfigure.getConfiguredDesktopFileContent()
                         fu.writeToFile("/usr/share/applications/HamsiManager.desktop", fileContent)
         if uni.isRunningAsRoot() is False:
             if fu.isDir(fu.joinPath(fu.userDirectoryPath, ".local", "applications")) is False:
                 fu.makeDirs(fu.joinPath(fu.userDirectoryPath, ".local", "applications"))
             fileContent = MyConfigure.getConfiguredDesktopFileContent()
             fu.writeToFile(fu.joinPath(fu.userDirectoryPath, ".local", "applications", "HamsiManager.desktop"),
                            fileContent)
         MyConfigure.installKDE4Languages()
         self.isInstallFinished = True
     except:
         ReportBug.ReportBug()
Example #5
0
def writeMusicFile(_oldMusicTagsValues, _newMusicTagsValues, _isImageAction=False, _ImageType=False, _ImagePath=False,
                   _imageDescription=u""):
    if fu.isWritableFileOrDir(_oldMusicTagsValues["path"]):
        baseNameOfDirectory = _oldMusicTagsValues["baseNameOfDirectory"]
        baseName = _oldMusicTagsValues["baseName"]
        tagger = Taggers.getTagger()
        tagger.loadFileForWrite(_oldMusicTagsValues["path"])
        if _isImageAction is False:
            if _newMusicTagsValues["artist"] != _oldMusicTagsValues["artist"]:
                tagger.setArtist(str(_newMusicTagsValues["artist"]))
            if _newMusicTagsValues["title"] != _oldMusicTagsValues["title"]:
                tagger.setTitle(str(_newMusicTagsValues["title"]))
            if _newMusicTagsValues["album"] != _oldMusicTagsValues["album"]:
                tagger.setAlbum(str(_newMusicTagsValues["album"]))
            if _newMusicTagsValues["albumArtist"] != _oldMusicTagsValues["albumArtist"]:
                tagger.setAlbumArtist(str(_newMusicTagsValues["albumArtist"]))
            if _newMusicTagsValues["trackNum"] != _oldMusicTagsValues["trackNum"]:
                tagger.setTrackNum(_newMusicTagsValues["trackNum"])
            if _newMusicTagsValues["year"] != _oldMusicTagsValues["year"]:
                tagger.setDate(str(_newMusicTagsValues["year"]))
            if _newMusicTagsValues["genre"] != _oldMusicTagsValues["genre"]:
                tagger.setGenre(str(_newMusicTagsValues["genre"]))
            if _newMusicTagsValues["firstComment"] != _oldMusicTagsValues["firstComment"]:
                tagger.setFirstComment(str(_newMusicTagsValues["firstComment"]))
            if _newMusicTagsValues["firstLyrics"] != _oldMusicTagsValues["firstLyrics"]:
                tagger.setFirstLyrics(str(_newMusicTagsValues["firstLyrics"]))
            tagger.update()
            if _newMusicTagsValues["baseNameOfDirectory"] != _oldMusicTagsValues["baseNameOfDirectory"]:
                baseNameOfDirectory = str(_newMusicTagsValues["baseNameOfDirectory"])
            if _newMusicTagsValues["baseName"] != _oldMusicTagsValues["baseName"]:
                baseName = str(_newMusicTagsValues["baseName"])
            newFilePath = fu.joinPath(fu.getDirName(fu.getDirName(_oldMusicTagsValues["path"])), baseNameOfDirectory,
                                      baseName)
            if fu.getRealPath(_oldMusicTagsValues["path"]) != fu.getRealPath(newFilePath):
                return fu.moveOrChange(_oldMusicTagsValues["path"], newFilePath,
                                       fu.getObjectType(_oldMusicTagsValues["path"]))
        #Making changes on image files
        else:
            if _ImagePath is False:
                tagger.removeImage(_imageDescription)
            else:
                tagger.addImage(_ImageType, _ImagePath, _imageDescription)
            tagger.update()
            return None
    return _oldMusicTagsValues["path"]
    def downloadAndInstall(self):
        try:
            if uni.isBuilt() is False:
                if fu.isWritableFileOrDir(fu.HamsiManagerDirectory, True) is False:
                    from Core import Organizer

                    Dialogs.showError(translate("UpdateControl", "Access Denied"),
                                      str(translate("UpdateControl",
                                                    "\"%s\" : you do not have the necessary permissions to change this directory.<br />Please check your access controls and retry. <br />Note: You can run Hamsi Manager as root and try again.")) % Organizer.getLink(
                                          fu.HamsiManagerDirectory))
            self.setFixedHeight(130)
            self.isDownloading = True
            self.prgbState.setVisible(True)
            self.lblInfo.setVisible(False)
            self.setWindowTitle(translate("UpdateControl", "Downloading Latest Release..."))
            self.request = MNetworkRequest(MUrl(self.updateInformations[1]))
            self.willDownload(self.request)
        except:
            ReportBug.ReportBug()
Example #7
0
 def Clear(self):
     try:
         uni.isCanBeShowOnMainWindow = False
         answer = Dialogs.ask(translate("Cleaner", "Your Files Will Be Removed"),
                              str(translate("Cleaner",
                                            "The files in the \"%s\" folder will be cleared according to the criteria you set.<br>" +
                                            "This action will delete the files completely, without any chance to recover.<br>" +
                                            "Are you sure you want to perform the action?")) % Organizer.getLink(
                                  Organizer.getLink(str(self.lePathOfProject.text()))))
         if answer == Dialogs.Yes:
             if fu.isWritableFileOrDir(str(self.lePathOfProject.text())):
                 if fu.clearCleaningDirectory(str(self.lePathOfProject.text()), True, True):
                     Dialogs.show(translate("Cleaner", "Directory Is Cleared"),
                                  str(translate("Cleaner",
                                                "This directory is cleared : \"%s\"")) % Organizer.getLink(
                                      str(self.lePathOfProject.text())))
         uni.isCanBeShowOnMainWindow = True
     except:
         ReportBug.ReportBug()
    def writeContents(self):
        self.changedValueNumber = 0
        oldAndNewPathValues = []
        startRowNo, rowStep = 0, 1
        uni.startThreadAction()
        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/Covers", "Writing Cover Informations"), 0, allItemNumber, True)
        for rowNo in range(startRowNo, self.rowCount(), rowStep):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isWritableFileOrDir(self.values[rowNo]["path"], False, True):
                        if self.isRowHidden(rowNo):
                            fu.removeFileOrDir(self.values[rowNo]["path"])
                            self.changedValueNumber += 1
                        else:
                            pathOfParentDirectory = str(
                                self.values[rowNo]["pathOfParentDirectory"])
                            baseName = str(self.values[rowNo]["baseName"])
                            if self.isChangeableItem(rowNo, "sourceCover") or self.isChangeableItem(rowNo, "destinationCover"):
                                sourcePath = self.values[rowNo]["sourceCover"]
                                destinationPath = self.values[rowNo]["destinationCover"]
                                if self.isChangeableItem(rowNo, "sourceCover"):
                                    sourcePath = str(self.item(rowNo, 3).text()).strip()
                                if self.isChangeableItem(rowNo, "destinationCover"):
                                    destinationPath = str(self.item(rowNo, 4).text()).strip()
                                if (str(self.item(rowNo,
                                                  2).text()) != sourcePath or sourcePath != destinationPath or str(
                                    self.item(rowNo, 2).text()) != destinationPath) or (
                                            str(self.item(rowNo, 2).text()) !=
                                            self.values[rowNo]["currentCover"] and (
                                                str(self.item(rowNo, 2).text()) != sourcePath and str(
                                            self.item(rowNo, 2).text()) != destinationPath)):
                                    if str(self.item(rowNo, 3).text()).strip() != "":
                                        sourcePath = fu.getRealPath(sourcePath,
                                                                    self.values[rowNo]["path"])
                                        sourcePath = fu.checkSource(sourcePath, "file")
                                        if sourcePath is not None:
                                            if destinationPath != "":
                                                destinationPath = fu.getRealPath(destinationPath,
                                                                                 self.values[
                                                                                     rowNo]["path"])
                                                if sourcePath != destinationPath:
                                                    destinationPath = fu.moveOrChange(sourcePath, destinationPath)
                                            else:
                                                destinationPath = sourcePath
                                            fu.setIconToDirectory(self.values[rowNo]["path"],
                                                                  destinationPath)
                                            self.changedValueNumber += 1
                                    else:
                                        fu.setIconToDirectory(self.values[rowNo]["path"], "")
                                        self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "baseNameOfDirectory", pathOfParentDirectory):
                                pathOfParentDirectory = str(self.item(rowNo, 0).text())
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "baseName", baseName, False):
                                baseName = str(self.item(rowNo, 1).text())
                                self.changedValueNumber += 1
                            newFilePath = fu.joinPath(pathOfParentDirectory, baseName)
                            oldFilePath = fu.getRealPath(self.values[rowNo]["path"])
                            newFilePath = fu.getRealPath(newFilePath)
                            if oldFilePath != newFilePath:
                                oldAndNewPaths = {}
                                oldAndNewPaths["oldPath"] = oldFilePath
                                oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath, "directory")
                                if oldFilePath != oldAndNewPaths["newPath"]:
                                    oldAndNewPathValues.append(oldAndNewPaths)
                                    oldDirName = fu.getDirName(oldFilePath)
                                    if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                                        fu.checkEmptyDirectories(oldDirName, True, True,
                                                                 uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(translate("FileUtils/Covers", "Writing Cover Informations"), rowNo + 1, allItemNumber,
                              True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        if len(oldAndNewPathValues) > 0:
            from Amarok import Operations

            Operations.changePaths(oldAndNewPathValues)
        return True
Example #9
0
def clickedAnAction(_action):
    try:
        actionName = _action.objectName()
        if actionName == "Open State":
            f = Dialogs.getOpenFileName(translate("MenuBar", "Open State Of Hamsi Manager"),
                                        fu.userDirectoryPath,
                                        translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.openStateOfSettings(f)
        elif actionName == "Save State":
            f = Dialogs.getSaveFileName(translate("MenuBar", "Save State Of Hamsi Manager"),
                                        fu.joinPath(fu.userDirectoryPath, "HamsiManager.desktop"),
                                        translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.saveStateOfSettings(f)
                Dialogs.show(translate("MenuBar", "Current State Saved"),
                             translate("MenuBar",
                                       "Current state saved with preferences.<br>You can continue where you left off."))
        elif actionName == "With This Profile (My Settings)":
            if Execute.executeAsRootWithThread(["--sDirectoryPath", fu.pathOfSettingsDirectory], "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(translate("MenuBar", "Can Not Run As Root"),
                                  translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "With Root Profile (Own Settings)":
            if Execute.executeAsRootWithThread([], "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(translate("MenuBar", "Can Not Run As Root"),
                                  translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "Quit":
            getMainWindow().close()
        elif actionName == "HTML Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "html", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "html", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "html", "title")
        elif actionName == "Text Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "plainText", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "plainText", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "plainText", "title")
        elif actionName == "HTML Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "file", "html", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "dialog", "html", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "clipboard", "html", "fileTree",
                               "title")
        elif actionName == "Text Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "file", "plainText", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "dialog", "plainText", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "clipboard", "plainText",
                               "fileTree", "title")
        elif actionName == "About QT":
            if isActivePyKDE4:
                QMessageBox.aboutQt(getMainWindow(), translate("MenuBar", "About QT"))
            else:
                MMessageBox.aboutQt(getMainWindow(), translate("MenuBar", "About QT"))
        elif actionName == "Options":
            from Options import OptionsForm

            OptionsForm.OptionsForm(getMainWindow())
        elif actionName == "My Plugins":
            import MyPlugins

            MyPlugins.MyPlugins()
        elif actionName == "Reconfigure":
            from Tools import Configurator

            Configurator.Configurator("configurePage")
        elif actionName == "My Plugins (System)":
            Execute.execute(["--qm", "--plugins", "--runAsRoot"], "HamsiManager")
        elif actionName == "Reconfigure (System)":
            Execute.execute(["--qm", "--configurator", "--runAsRoot"], "HamsiManager")
        elif actionName == "Update":
            from Core import UpdateControl

            UpdateControl.UpdateControl(getMainWindow())
        elif actionName == "Report Bug":
            ReportBug.ReportBug(True)
        elif actionName == "Suggest Idea":
            from Core import SuggestIdea

            SuggestIdea.SuggestIdea()
        elif actionName == "About Hamsi Manager":
            if isActivePyKDE4 is False:
                MMessageBox.about(getMainWindow(), translate("MenuBar", "About Hamsi Manager"),
                                  uni.aboutOfHamsiManager)
        elif actionName == translate("ToolsBar", "Check Icon"):
            getMainWindow().setEnabled(False)
            fu.checkIcon(getMainWindow().FileManager.getCurrentDirectoryPath())
            Dialogs.show(translate("ToolsBar", "Directory Icon Checked"),
                         translate("ToolsBar",
                                   "Current directory icon checked.<br>The default action based on the data is executed."))
            getMainWindow().setEnabled(True)
        elif actionName == "Clear Empty Directories":
            if getMainTable().checkUnSavedValues() is False:
                _action.setChecked(False)
                return False
            answer = Dialogs.ask(translate("ToolsBar", "Empty Directories Will Be Removed"),
                                 str(translate("ToolsBar",
                                               "Are you sure you want to remove empty directories based on the criteria you set in \"%s\"?")) % Organizer.getLink(
                                     getMainWindow().FileManager.getCurrentDirectoryPath()))
            if answer == Dialogs.Yes:
                getMainWindow().setEnabled(False)
                currentDirPath = getMainWindow().FileManager.getCurrentDirectoryPath()
                if fu.isWritableFileOrDir(currentDirPath):
                    fu.checkEmptyDirectories(currentDirPath, True, True, True, True)
                    Dialogs.show(translate("ToolsBar", "Directory Cleaned"),
                                 translate("ToolsBar",
                                           "The current directory is cleaned based on the criteria you set."))
                getMainWindow().setEnabled(True)
                getMainWindow().FileManager.makeRefresh()
        elif actionName == "Pack":
            from Tools import Packager

            Packager.Packager(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Hash":
            from Tools import Hasher

            Hasher.Hasher(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Clear":
            from Tools import Cleaner

            Cleaner.Cleaner(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Text Corrector":
            from Tools import TextCorrector

            TextCorrector.TextCorrector(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "File Tree":
            from Tools import FileTreeBuilder

            FileTreeBuilder.FileTreeBuilder(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Search":
            from Tools import Searcher

            Searcher.Searcher([getMainWindow().FileManager.getCurrentDirectoryPath()])
        elif actionName == "Script Manager":
            from Tools import ScriptManager

            if ScriptManager.ScriptManager.checkScriptManager():
                ScriptManager.ScriptManager(getMainWindow())
        elif actionName == "Show Last Actions":
            from Core import RecordsForm

            RecordsForm.RecordsForm(getMainWindow())
        elif actionName == "Remove Sub Files":
            answer = Dialogs.ask(translate("ToolsBar", "All Files Will Be Removed"),
                                 str(translate("ToolsBar",
                                               "Are you sure you want to remove only all files in \"%s\"?<br>Note:Do not will remove directory and subfolders.")) % Organizer.getLink(
                                     getMainWindow().FileManager.getCurrentDirectoryPath()))
            if answer == Dialogs.Yes:
                getMainWindow().setEnabled(False)
                fu.removeOnlySubFiles(getMainWindow().FileManager.getCurrentDirectoryPath())
                getMainWindow().setEnabled(True)
                Dialogs.show(translate("ToolsBar", "Removed Only All Files"),
                             str(translate("ToolsBar",
                                           "Removed only all files in \"%s\".<br>Note:Do not removed directory and subfolders.")) % Organizer.getLink(
                                 getMainWindow().FileManager.getCurrentDirectoryPath()))
        elif actionName == "Amarok Embedded Database Configurator":
            import Amarok

            if Amarok.checkAmarok():
                Amarok.openEmbeddedDBConfigurator()
        elif _action.parent().objectName() == "Table Types":
            changeTableType(_action)
        elif _action.parent().objectName() == "File Renamer Types":
            changeReNamerType(_action)
        elif _action.parent().objectName() == "Scripts":
            from Core import Scripts

            Scripts.runScriptFile(fu.joinPath(Scripts.pathOfScripsDirectory, actionName))
        Records.saveAllRecords()
    except:
        ReportBug.ReportBug()
    def writeContents(self):
        self.changedValueNumber = 0
        uni.startThreadAction()
        import Amarok

        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), 0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if self.isRowHidden(rowNo) is False:
                        baseNameOfDirectory = str(self.values[rowNo]["baseNameOfDirectory"])
                        baseName = str(self.values[rowNo]["baseName"])
                        if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
                            baseNameOfDirectory = str(self.item(rowNo, 0).text())
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "baseName", baseName, False):
                            baseName = str(self.item(rowNo, 1).text())
                            self.changedValueNumber += 1
                        newFilePath = fu.getRealPath(
                            fu.joinPath(str(self.leDestinationDirPath.text()), baseNameOfDirectory,
                                        baseName))
                        if fu.isFile(self.values[rowNo]["path"]) and fu.isReadableFileOrDir(
                            self.values[rowNo]["path"], False, True):
                            if fu.isWritableFileOrDir(newFilePath, False, True):
                                newFilePathCopied = fu.copyOrChange(self.values[rowNo]["path"],
                                                                    newFilePath)
                                if self.values[rowNo]["path"] != newFilePathCopied:
                                    newFilePath = newFilePathCopied
                                    try:
                                        tagger = Taggers.getTagger()
                                        tagger.loadFileForWrite(newFilePath)
                                        if self.isChangeableItem(rowNo, "artist"):
                                            value = str(self.item(rowNo, 2).text())
                                            tagger.setArtist(value)
                                            Records.add(str(translate("MusicTable", "Artist")),
                                                        str(self.values[rowNo]["artist"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "title"):
                                            value = str(self.item(rowNo, 3).text())
                                            tagger.setTitle(value)
                                            Records.add(str(translate("MusicTable", "Title")),
                                                        str(self.values[rowNo]["title"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "album"):
                                            value = str(self.item(rowNo, 4).text())
                                            tagger.setAlbum(value)
                                            Records.add(str(translate("MusicTable", "Album")),
                                                        str(self.values[rowNo]["album"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "albumArtist"):
                                            value = str(self.item(rowNo, 5).text())
                                            tagger.setAlbumArtist(value)
                                            Records.add(str(translate("MusicTable", "Album Artist")),
                                                        str(self.values[rowNo]["albumArtist"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "trackNum"):
                                            value = str(self.item(rowNo, 6).text())
                                            tagger.setTrackNum(value)
                                            Records.add(str(translate("MusicTable", "Track No")),
                                                        str(self.values[rowNo]["trackNum"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "year"):
                                            value = str(self.item(rowNo, 7).text())
                                            tagger.setDate(value)
                                            Records.add(str(translate("MusicTable", "Year")),
                                                        str(self.values[rowNo]["year"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "genre"):
                                            value = str(self.item(rowNo, 8).text())
                                            tagger.setGenre(value)
                                            Records.add(str(translate("MusicTable", "Genre")),
                                                        str(self.values[rowNo]["genre"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "firstComment"):
                                            value = str(self.item(rowNo, 9).text())
                                            tagger.setFirstComment(value)
                                            Records.add(str(translate("MusicTable", "Comment")), str(
                                                self.values[rowNo]["firstComment"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "firstLyrics"):
                                            value = str(self.item(rowNo, 10).text())
                                            tagger.setFirstLyrics(value)
                                            Records.add(str(translate("MusicTable", "Lyrics")),
                                                        str(self.values[rowNo]["firstLyrics"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        tagger.update()
                                    except:
                                        Dialogs.showError(translate("MusicTable", "Tags Cannot Changed"),
                                                          str(translate("MusicTable",
                                                                        "\"%s\" : cannot be changed tags.")
                                                          ) % Organizer.getLink(newFilePath))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), rowNo + 1, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        return True
Example #11
0
    def writeContents(self):
        self.changedValueNumber = 0
        oldAndNewPathValues = []
        uni.startThreadAction()
        if uni.isActiveAmarok and uni.getBoolValue(
                "isFolderTableValuesChangeInAmarokDB"):
            import Amarok

            if Amarok.checkAmarok(True, False) is False:
                return False
        allItemNumber = len(self.values)
        Dialogs.showState(
            translate("FileUtils/Folders", "Writing Directory Informations"),
            0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isWritableFileOrDir(self.values[rowNo]["path"],
                                              False, True):
                        if self.isRowHidden(rowNo):
                            fu.removeFileOrDir(self.values[rowNo]["path"])
                            self.changedValueNumber += 1
                        else:
                            baseNameOfDirectory = str(
                                self.values[rowNo]["baseNameOfDirectory"])
                            baseName = str(self.values[rowNo]["baseName"])
                            if self.isChangeableItem(rowNo,
                                                     "baseNameOfDirectory",
                                                     baseNameOfDirectory):
                                baseNameOfDirectory = str(
                                    self.item(rowNo, 0).text())
                                self.changedValueNumber += 1
                                newDirectoryPath = fu.joinPath(
                                    fu.getDirName(
                                        fu.getDirName(
                                            self.values[rowNo]["path"])),
                                    baseNameOfDirectory)
                                self.setNewDirectory(newDirectoryPath)
                            if self.isChangeableItem(rowNo, "baseName",
                                                     baseName, False):
                                baseName = str(self.item(rowNo, 1).text())
                                self.changedValueNumber += 1
                            newFilePath = fu.joinPath(
                                fu.getDirName(
                                    fu.getDirName(self.values[rowNo]["path"])),
                                baseNameOfDirectory, baseName)

                            oldFilePath = fu.getRealPath(
                                self.values[rowNo]["path"])
                            newFilePath = fu.getRealPath(newFilePath)
                            if oldFilePath != newFilePath:
                                oldAndNewPaths = {}
                                oldAndNewPaths["oldPath"] = oldFilePath
                                oldAndNewPaths["newPath"] = fu.moveOrChange(
                                    oldFilePath, newFilePath,
                                    fu.getObjectType(oldFilePath))
                                if oldFilePath != oldAndNewPaths["newPath"]:
                                    oldAndNewPathValues.append(oldAndNewPaths)
                                    oldDirName = fu.getDirName(oldFilePath)
                                    if uni.getBoolValue(
                                            "isClearEmptyDirectoriesWhenFileMove"
                                    ):
                                        fu.checkEmptyDirectories(
                                            oldDirName, True, True,
                                            uni.getBoolValue(
                                                "isAutoCleanSubFolderWhenFileMove"
                                            ))
                                    if (uni.isActiveDirectoryCover
                                            and uni.getBoolValue(
                                                "isActiveAutoMakeIconToDirectory"
                                            ) and uni.getBoolValue(
                                                "isAutoMakeIconToDirectoryWhenFileMove"
                                            ) and fu.getObjectType(oldFilePath)
                                            == "file"):
                                        fu.checkIcon(oldDirName)
                                        fu.checkIcon(
                                            fu.getDirName(
                                                oldAndNewPaths["newPath"]))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(
                translate("FileUtils/Folders",
                          "Writing Directory And File Informations"),
                rowNo + 1, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        if (uni.isActiveAmarok
                and uni.getBoolValue("isFolderTableValuesChangeInAmarokDB")
                and len(oldAndNewPathValues) > 0):
            import Amarok
            from Amarok import Operations

            Operations.changePaths(oldAndNewPathValues)
        return True
Example #12
0
    def writeContents(self):
        self.changedValueNumber = 0
        oldAndNewPathValues = []
        changingTags = []
        isNewDirectoriesSame = True
        isMovedToNewDirectory = False
        currentDirectoryPath = ""
        newDirectoryPath = ""
        if uni.isActiveAmarok and uni.getBoolValue("isMusicTableValuesChangeInAmarokDB"):
            import Amarok

            if Amarok.checkAmarok(True, False) is False:
                return False
        uni.startThreadAction()
        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), 0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    changingTag = {"path": self.values[rowNo]["path"]}
                    if fu.isWritableFileOrDir(self.values[rowNo]["path"], False, True):
                        if self.isRowHidden(rowNo):
                            fu.removeFileOrDir(self.values[rowNo]["path"])
                            self.changedValueNumber += 1
                        else:
                            baseNameOfDirectory = str(
                                self.values[rowNo]["baseNameOfDirectory"])
                            baseName = str(self.values[rowNo]["baseName"])
                            tagger = Taggers.getTagger()
                            tagger.loadFileForWrite(self.values[rowNo]["path"])
                            isCheckLike = (tagger.isNeedUpdate or
                                           (uni.isActiveAmarok and
                                            uni.getBoolValue("isMusicTableValuesChangeInAmarokDB")))
                            if self.isChangeableItem(rowNo, "artist", self.values[rowNo]["artist"], True, isCheckLike):
                                value = str(self.item(rowNo, 2).text())
                                tagger.setArtist(value)
                                changingTag["artist"] = value
                                Records.add(str(translate("MusicTable", "Artist")),
                                            str(self.values[rowNo]["artist"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "title", self.values[rowNo]["title"], True, isCheckLike):
                                value = str(self.item(rowNo, 3).text())
                                tagger.setTitle(value)
                                changingTag["title"] = value
                                Records.add(str(translate("MusicTable", "Title")),
                                            str(self.values[rowNo]["title"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "album", self.values[rowNo]["album"], True, isCheckLike):
                                value = str(self.item(rowNo, 4).text())
                                tagger.setAlbum(value)
                                changingTag["album"] = value
                                Records.add(str(translate("MusicTable", "Album")),
                                            str(self.values[rowNo]["album"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "albumArtist", self.values[rowNo]["albumArtist"], True,
                                                     isCheckLike):
                                value = str(self.item(rowNo, 5).text())
                                tagger.setAlbumArtist(value)
                                changingTag["albumArtist"] = value
                                Records.add(str(translate("MusicTable", "Album Artist")),
                                            str(self.values[rowNo]["albumArtist"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "trackNum", self.values[rowNo]["trackNum"],
                                                     True, isCheckLike):
                                value = str(self.item(rowNo, 6).text())
                                tagger.setTrackNum(value)
                                changingTag["trackNum"] = value
                                Records.add(str(translate("MusicTable", "Track No")),
                                            str(self.values[rowNo]["trackNum"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "year", self.values[rowNo]["year"], True, isCheckLike):
                                value = str(self.item(rowNo, 7).text())
                                tagger.setDate(value)
                                changingTag["year"] = value
                                Records.add(str(translate("MusicTable", "Year")),
                                            str(self.values[rowNo]["year"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "genre", self.values[rowNo]["genre"], True, isCheckLike):
                                value = str(self.item(rowNo, 8).text())
                                tagger.setGenre(value)
                                changingTag["genre"] = value
                                Records.add(str(translate("MusicTable", "Genre")),
                                            str(self.values[rowNo]["genre"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "firstComment", self.values[rowNo]["firstComment"],
                                                     True, isCheckLike):
                                value = str(self.item(rowNo, 9).text())
                                tagger.setFirstComment(value)
                                changingTag["firstComment"] = value
                                Records.add(str(translate("MusicTable", "Comment")),
                                            str(self.values[rowNo]["firstComment"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "firstLyrics", self.values[rowNo]["firstLyrics"],
                                                     True, isCheckLike):
                                value = str(self.item(rowNo, 10).text())
                                tagger.setFirstLyrics(value)
                                changingTag["firstLyrics"] = value
                                Records.add(str(translate("MusicTable", "Lyrics")),
                                            str(self.values[rowNo]["firstLyrics"]), value)
                                self.changedValueNumber += 1
                            if len(changingTag) > 1:
                                changingTags.append(changingTag)
                            tagger.update()
                            if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
                                baseNameOfDirectory = str(self.item(rowNo, 0).text())
                                self.changedValueNumber += 1
                                isMovedToNewDirectory = True
                                currentDirectoryPath = fu.getDirName(
                                    self.values[rowNo]["path"])
                                newDirectoryPath = fu.joinPath(
                                    fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                    baseNameOfDirectory)
                                self.setNewDirectory(newDirectoryPath)
                                if rowNo > 0:
                                    if str(self.item(rowNo - 1, 0).text()) != baseNameOfDirectory:
                                        isNewDirectoriesSame = False
                            if self.isChangeableItem(rowNo, "baseName", baseName, False):
                                baseName = str(self.item(rowNo, 1).text())
                                self.changedValueNumber += 1
                            newFilePath = fu.joinPath(
                                fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                baseNameOfDirectory, baseName)
                            oldFilePath = fu.getRealPath(self.values[rowNo]["path"])
                            newFilePath = fu.getRealPath(newFilePath)
                            if oldFilePath != newFilePath:
                                oldAndNewPaths = {}
                                oldAndNewPaths["oldPath"] = oldFilePath
                                oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath, "file")
                                if oldFilePath != oldAndNewPaths["newPath"]:
                                    oldAndNewPathValues.append(oldAndNewPaths)
                                    oldDirName = fu.getDirName(oldFilePath)
                                    if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                                        fu.checkEmptyDirectories(oldDirName, True, True,
                                                                 uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags And Informations"), rowNo + 1, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        if self.rowCount() == len(oldAndNewPathValues) and isMovedToNewDirectory and isNewDirectoriesSame:
            otherFileNames = fu.readDirectory(currentDirectoryPath, "fileAndDirectory", True)
            if len(otherFileNames) > 0:
                answer = Dialogs.ask(translate("FileUtils/Musics", "There Are More Files"),
                                     str(translate("FileUtils/Musics",
                                                   "\"%s\" : there are more files in this directory.<br>Are you want to move all found files into new directory?<br>New Directory : \"%s\"")) % (
                                         Organizer.getLink(currentDirectoryPath), Organizer.getLink(newDirectoryPath)))
                if answer == Dialogs.Yes:
                    uni.startThreadAction()
                    allItemNumber = len(otherFileNames)
                    for rowNo, fileName in enumerate(otherFileNames):
                        isContinueThreadAction = uni.isContinueThreadAction()
                        if isContinueThreadAction:
                            try:
                                oldFilePath = fu.getRealPath(fu.joinPath(currentDirectoryPath, fileName))
                                newFilePath = fu.getRealPath(fu.joinPath(newDirectoryPath, fileName))
                                if oldFilePath != newFilePath:
                                    oldAndNewPaths = {}
                                    oldAndNewPaths["oldPath"] = oldFilePath
                                    oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath,
                                                                                fu.getObjectType(oldFilePath))
                                    if oldFilePath != oldAndNewPaths["newPath"]:
                                        oldAndNewPathValues.append(oldAndNewPaths)
                            except:
                                ReportBug.ReportBug()
                        else:
                            allItemNumber = rowNo + 1
                        Dialogs.showState(translate("FileUtils/Covers", "Writing Directory And File Informations"),
                                          rowNo + 1, allItemNumber, True)
                        if isContinueThreadAction is False:
                            break
                    uni.finishThreadAction()
                    if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                        fu.checkEmptyDirectories(currentDirectoryPath, True, True,
                                                 uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                    if (uni.isActiveDirectoryCover and uni.getBoolValue("isActiveAutoMakeIconToDirectory") and
                            uni.getBoolValue("isAutoMakeIconToDirectoryWhenFileMove")):
                        fu.checkIcon(newDirectoryPath)
        if uni.isActiveAmarok and uni.getBoolValue("isMusicTableValuesChangeInAmarokDB"):
            import Amarok
            from Amarok import Operations

            Operations.changeTags(changingTags)
            if len(oldAndNewPathValues) > 0:
                Operations.changePaths(oldAndNewPathValues, "file")
        return True
Example #13
0
 def reConfigure(self):
     try:
         oldPathOfExecutableHamsi = Settings.getUniversalSetting(
             "HamsiManagerExecutableLinkPath", "/usr/bin/hamsi")
         if fu.isFile(
                 fu.joinPath(fu.HamsiManagerDirectory,
                             "HamsiManager.desktop")):
             if fu.isWritableFileOrDir(
                     fu.joinPath(fu.HamsiManagerDirectory,
                                 "HamsiManager.desktop")):
                 MyConfigure.reConfigureFile(
                     fu.joinPath(fu.HamsiManagerDirectory,
                                 "HamsiManager.desktop"))
         if self.isCreateDesktopShortcut is not None:
             if self.isCreateDesktopShortcut.checkState() == Mt.Checked:
                 desktopPath = uni.getUserDesktopPath()
                 if uni.isWindows:
                     MyConfigure.createShortCutFile(
                         fu.joinPath(desktopPath, "Hamsi Manager.lnk"))
                 else:
                     fileContent = MyConfigure.getConfiguredDesktopFileContent(
                     )
                     fu.writeToFile(
                         fu.joinPath(desktopPath, "HamsiManager.desktop"),
                         fileContent)
         if uni.isRunningAsRoot():
             executableLink = str(self.leExecutableLink.text())
             if self.isCreateExecutableLink is not None:
                 if self.isCreateExecutableLink.checkState() == Mt.Checked:
                     if executableLink.strip() != "":
                         HamsiManagerFileName = Execute.findExecutableBaseName(
                             "HamsiManager")
                         if fu.isFile(executableLink):
                             fu.removeFileOrDir(executableLink)
                         fu.createSymLink(
                             fu.joinPath(fu.HamsiManagerDirectory,
                                         HamsiManagerFileName),
                             executableLink)
                         Settings.setUniversalSetting(
                             "HamsiManagerExecutableLinkPath",
                             executableLink)
                         if oldPathOfExecutableHamsi != executableLink:
                             if fu.isFile(oldPathOfExecutableHamsi):
                                 answer = Dialogs.ask(
                                     translate(
                                         "Reconfigure",
                                         "Other Hamsi Manager Was Detected"
                                     ),
                                     str(
                                         translate(
                                             "Reconfigure",
                                             "Other Hamsi Manager executable file was detected. Are you want to delete old executable file? You can delete this old executable file : \"%s\""
                                         )) % (oldPathOfExecutableHamsi))
                                 if answer != Dialogs.Yes:
                                     fu.removeFile(oldPathOfExecutableHamsi)
                     if fu.isDir("/usr/share/applications/"):
                         fileContent = MyConfigure.getConfiguredDesktopFileContent(
                         )
                         fu.writeToFile(
                             "/usr/share/applications/HamsiManager.desktop",
                             fileContent)
         if uni.isRunningAsRoot() is False:
             if fu.isDir(
                     fu.joinPath(fu.userDirectoryPath, ".local",
                                 "applications")) is False:
                 fu.makeDirs(
                     fu.joinPath(fu.userDirectoryPath, ".local",
                                 "applications"))
             fileContent = MyConfigure.getConfiguredDesktopFileContent()
             fu.writeToFile(
                 fu.joinPath(fu.userDirectoryPath, ".local", "applications",
                             "HamsiManager.desktop"), fileContent)
         MyConfigure.installKDE4Languages()
         self.isInstallFinished = True
     except:
         ReportBug.ReportBug()
Example #14
0
    def writeContents(self):
        self.changedValueNumber = 0
        uni.startThreadAction()
        import Amarok

        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"),
                          0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if self.isRowHidden(rowNo) is False:
                        baseNameOfDirectory = str(
                            self.values[rowNo]["baseNameOfDirectory"])
                        baseName = str(self.values[rowNo]["baseName"])
                        if self.isChangeableItem(rowNo, "baseNameOfDirectory",
                                                 baseNameOfDirectory):
                            baseNameOfDirectory = str(
                                self.item(rowNo, 0).text())
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "baseName", baseName,
                                                 False):
                            baseName = str(self.item(rowNo, 1).text())
                            self.changedValueNumber += 1
                        newFilePath = fu.getRealPath(
                            fu.joinPath(str(self.leDestinationDirPath.text()),
                                        baseNameOfDirectory, baseName))
                        if fu.isFile(self.values[rowNo]
                                     ["path"]) and fu.isReadableFileOrDir(
                                         self.values[rowNo]["path"], False,
                                         True):
                            if fu.isWritableFileOrDir(newFilePath, False,
                                                      True):
                                newFilePathCopied = fu.copyOrChange(
                                    self.values[rowNo]["path"], newFilePath)
                                if self.values[rowNo][
                                        "path"] != newFilePathCopied:
                                    newFilePath = newFilePathCopied
                                    try:
                                        tagger = Taggers.getTagger()
                                        tagger.loadFileForWrite(newFilePath)
                                        if self.isChangeableItem(
                                                rowNo, "artist"):
                                            value = str(
                                                self.item(rowNo, 2).text())
                                            tagger.setArtist(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Artist")),
                                                str(self.values[rowNo]
                                                    ["artist"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "title"):
                                            value = str(
                                                self.item(rowNo, 3).text())
                                            tagger.setTitle(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Title")),
                                                str(self.values[rowNo]
                                                    ["title"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "album"):
                                            value = str(
                                                self.item(rowNo, 4).text())
                                            tagger.setAlbum(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Album")),
                                                str(self.values[rowNo]
                                                    ["album"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "albumArtist"):
                                            value = str(
                                                self.item(rowNo, 5).text())
                                            tagger.setAlbumArtist(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Album Artist")),
                                                str(self.values[rowNo]
                                                    ["albumArtist"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "trackNum"):
                                            value = str(
                                                self.item(rowNo, 6).text())
                                            tagger.setTrackNum(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Track No")),
                                                str(self.values[rowNo]
                                                    ["trackNum"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "year"):
                                            value = str(
                                                self.item(rowNo, 7).text())
                                            tagger.setDate(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable", "Year")),
                                                str(self.values[rowNo]
                                                    ["year"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "genre"):
                                            value = str(
                                                self.item(rowNo, 8).text())
                                            tagger.setGenre(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Genre")),
                                                str(self.values[rowNo]
                                                    ["genre"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "firstComment"):
                                            value = str(
                                                self.item(rowNo, 9).text())
                                            tagger.setFirstComment(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Comment")),
                                                str(self.values[rowNo]
                                                    ["firstComment"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "firstLyrics"):
                                            value = str(
                                                self.item(rowNo, 10).text())
                                            tagger.setFirstLyrics(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Lyrics")),
                                                str(self.values[rowNo]
                                                    ["firstLyrics"]), value)
                                            self.changedValueNumber += 1
                                        tagger.update()
                                    except:
                                        Dialogs.showError(
                                            translate("MusicTable",
                                                      "Tags Cannot Changed"),
                                            str(
                                                translate(
                                                    "MusicTable",
                                                    "\"%s\" : cannot be changed tags."
                                                )) %
                                            Organizer.getLink(newFilePath))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(
                translate("FileUtils/Musics", "Writing Music Tags"), rowNo + 1,
                allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        return True
Example #15
0
 def writeContents(self):
     self.changedValueNumber = 0
     oldAndNewPathValues = []
     isNewDirectoriesSame = True
     isMovedToNewDirectory = False
     currentDirectoryPath = ""
     newDirectoryPath = ""
     startRowNo, rowStep = 0, 1
     uni.startThreadAction()
     allItemNumber = len(self.values)
     Dialogs.showState(translate("FileUtils/Covers", "Writing Cover Informations"), 0, allItemNumber, True)
     for rowNo in range(startRowNo, self.rowCount(), rowStep):
         isContinueThreadAction = uni.isContinueThreadAction()
         if isContinueThreadAction:
             try:
                 if fu.isWritableFileOrDir(self.values[rowNo]["path"], False, True):
                     if self.isRowHidden(rowNo):
                         fu.removeFileOrDir(self.values[rowNo]["path"])
                         self.changedValueNumber += 1
                     else:
                         baseNameOfDirectory = str(
                             self.values[rowNo]["baseNameOfDirectory"])
                         baseName = str(self.values[rowNo]["baseName"])
                         if (self.isChangeableItem(rowNo, "sourceCover") or
                                 self.isChangeableItem(rowNo, "destinationCover")):
                             sourcePath = self.values[rowNo]["sourceCover"]
                             destinationPath = self.values[rowNo]["destinationCover"]
                             if self.isChangeableItem(rowNo, "sourceCover"):
                                 sourcePath = str(self.item(rowNo, 3).text()).strip()
                             if self.isChangeableItem(rowNo, "destinationCover"):
                                 destinationPath = str(self.item(rowNo, 4).text()).strip()
                             if (str(self.item(rowNo,
                                               2).text()) != sourcePath or sourcePath != destinationPath or str(
                                 self.item(rowNo, 2).text()) != destinationPath) or (
                                         str(self.item(rowNo, 2).text()) !=
                                         self.values[rowNo]["currentCover"] and (
                                             str(self.item(rowNo, 2).text()) != sourcePath and str(
                                         self.item(rowNo, 2).text()) != destinationPath)):
                                 if str(self.item(rowNo, 3).text()).strip() != "":
                                     sourcePath = fu.getRealPath(sourcePath,
                                                                 self.values[rowNo]["path"])
                                     sourcePath = fu.checkSource(sourcePath, "file")
                                     if sourcePath is not None:
                                         if destinationPath != "":
                                             destinationPath = fu.getRealPath(destinationPath,
                                                                              self.values[
                                                                                  rowNo]["path"])
                                             if sourcePath != destinationPath:
                                                 destinationPath = fu.moveOrChange(sourcePath, destinationPath)
                                         else:
                                             destinationPath = sourcePath
                                         fu.setIconToDirectory(self.values[rowNo]["path"],
                                                               destinationPath)
                                         self.changedValueNumber += 1
                                 else:
                                     fu.setIconToDirectory(self.values[rowNo]["path"], "")
                                     self.changedValueNumber += 1
                         if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
                             baseNameOfDirectory = str(self.item(rowNo, 0).text())
                             self.changedValueNumber += 1
                             isMovedToNewDirectory = True
                             currentDirectoryPath = fu.getDirName(
                                 self.values[rowNo]["path"])
                             newDirectoryPath = fu.joinPath(
                                 fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                 baseNameOfDirectory)
                             self.setNewDirectory(newDirectoryPath)
                             if rowNo > 0:
                                 if str(self.item(rowNo - 1, 0).text()) != baseNameOfDirectory:
                                     isNewDirectoriesSame = False
                         if self.isChangeableItem(rowNo, "baseName", baseName, False):
                             baseName = str(self.item(rowNo, 1).text())
                             self.changedValueNumber += 1
                         newFilePath = fu.joinPath(
                             fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                             baseNameOfDirectory, baseName)
                         oldFilePath = fu.getRealPath(self.values[rowNo]["path"])
                         newFilePath = fu.getRealPath(newFilePath)
                         if oldFilePath != newFilePath:
                             oldAndNewPaths = {}
                             oldAndNewPaths["oldPath"] = oldFilePath
                             oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath, "directory")
                             if oldFilePath != oldAndNewPaths["newPath"]:
                                 oldAndNewPathValues.append(oldAndNewPaths)
                                 oldDirName = fu.getDirName(oldFilePath)
                                 if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                                     fu.checkEmptyDirectories(oldDirName, True, True,
                                                              uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
             except:
                 ReportBug.ReportBug()
         else:
             allItemNumber = rowNo + 1
         Dialogs.showState(translate("FileUtils/Covers", "Writing Cover Informations"), rowNo + 1, allItemNumber,
                           True)
         if isContinueThreadAction is False:
             break
     uni.finishThreadAction()
     if self.rowCount() == len(oldAndNewPathValues) and isMovedToNewDirectory and isNewDirectoriesSame:
         otherFileNames = fu.readDirectory(currentDirectoryPath, "fileAndDirectory", True)
         if len(otherFileNames) > 0:
             answer = Dialogs.ask(translate("FileUtils/Musics", "There Are More Files"),
                                  str(translate("FileUtils/Musics",
                                                "\"%s\" : there are more files in this directory.<br>Are you want to move all found files into new directory?<br>New Directory : \"%s\"")) % (
                                      Organizer.getLink(currentDirectoryPath), Organizer.getLink(newDirectoryPath)))
             if answer == Dialogs.Yes:
                 uni.startThreadAction()
                 allItemNumber = len(otherFileNames)
                 for rowNo, fileName in enumerate(otherFileNames):
                     isContinueThreadAction = uni.isContinueThreadAction()
                     if isContinueThreadAction:
                         try:
                             oldFilePath = fu.getRealPath(fu.joinPath(currentDirectoryPath, fileName))
                             newFilePath = fu.getRealPath(fu.joinPath(newDirectoryPath, fileName))
                             if oldFilePath != newFilePath:
                                 oldAndNewPaths = {}
                                 oldAndNewPaths["oldPath"] = oldFilePath
                                 oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath,
                                                                             fu.getObjectType(oldFilePath))
                                 if oldFilePath != oldAndNewPaths["newPath"]:
                                     oldAndNewPathValues.append(oldAndNewPaths)
                         except:
                             ReportBug.ReportBug()
                     else:
                         allItemNumber = rowNo + 1
                     Dialogs.showState(translate("FileUtils/Covers", "Writing Directory And File Informations"),
                                       rowNo + 1, allItemNumber, True)
                     if isContinueThreadAction is False:
                         break
                 uni.finishThreadAction()
                 if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                     fu.checkEmptyDirectories(currentDirectoryPath, True, True,
                                              uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                 if (uni.isActiveDirectoryCover and uni.getBoolValue("isActiveAutoMakeIconToDirectory") and
                         uni.getBoolValue("isAutoMakeIconToDirectoryWhenFileMove")):
                     fu.checkIcon(newDirectoryPath)
     return True
    def writeContents(self):
        self.changedValueNumber = 0
        oldAndNewPathValues = []
        changingTags = []
        uni.startThreadAction()
        import Amarok

        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), 0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if self.isRowHidden(rowNo):
                        isWritableFileOrDir = fu.isFile(
                            self.values[rowNo]["path"]) and fu.isWritableFileOrDir(
                            self.values[rowNo]["path"], False, True)
                        if isWritableFileOrDir:
                            fu.removeFileOrDir(self.values[rowNo]["path"])
                            self.changedValueNumber += 1
                    else:
                        changingTag = {"path": self.values[rowNo]["path"]}
                        isWritableFileOrDir = fu.isFile(
                            self.values[rowNo]["path"]) and fu.isWritableFileOrDir(
                            self.values[rowNo]["path"], False, True)
                        isSetTagOfFile = False
                        if isWritableFileOrDir:
                            baseNameOfDirectory = str(
                                self.values[rowNo]["baseNameOfDirectory"])
                            baseName = str(self.values[rowNo]["baseName"])
                            if Amarok.getSelectedTagTargetType("AmarokMusicTable").find("To File") > -1:
                                isSetTagOfFile = True
                                tagger = Taggers.getTagger()
                                tagger.loadFileForWrite(self.values[rowNo]["path"])
                        if self.isChangeableItem(rowNo, "artist"):
                            value = str(self.item(rowNo, 2).text())
                            if isSetTagOfFile: tagger.setArtist(value)
                            changingTag["artist"] = value
                            Records.add(str(translate("MusicTable", "Artist")),
                                        str(self.values[rowNo]["artist"]), value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "title"):
                            value = str(self.item(rowNo, 3).text())
                            if isSetTagOfFile: tagger.setTitle(value)
                            changingTag["title"] = value
                            Records.add(str(translate("MusicTable", "Title")),
                                        str(self.values[rowNo]["title"]), value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "album"):
                            value = str(self.item(rowNo, 4).text())
                            if isSetTagOfFile: tagger.setAlbum(value)
                            changingTag["album"] = value
                            Records.add(str(translate("MusicTable", "Album")),
                                        str(self.values[rowNo]["album"]), value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "albumArtist"):
                            value = str(self.item(rowNo, 5).text())
                            if isSetTagOfFile: tagger.setAlbumArtist(value)
                            changingTag["albumArtist"] = value
                            Records.add(str(translate("MusicTable", "Album Artist")),
                                        str(self.values[rowNo]["albumArtist"]), value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "trackNum"):
                            value = str(self.item(rowNo, 6).text())
                            if isSetTagOfFile: tagger.setTrackNum(value)
                            changingTag["trackNum"] = value
                            Records.add(str(translate("MusicTable", "Track No")),
                                        str(self.values[rowNo]["trackNum"]), value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "year"):
                            value = str(self.item(rowNo, 7).text())
                            if isSetTagOfFile: tagger.setDate(value)
                            changingTag["year"] = value
                            Records.add(str(translate("MusicTable", "Year")),
                                        str(self.values[rowNo]["year"]), value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "genre"):
                            value = str(self.item(rowNo, 8).text())
                            if isSetTagOfFile: tagger.setGenre(value)
                            changingTag["genre"] = value
                            Records.add(str(translate("MusicTable", "Genre")),
                                        str(self.values[rowNo]["genre"]), value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "firstComment"):
                            value = str(self.item(rowNo, 9).text())
                            if isSetTagOfFile: tagger.setFirstComment(value)
                            changingTag["firstComment"] = value
                            Records.add(str(translate("MusicTable", "Comment")),
                                        str(self.values[rowNo]["firstComment"]), value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "firstLyrics"):
                            value = str(self.item(rowNo, 10).text())
                            if isSetTagOfFile: tagger.setFirstLyrics(value)
                            changingTag["firstLyrics"] = value
                            Records.add(str(translate("MusicTable", "Lyrics")),
                                        str(self.values[rowNo]["firstLyrics"]), value)
                            self.changedValueNumber += 1
                        if len(changingTag) > 1:
                            changingTags.append(changingTag)
                        if isWritableFileOrDir:
                            if isSetTagOfFile:
                                tagger.update()
                            if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
                                baseNameOfDirectory = str(self.item(rowNo, 0).text())
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "baseName", baseName, False):
                                baseName = str(self.item(rowNo, 1).text())
                                self.changedValueNumber += 1
                            newFilePath = fu.joinPath(
                                fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                baseNameOfDirectory, baseName)
                            oldFilePath = fu.getRealPath(self.values[rowNo]["path"])
                            newFilePath = fu.getRealPath(newFilePath)
                            if oldFilePath != newFilePath:
                                oldAndNewPaths = {}
                                oldAndNewPaths["oldPath"] = oldFilePath
                                oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath, "file")
                                if oldFilePath != oldAndNewPaths["newPath"]:
                                    oldAndNewPathValues.append(oldAndNewPaths)
                                    oldDirName = fu.getDirName(oldFilePath)
                                    if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                                        fu.checkEmptyDirectories(oldDirName, True, True,
                                                                 uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags And Informations"), rowNo + 1, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        from Amarok import Operations

        if Amarok.getSelectedTagTargetType("AmarokMusicTable").find("Amarok") > -1:
            Operations.changeTags(changingTags)
        if len(oldAndNewPathValues) > 0:
            Operations.changePaths(oldAndNewPathValues, "file")
        return True
    def writeContents(self):
        self.changedValueNumber = 0
        oldAndNewPathValues = []
        if uni.isActiveAmarok and uni.getBoolValue("isSubFolderTableValuesChangeInAmarokDB"):
            import Amarok

            if Amarok.checkAmarok(True, False) is False:
                return False
        uni.startThreadAction()
        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/SubFolders", "Writing File Informations"), 0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isWritableFileOrDir(self.values[rowNo]["path"], False, True):
                        if self.isRowHidden(rowNo):
                            fu.removeFileOrDir(self.values[rowNo]["path"])
                            self.changedValueNumber += 1
                        else:
                            baseNameOfDirectory = str(self.values[rowNo]["baseNameOfDirectory"])
                            baseName = str(self.values[rowNo]["baseName"])
                            if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
                                baseNameOfDirectory = str(self.item(rowNo, 0).text())
                                self.changedValueNumber += 1
                                newDirectoryPath = fu.joinPath(
                                    fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                    baseNameOfDirectory)
                                self.setNewDirectory(newDirectoryPath)
                            if self.isChangeableItem(rowNo, "baseName", baseName, False):
                                baseName = str(self.item(rowNo, 1).text())
                                self.changedValueNumber += 1
                            newFilePath = fu.joinPath(str(self.values[rowNo]["path"]).replace(
                                fu.joinPath(str(self.values[rowNo]["baseNameOfDirectory"]),
                                            str(self.values[rowNo]["baseName"])), ""),
                                                      baseNameOfDirectory, baseName)
                            oldFilePath = fu.getRealPath(self.values[rowNo]["path"])
                            newFilePath = fu.getRealPath(newFilePath)
                            if oldFilePath != newFilePath:
                                oldAndNewPaths = {}
                                oldAndNewPaths["oldPath"] = oldFilePath
                                oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath, "file")
                                if oldFilePath != oldAndNewPaths["newPath"]:
                                    oldAndNewPathValues.append(oldAndNewPaths)
                                    oldDirName = fu.getDirName(oldFilePath)
                                    if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                                        fu.checkEmptyDirectories(oldDirName, True, True,
                                                                 uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                                    if (uni.isActiveDirectoryCover and
                                            uni.getBoolValue("isActiveAutoMakeIconToDirectory") and
                                            uni.getBoolValue("isAutoMakeIconToDirectoryWhenFileMove")):
                                        fu.checkIcon(oldDirName)
                                        fu.checkIcon(fu.getDirName(oldAndNewPaths["newPath"]))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(translate("FileUtils/SubFolders", "Writing File Informations"), rowNo + 1, allItemNumber,
                              True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        if (uni.isActiveAmarok and
                uni.getBoolValue("isSubFolderTableValuesChangeInAmarokDB") and
                len(oldAndNewPathValues) > 0):
            import Amarok
            from Amarok import Operations

            Operations.changePaths(oldAndNewPathValues, "file")
        return True
Example #18
0
    def writeContents(self):
        self.changedValueNumber = 0
        oldAndNewPathValues = []
        changingTags = []
        if uni.isActiveAmarok and uni.getBoolValue(
                "isSubFolderMusicTableValuesChangeInAmarokDB"):
            import Amarok

            if Amarok.checkAmarok(True, False) is False:
                return False
        uni.startThreadAction()
        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"),
                          0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    changingTag = {"path": self.values[rowNo]["path"]}
                    if fu.isWritableFileOrDir(self.values[rowNo]["path"],
                                              False, True):
                        if self.isRowHidden(rowNo):
                            fu.removeFileOrDir(self.values[rowNo]["path"])
                            self.changedValueNumber += 1
                        else:
                            baseNameOfDirectory = str(
                                self.values[rowNo]["baseNameOfDirectory"])
                            baseName = str(self.values[rowNo]["baseName"])
                            tagger = Taggers.getTagger()
                            tagger.loadFileForWrite(self.values[rowNo]["path"])
                            isCheckLike = (
                                tagger.isNeedUpdate
                                or (uni.isActiveAmarok and uni.getBoolValue(
                                    "isSubFolderMusicTableValuesChangeInAmarokDB"
                                )))
                            if self.isChangeableItem(
                                    rowNo, "artist",
                                    self.values[rowNo]["artist"], True,
                                    isCheckLike):
                                value = str(self.item(rowNo, 2).text())
                                tagger.setArtist(value)
                                changingTag["artist"] = value
                                Records.add(
                                    str(translate("MusicTable", "Artist")),
                                    str(self.values[rowNo]["artist"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(
                                    rowNo, "title",
                                    self.values[rowNo]["title"], True,
                                    isCheckLike):
                                value = str(self.item(rowNo, 3).text())
                                tagger.setTitle(value)
                                changingTag["title"] = value
                                Records.add(
                                    str(translate("MusicTable", "Title")),
                                    str(self.values[rowNo]["title"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(
                                    rowNo, "album",
                                    self.values[rowNo]["album"], True,
                                    isCheckLike):
                                value = str(self.item(rowNo, 4).text())
                                tagger.setAlbum(value)
                                changingTag["album"] = value
                                Records.add(
                                    str(translate("MusicTable", "Album")),
                                    str(self.values[rowNo]["album"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(
                                    rowNo, "albumArtist",
                                    self.values[rowNo]["albumArtist"], True,
                                    isCheckLike):
                                value = str(self.item(rowNo, 5).text())
                                tagger.setAlbumArtist(value)
                                changingTag["albumArtist"] = value
                                Records.add(
                                    str(translate("MusicTable",
                                                  "Album Artist")),
                                    str(self.values[rowNo]["albumArtist"]),
                                    value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(
                                    rowNo, "trackNum",
                                    self.values[rowNo]["trackNum"], True,
                                    isCheckLike):
                                value = str(self.item(rowNo, 6).text())
                                tagger.setTrackNum(value)
                                changingTag["trackNum"] = value
                                Records.add(
                                    str(translate("MusicTable", "Track No")),
                                    str(self.values[rowNo]["trackNum"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(
                                    rowNo, "year", self.values[rowNo]["year"],
                                    True, isCheckLike):
                                value = str(self.item(rowNo, 7).text())
                                tagger.setDate(value)
                                changingTag["year"] = value
                                Records.add(
                                    str(translate("MusicTable", "Year")),
                                    str(self.values[rowNo]["year"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(
                                    rowNo, "genre",
                                    self.values[rowNo]["genre"], True,
                                    isCheckLike):
                                value = str(self.item(rowNo, 8).text())
                                tagger.setGenre(value)
                                changingTag["genre"] = value
                                Records.add(
                                    str(translate("MusicTable", "Genre")),
                                    str(self.values[rowNo]["genre"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(
                                    rowNo, "firstComment",
                                    self.values[rowNo]["firstComment"], True,
                                    isCheckLike):
                                value = str(self.item(rowNo, 9).text())
                                tagger.setFirstComment(value)
                                changingTag["firstComment"] = value
                                Records.add(
                                    str(translate("MusicTable", "Comment")),
                                    str(self.values[rowNo]["firstComment"]),
                                    value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(
                                    rowNo, "firstLyrics",
                                    self.values[rowNo]["firstLyrics"], True,
                                    isCheckLike):
                                value = str(self.item(rowNo, 10).text())
                                tagger.setFirstLyrics(value)
                                changingTag["firstLyrics"] = value
                                Records.add(
                                    str(translate("MusicTable", "Lyrics")),
                                    str(self.values[rowNo]["firstLyrics"]),
                                    value)
                                self.changedValueNumber += 1
                            if len(changingTag) > 1:
                                changingTags.append(changingTag)
                            tagger.update()
                            if self.isChangeableItem(rowNo,
                                                     "baseNameOfDirectory",
                                                     baseNameOfDirectory):
                                baseNameOfDirectory = str(
                                    self.item(rowNo, 0).text())
                                self.changedValueNumber += 1
                                newDirectoryPath = fu.joinPath(
                                    fu.getDirName(
                                        fu.getDirName(
                                            self.values[rowNo]["path"])),
                                    baseNameOfDirectory)
                                self.setNewDirectory(newDirectoryPath)
                            if self.isChangeableItem(rowNo, "baseName",
                                                     baseName, False):
                                baseName = str(self.item(rowNo, 1).text())
                                self.changedValueNumber += 1
                            newFilePath = fu.joinPath(
                                str(self.values[rowNo]["path"]).replace(
                                    fu.joinPath(
                                        str(self.values[rowNo]
                                            ["baseNameOfDirectory"]),
                                        str(self.values[rowNo]["baseName"])),
                                    ""), baseNameOfDirectory, baseName)
                            oldFilePath = fu.getRealPath(
                                self.values[rowNo]["path"])
                            newFilePath = fu.getRealPath(newFilePath)
                            if oldFilePath != newFilePath:
                                oldAndNewPaths = {}
                                oldAndNewPaths["oldPath"] = oldFilePath
                                oldAndNewPaths["newPath"] = fu.moveOrChange(
                                    oldFilePath, newFilePath, "file")
                                if oldFilePath != oldAndNewPaths["newPath"]:
                                    oldAndNewPathValues.append(oldAndNewPaths)
                                    oldDirName = fu.getDirName(oldFilePath)
                                    if uni.getBoolValue(
                                            "isClearEmptyDirectoriesWhenFileMove"
                                    ):
                                        fu.checkEmptyDirectories(
                                            oldDirName, True, True,
                                            uni.getBoolValue(
                                                "isAutoCleanSubFolderWhenFileMove"
                                            ))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(
                translate("FileUtils/Musics",
                          "Writing Music Tags And Informations"), rowNo + 1,
                allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        if uni.isActiveAmarok and uni.getBoolValue(
                "isSubFolderMusicTableValuesChangeInAmarokDB"):
            import Amarok
            from Amarok import Operations

            Operations.changeTags(changingTags)
            if len(oldAndNewPathValues) > 0:
                Operations.changePaths(oldAndNewPathValues, "file")
        return True