当前位置: 首页>>代码示例>>Python>>正文


Python QDir.setFilter方法代码示例

本文整理汇总了Python中PyQt.QtCore.QDir.setFilter方法的典型用法代码示例。如果您正苦于以下问题:Python QDir.setFilter方法的具体用法?Python QDir.setFilter怎么用?Python QDir.setFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt.QtCore.QDir的用法示例。


在下文中一共展示了QDir.setFilter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getRasterFiles

# 需要导入模块: from PyQt.QtCore import QDir [as 别名]
# 或者: from PyQt.QtCore.QDir import setFilter [as 别名]
def getRasterFiles(path, recursive=False):
    rasters = []
    if not QFileInfo(path).exists():
        return rasters

    # TODO remove *.aux.xml
    _filter = getRasterExtensions()
    workDir = QDir(path)
    workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot)
    workDir.setNameFilters(_filter)
    files = workDir.entryList()
    for f in files:
        rasters.append(path + "/" + f)

    if recursive:
        for myRoot, myDirs, myFiles in os.walk(unicode(path)):
            for dir in myDirs:
                workDir = QDir(myRoot + "/" + dir)
                workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot)
                workDir.setNameFilters(_filter)
                workFiles = workDir.entryList()
                for f in workFiles:
                    rasters.append(myRoot + "/" + dir + "/" + f)

    return rasters
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:27,代码来源:GdalTools_utils.py

示例2: batchRun

# 需要导入模块: from PyQt.QtCore import QDir [as 别名]
# 或者: from PyQt.QtCore.QDir import setFilter [as 别名]
    def batchRun(self):
        exts = re.sub('\).*$', '', re.sub('^.*\(', '', self.formatCombo.currentText())).split(" ")
        if len(exts) > 0 and exts[0] != "*" and exts[0] != "*.*":
            outExt = exts[0].replace("*", "")
        else:
            outExt = ".tif"

        self.base.enableRun(False)
        self.base.setCursor(Qt.WaitCursor)

        inDir = self.getInputFileName()
        outDir = self.getOutputFileName()

        extensions = Utils.getRasterExtensions()
        workDir = QDir(inDir)
        workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot)
        workDir.setNameFilters(extensions)
        files = workDir.entryList()

        self.inFiles = []
        self.outFiles = []

        for f in files:
            self.inFiles.append(inDir + "/" + f)
            if outDir is not None:
                outFile = re.sub("\.[a-zA-Z0-9]{2,4}", outExt, f)
                self.outFiles.append(outDir + "/" + outFile)

        self.errors = []
        self.batchIndex = 0
        self.batchTotal = len(self.inFiles)
        self.setProgressRange(self.batchTotal)

        self.runItem(self.batchIndex, self.batchTotal)
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:36,代码来源:doFillNodata.py

示例3: fillInputDir

# 需要导入模块: from PyQt.QtCore import QDir [as 别名]
# 或者: from PyQt.QtCore.QDir import setFilter [as 别名]
    def fillInputDir(self):
        inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files to Warp"))
        if not inputDir:
            return

        self.inSelector.setFilename(inputDir)

        filter = Utils.getRasterExtensions()
        workDir = QDir(inputDir)
        workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot)
        workDir.setNameFilters(filter)
        if len(workDir.entryList()) > 0:
            fl = inputDir + "/" + workDir.entryList()[0]
            self.sourceSRSEdit.setText(Utils.getRasterSRS(self, fl))
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:16,代码来源:doWarp.py

示例4: fillInputDir

# 需要导入模块: from PyQt.QtCore import QDir [as 别名]
# 或者: from PyQt.QtCore.QDir import setFilter [as 别名]
    def fillInputDir(self):
        inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files to Translate"))
        if not inputDir:
            return
        self.inSelector.setFilename(inputDir)

        filter = Utils.getRasterExtensions()
        workDir = QDir(inputDir)
        workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot)
        workDir.setNameFilters(filter)

        # search for a valid SRS, then use it as default target SRS
        srs = ''
        for fname in workDir.entryList():
            fl = inputDir + "/" + fname
            srs = Utils.getRasterSRS(self, fl)
            if srs:
                break
        self.targetSRSEdit.setText(srs)
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:21,代码来源:doTranslate.py

示例5: getAllInstalled

# 需要导入模块: from PyQt.QtCore import QDir [as 别名]
# 或者: from PyQt.QtCore.QDir import setFilter [as 别名]
    def getAllInstalled(self, testLoad=True):
        """ Build the localCache """
        self.localCache = {}

        # reversed list of the plugin paths: first system plugins -> then user plugins -> finally custom path(s)
        pluginPaths = list(plugin_paths)
        pluginPaths.reverse()

        for pluginsPath in pluginPaths:
            isTheSystemDir = (pluginPaths.index(pluginsPath) == 0)  # The curent dir is the system plugins dir
            if isTheSystemDir:
                # temporarily add the system path as the first element to force loading the readonly plugins, even if masked by user ones.
                sys.path = [pluginsPath] + sys.path
            try:
                pluginDir = QDir(pluginsPath)
                pluginDir.setFilter(QDir.AllDirs)
                for key in pluginDir.entryList():
                    if key not in [".", ".."]:
                        path = QDir.convertSeparators(pluginsPath + "/" + key)
                        # readOnly = not QFileInfo(pluginsPath).isWritable() # On windows testing the writable status isn't reliable.
                        readOnly = isTheSystemDir                            # Assume only the system plugins are not writable.
                        # only test those not yet loaded. Loaded plugins already proved they're o.k.
                        # failedToLoad = settings.value("/PythonPlugins/watchDog/" + key) is not None
                        testLoadThis = testLoad and key not in qgis.utils.plugins
                        plugin = self.getInstalledPlugin(key, path=path, readOnly=readOnly, testLoad=testLoadThis)
                        self.localCache[key] = plugin
                        if key in self.localCache.keys() and compareVersions(self.localCache[key]["version_installed"], plugin["version_installed"]) == 1:
                            # An obsolete plugin in the "user" location is masking a newer one in the "system" location!
                            self.obsoletePlugins += [key]
            except:
                # it's not necessary to stop if one of the dirs is inaccessible
                pass

            if isTheSystemDir:
                # remove the temporarily added path
                sys.path.remove(pluginsPath)
开发者ID:chaosui,项目名称:QGIS,代码行数:38,代码来源:installer_data.py


注:本文中的PyQt.QtCore.QDir.setFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。