def removeDir(path): result = "" if not QFile(path).exists(): result = QCoreApplication.translate( "QgsPluginInstaller", "Nothing to remove! Plugin directory doesn't exist:") + "\n" + path elif QFile(path).remove( ): # if it is only link, just remove it without resolving. pass else: fltr = QDir.Dirs | QDir.Files | QDir.Hidden iterator = QDirIterator(path, fltr, QDirIterator.Subdirectories) while iterator.hasNext(): item = iterator.next() if QFile(item).remove(): pass fltr = QDir.Dirs | QDir.Hidden iterator = QDirIterator(path, fltr, QDirIterator.Subdirectories) while iterator.hasNext(): item = iterator.next() if QDir().rmpath(item): pass if QFile(path).exists(): result = QCoreApplication.translate( "QgsPluginInstaller", "Failed to remove the directory:" ) + "\n" + path + "\n" + QCoreApplication.translate( "QgsPluginInstaller", "Check permissions or remove it manually") # restore plugin directory if removed by QDir().rmpath() pluginDir = qgis.utils.home_plugin_path if not QDir(pluginDir).exists(): QDir().mkpath(pluginDir) return result
def removeDir(path): result = "" if not QFile(path).exists(): result = QCoreApplication.translate("QgsPluginInstaller", "Nothing to remove! Plugin directory doesn't exist:") + "\n" + path elif QFile(path).remove(): # if it is only link, just remove it without resolving. pass else: fltr = QDir.Dirs | QDir.Files | QDir.Hidden iterator = QDirIterator(path, fltr, QDirIterator.Subdirectories) while iterator.hasNext(): item = iterator.next() if QFile(item).remove(): pass fltr = QDir.Dirs | QDir.Hidden iterator = QDirIterator(path, fltr, QDirIterator.Subdirectories) while iterator.hasNext(): item = iterator.next() if QDir().rmpath(item): pass if QFile(path).exists(): result = QCoreApplication.translate("QgsPluginInstaller", "Failed to remove the directory:") + "\n" + path + "\n" + QCoreApplication.translate("QgsPluginInstaller", "Check permissions or remove it manually") # restore plugin directory if removed by QDir().rmpath() pluginDir = qgis.utils.home_plugin_path if not QDir(pluginDir).exists(): QDir().mkpath(pluginDir) return result
def UItranslations(self): """ Get list of available ui translations """ # iterate over resource file to find available translations fltr = QDir.Dirs | QDir.Files | QDir.Hidden iterator = QDirIterator(':', fltr, QDirIterator.Subdirectories) while iterator.hasNext(): filePath = iterator.next() if '/translations/ts/' in filePath: fileName = os.path.basename(unicode(filePath[1:])) locale = fileName.replace('lector_','').replace('.qm', '') if locale: self.ui.cbLang.addItem(locale) locale = settings.get('ui:lang') if not locale: locale = QLocale.system().name() currentIndex = self.ui.cbLang.findText(locale) if currentIndex <= -1: currentIndex = self.ui.cbLang.findText('en_GB') self.ui.cbLang.setCurrentIndex(currentIndex)
def UItranslations(self): """ Get list of available ui translations """ # iterate over resource file to find available translations fltr = QDir.Dirs | QDir.Files | QDir.Hidden iterator = QDirIterator(':', fltr, QDirIterator.Subdirectories) while iterator.hasNext(): filePath = iterator.next() if '/translations/ts/' in filePath: fileName = os.path.basename(unicode(filePath[1:])) locale = fileName.replace('lector_', '').replace('.qm', '') if locale: self.ui.cbLang.addItem(locale) locale = settings.get('ui:lang') if not locale: locale = QLocale.system().name() currentIndex = self.ui.cbLang.findText(locale) if currentIndex <= -1: currentIndex = self.ui.cbLang.findText('en_GB') self.ui.cbLang.setCurrentIndex(currentIndex)