• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python version_compare.compareVersions函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中version_compare.compareVersions函数的典型用法代码示例。如果您正苦于以下问题:Python compareVersions函数的具体用法?Python compareVersions怎么用?Python compareVersions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: xmlDownloaded

  def xmlDownloaded(self,nr,state):
    """ populate the plugins object with the fetched data """
    if not self.httpId.has_key(nr):
      return
    reposName = self.httpId[nr]
    if state:                             # fetching failed
      self.mRepositories[reposName]["state"] =  3
      self.mRepositories[reposName]["error"] = self.mRepositories[reposName]["QPHttp"].errorString()
    else:
      repoData = self.mRepositories[reposName]["xmlData"]
      reposXML = QDomDocument()
      reposXML.setContent(repoData.data())
      pluginNodes = reposXML.elementsByTagName("pyqgis_plugin")
      if pluginNodes.size():
        for i in range(pluginNodes.size()):
          fileName = pluginNodes.item(i).firstChildElement("file_name").text().simplified()
          if not fileName:
              fileName = QFileInfo(pluginNodes.item(i).firstChildElement("download_url").text().trimmed().split("?")[0]).fileName()
          name = fileName.section(".", 0, 0)
          name = unicode(name)
          experimental = False
          if pluginNodes.item(i).firstChildElement("experimental").text().simplified().toUpper() in ["TRUE","YES"]:
            experimental = True
          plugin = {
            "name"          : pluginNodes.item(i).toElement().attribute("name"),
            "version_avail" : pluginNodes.item(i).toElement().attribute("version"),
            "desc_repo"     : pluginNodes.item(i).firstChildElement("description").text().simplified(),
            "desc_local"    : "",
            "author"        : pluginNodes.item(i).firstChildElement("author_name").text().simplified(),
            "homepage"      : pluginNodes.item(i).firstChildElement("homepage").text().simplified(),
            "url"           : pluginNodes.item(i).firstChildElement("download_url").text().simplified(),
            "experimental"  : experimental,
            "filename"      : fileName,
            "status"        : "not installed",
            "error"         : "",
            "error_details" : "",
            "version_inst"  : "",
            "repository"    : reposName,
            "localdir"      : name,
            "read-only"     : False}
          qgisMinimumVersion = pluginNodes.item(i).firstChildElement("qgis_minimum_version").text().simplified()
          if not qgisMinimumVersion: qgisMinimumVersion = "1"
          qgisMaximumVersion = pluginNodes.item(i).firstChildElement("qgis_maximum_version").text().simplified()
          if not qgisMaximumVersion: qgisMaximumVersion = qgisMinimumVersion[0] + ".99"
          #if compatible, add the plugin to the list
          if not pluginNodes.item(i).firstChildElement("disabled").text().simplified().toUpper() in ["TRUE","YES"]:
           if compareVersions(QGIS_VER, qgisMinimumVersion) < 2 and compareVersions(qgisMaximumVersion, QGIS_VER) < 2:
              #add the plugin to the cache
              plugins.addFromRepository(plugin)
      # set state=2, even if the repo is empty
      self.mRepositories[reposName]["state"] = 2

    self.emit(SIGNAL("repositoryFetched(QString)"), reposName )

    # is the checking done?
    if not self.fetchingInProgress():
      plugins.rebuild()
      self.saveCheckingOnStartLastDate()
      self.emit(SIGNAL("checkingDone()"))
开发者ID:Hardysong,项目名称:Quantum-GIS,代码行数:59,代码来源:installer_data.py


示例2: rebuild

 def rebuild(self):
   """ build or rebuild the mPlugins from the caches """
   self.mPlugins = {}
   for i in self.localCache.keys():
     self.mPlugins[i] = self.localCache[i].copy()
   settings = QSettings()
   allowExperimental = settings.value(settingsGroup+"/allowExperimental", False, type=bool)
   for i in self.repoCache.values():
     for j in i:
       plugin=j.copy() # do not update repoCache elements!
       key = plugin["id"]
       # check if the plugin is allowed and if there isn't any better one added already.
       if (allowExperimental or not plugin["experimental"]) \
       and not (self.mPlugins.has_key(key) and self.mPlugins[key]["version_available"] and compareVersions(self.mPlugins[key]["version_available"], plugin["version_available"]) < 2):
         # The mPlugins dict contains now locally installed plugins.
         # Now, add the available one if not present yet or update it if present already.
         if not self.mPlugins.has_key(key):
           self.mPlugins[key] = plugin   # just add a new plugin
         else:
           # update local plugin with remote metadata
           # name, description, icon: only use remote data if local one is not available (because of i18n and to not download the icon)
           for attrib in translatableAttributes + ["icon"]:
               if not self.mPlugins[key][attrib] and plugin[attrib]:
                   self.mPlugins[key][attrib] = plugin[attrib]
           # other remote metadata is preffered:
           for attrib in ["name", "description", "category", "tags", "changelog", "author_name", "author_email", "homepage",
                          "tracker", "code_repository", "experimental", "version_available", "zip_repository",
                          "download_url", "filename", "downloads", "average_vote", "rating_votes"]:
             if not attrib in translatableAttributes:
               if plugin[attrib]:
                   self.mPlugins[key][attrib] = plugin[attrib]
         # set status
         #
         # installed   available   status
         # ---------------------------------------
         # none        any         "not installed" (will be later checked if is "new")
         # any         none        "orphan"
         # same        same        "installed"
         # less        greater     "upgradeable"
         # greater     less        "newer"
         if not self.mPlugins[key]["version_available"]:
           self.mPlugins[key]["status"] = "orphan"
         elif not self.mPlugins[key]["version_installed"]:
           self.mPlugins[key]["status"] = "not installed"
         elif self.mPlugins[key]["version_installed"] in ["?", "-1"]:
           self.mPlugins[key]["status"] = "installed"
         elif compareVersions(self.mPlugins[key]["version_available"],self.mPlugins[key]["version_installed"]) == 0:
           self.mPlugins[key]["status"] = "installed"
         elif compareVersions(self.mPlugins[key]["version_available"],self.mPlugins[key]["version_installed"]) == 1:
           self.mPlugins[key]["status"] = "upgradeable"
         else:
           self.mPlugins[key]["status"] = "newer"
         # debug: test if the status match the "installed" tag:
         if self.mPlugins[key]["status"] in ["not installed"] and self.mPlugins[key]["installed"]:
             raise Exception("Error: plugin status is ambiguous (1)")
         if self.mPlugins[key]["status"] in ["installed","orphan","upgradeable","newer"] and not self.mPlugins[key]["installed"]:
             raise Exception("Error: plugin status is ambiguous (2)")
   self.markNews()
开发者ID:rafaelisaias,项目名称:Quantum-GIS,代码行数:58,代码来源:installer_data.py


示例3: xmlDownloaded

  def xmlDownloaded(self,nr,state):
    """ populate the plugins object with the fetched data """
    if not self.httpId.has_key(nr):
      return
    reposName = self.httpId[nr]
    if state:                             # fetching failed
      self.mRepositories[reposName]["state"] =  3
      self.mRepositories[reposName]["error"] = self.mRepositories[reposName]["QPHttp"].errorString()
    else:
      repoData = self.mRepositories[reposName]["xmlData"]
      reposXML = QDomDocument()
      reposXML.setContent(repoData.data())
      pluginNodes = reposXML.elementsByTagName("pyqgis_plugin")
      if pluginNodes.size():
        for i in range(pluginNodes.size()):
          fileName = QFileInfo(pluginNodes.item(i).firstChildElement("download_url").text().trimmed()).fileName()
          name = fileName.section(".", 0, 0)
          name = str(name)
          plugin = {}
          plugin[name] = {
            "name"          : pluginNodes.item(i).toElement().attribute("name"),
            "version_avail" : pluginNodes.item(i).toElement().attribute("version"),
            "desc_repo"     : pluginNodes.item(i).firstChildElement("description").text().trimmed(),
            "desc_local"    : "",
            "author"        : pluginNodes.item(i).firstChildElement("author_name").text().trimmed(),
            "homepage"      : pluginNodes.item(i).firstChildElement("homepage").text().trimmed(),
            "url"           : pluginNodes.item(i).firstChildElement("download_url").text().trimmed(),
            "filename"      : fileName,
            "status"        : "not installed",
            "error"         : "",
            "error_details" : "",
            "version_inst"  : "",
            "repository"    : reposName,
            "localdir"      : name,
            "read-only"     : False}
          qgisMinimumVersion = pluginNodes.item(i).firstChildElement("qgis_minimum_version").text().trimmed()
          if not qgisMinimumVersion: qgisMinimumVersion = "0"
          # please use the tag below only if really needed! (for example if plugin development is abandoned)
          qgisMaximumVersion = pluginNodes.item(i).firstChildElement("qgis_maximum_version").text().trimmed()
          if not qgisMaximumVersion: qgisMaximumVersion = "2"
          #if compatible, add the plugin to the list
          if compareVersions(QGIS_VER, qgisMinimumVersion) < 2 and compareVersions(qgisMaximumVersion, QGIS_VER) < 2:
            if QGIS_VER[0]=="0" or qgisMinimumVersion[0]=="1" or name=="plugin_installer":
              plugins.addPlugin(plugin)
        plugins.workarounds()
        self.mRepositories[reposName]["state"] = 2
      else:
        #print "Repository parsing error"
        self.mRepositories[reposName]["state"] = 3
        self.mRepositories[reposName]["error"] = QCoreApplication.translate("QgsPluginInstaller","Couldn't parse output from the repository")

    self.emit(SIGNAL("repositoryFetched(QString)"), reposName )

    # is the checking done?
    if not self.fetchingInProgress():
      plugins.getAllInstalled()
      self.emit(SIGNAL("checkingDone()"))
开发者ID:HydroCouple,项目名称:FVHMComponent,代码行数:57,代码来源:installer_data.py


示例4: rebuild

 def rebuild(self):
   """ build or rebuild the mPlugins from the caches """
   self.mPlugins = {}
   for i in self.localCache.keys():
     self.mPlugins[i] = self.localCache[i].copy()
   settings = QSettings()
   (allowed, ok) = settings.value(settingsGroup+"/allowedPluginType", QVariant(2)).toInt()
   for i in self.repoCache.values():
     for plugin in i:
       key = plugin["localdir"]
       # check if the plugin is allowed and if there isn't any better one added already.
       if (allowed != 1 or plugin["repository"] == officialRepo[0]) and (allowed == 3 or not plugin["experimental"]) \
       and not (self.mPlugins.has_key(key) and self.mPlugins[key]["version_avail"] and compareVersions(self.mPlugins[key]["version_avail"], plugin["version_avail"]) < 2):
         # The mPlugins doct contains now locally installed plugins. 
         # Now, add the available one if not present yet or update it if present already.
         if not self.mPlugins.has_key(key):
           self.mPlugins[key] = plugin   # just add a new plugin
         else:
           self.mPlugins[key]["version_avail"] = plugin["version_avail"]
           self.mPlugins[key]["desc_repo"] = plugin["desc_repo"]
           self.mPlugins[key]["filename"] = plugin["filename"]
           self.mPlugins[key]["repository"] = plugin["repository"]
           self.mPlugins[key]["experimental"] = plugin["experimental"]
           # use remote name if local one is not available
           if self.mPlugins[key]["name"] == key and plugin["name"]:
             self.mPlugins[key]["name"] = plugin["name"]
           # those metadata has higher priority for their remote instances:
           if plugin["author"]:
             self.mPlugins[key]["author"] = plugin["author"]
           if plugin["homepage"]:
             self.mPlugins[key]["homepage"] = plugin["homepage"]
           if plugin["url"]:
             self.mPlugins[key]["url"] = plugin["url"]
         # set status
         #
         # installed   available   status
         # ---------------------------------------
         # none        any         "not installed" (will be later checked if is "new")
         # any         none        "orphan"
         # same        same        "installed"
         # less        greater     "upgradeable"
         # greater     less        "newer"
         if not self.mPlugins[key]["version_avail"]:
           self.mPlugins[key]["status"] = "orphan"
         elif self.mPlugins[key]["error"] in ["broken","dependent"]:
           self.mPlugins[key]["status"] = "installed"
         elif not self.mPlugins[key]["version_inst"]:
           self.mPlugins[key]["status"] = "not installed"
         elif compareVersions(self.mPlugins[key]["version_avail"],self.mPlugins[key]["version_inst"]) == 0:
           self.mPlugins[key]["status"] = "installed"
         elif compareVersions(self.mPlugins[key]["version_avail"],self.mPlugins[key]["version_inst"]) == 1:
           self.mPlugins[key]["status"] = "upgradeable"
         else:
           self.mPlugins[key]["status"] = "newer"
   self.markNews()
开发者ID:RealworldSystems,项目名称:Quantum-GIS,代码行数:55,代码来源:installer_data.py


示例5: getAllInstalled

 def getAllInstalled(self):
   """ Build the localCache """
   self.localCache = {}
   # first, try to add the read-only plugins...
   pluginsPath = unicode(QDir.convertSeparators(QDir.cleanPath(QgsApplication.pkgDataPath() + "/python/plugins")))
   #  temporarily add the system path as the first element to force loading the read-only 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():
       key = unicode(key)
       if not key in [".",".."]:
         self.localCache[key] = self.getInstalledPlugin(key, True)
   except:
     # return QCoreApplication.translate("QgsPluginInstaller","Couldn't open the system plugin directory")
     pass # it's not necessary to stop due to this error
   # remove the temporarily added path
   sys.path.remove(pluginsPath)
   # ...then try to add locally installed ones
   try:
     pluginDir = QDir.convertSeparators(QDir.cleanPath(QgsApplication.qgisSettingsDirPath() + "/python/plugins"))
     pluginDir = QDir(pluginDir)
     pluginDir.setFilter(QDir.AllDirs)
   except:
     return QCoreApplication.translate("QgsPluginInstaller","Couldn't open the local plugin directory")
   for key in pluginDir.entryList():
     key = unicode(key)
     if not key in [".",".."]:
       plugin = self.getInstalledPlugin(key, False)
       if key in self.localCache.keys() and compareVersions(self.localCache[key]["version_inst"],plugin["version_inst"]) == 1:
         # An obsolete plugin in the "user" location is masking a newer one in the "system" location!
         self.obsoletePlugins += [key]
       self.localCache[key] = plugin
开发者ID:RealworldSystems,项目名称:Quantum-GIS,代码行数:34,代码来源:installer_data.py


示例6: getAllInstalled

  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 not key 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.
            testLoadThis = testLoad and not qgis.utils.plugins.has_key(key)
            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:ChowZenki,项目名称:QGIS,代码行数:35,代码来源:installer_data.py


示例7: addPlugin

 def addPlugin(self, plugins):
   """ add a plugin (first from given) to the mPlugins dict """
   key = plugins.keys()[0]
   plugin = plugins[key]
   plugin["version_avail"] = normalizeVersion(plugin["version_avail"])
   plugin["version_inst"] = normalizeVersion(plugin["version_inst"])
   if not self.mPlugins.has_key(key) or compareVersions(self.mPlugins[key]["version_avail"],plugin["version_avail"]) == 2:
     self.mPlugins[key] = plugin # add the plugin if not present yet or if is newer than existing one
开发者ID:HydroCouple,项目名称:FVHMComponent,代码行数:8,代码来源:installer_data.py


示例8: getInstalledPlugin

 def getInstalledPlugin(self, key, readOnly, testLoad=False):
   """ get the metadata of an installed plugin """
   if readOnly:
     path = QgsApplication.pkgDataPath()
   else:
     path = QgsApplication.qgisSettingsDirPath()
   path = QDir.cleanPath(path) + "/python/plugins/" + key
   if not QDir(path).exists():
     return
   nam   = ""
   ver   = ""
   desc  = ""
   auth  = ""
   homepage  = ""
   error = ""
   errorDetails = ""
   try:
     exec("import %s" % key)
     exec("reload (%s)" % key)
     try:
       exec("nam = %s.name()" % key)
     except:
       pass
     try:
       exec("ver = %s.version()" % key)
     except:
       pass
     try:
       exec("desc = %s.description()" % key)
     except:
       pass
     try:
       exec("auth = %s.author()" % key)
     except:
       # "authorName" was deprecated in QGis > 1.8,
       # you must use "author" instead
       try:
         exec("auth = %s.authorName()" % key)
       except:
         pass
     try:
       exec("homepage = %s.homepage()" % key)
     except:
       pass
     try:
       exec("qgisMinimumVersion = %s.qgisMinimumVersion()" % key)
       if compareVersions(QGIS_VER, qgisMinimumVersion) == 2:
         error = "incompatible"
         errorDetails = qgisMinimumVersion
     except:
       pass
     if testLoad:
       try:
         exec ("%s.classFactory(iface)" % key)
       except Exception, error:
         error = unicode(error.args[0])
   except Exception, error:
     error = unicode(error.args[0])
开发者ID:Hardysong,项目名称:Quantum-GIS,代码行数:58,代码来源:installer_data.py


示例9: updatePlugin

 def updatePlugin(self, key, readOnly):
   """ The mPlugins should contain available plugins first. Now, add installed one (add when not present, update if present) """
   if readOnly:
     path = QgsApplication.pkgDataPath()
   else:
     path = QgsApplication.qgisSettingsDirPath()
   path = QDir.cleanPath(path) + "/python/plugins/" + key
   if not QDir(path).exists():
     return
   nam   = ""
   ver   = ""
   desc  = ""
   auth  = ""
   homepage  = ""
   error = ""
   errorDetails = ""
   try:
     exec("import "+ key)
     try:
       exec("nam = %s.name()" % key)
     except:
       pass
     try:
       exec("ver = %s.version()" % key)
     except:
       pass
     try:
       exec("desc = %s.description()" % key)
     except:
       pass
     try:
       exec("auth = %s.authorName()" % key)
     except:
       pass
     try:
       exec("homepage = %s.homepage()" % key)
     except:
       pass
     try:
       exec("qgisMinimumVersion = %s.qgisMinimumVersion()" % key)
       if compareVersions(QGIS_VER, qgisMinimumVersion) == 2:
         error = "incompatible"
         errorDetails = qgisMinimumVersion
     except:
       pass
     try:
       exec ("%s.classFactory(iface)" % key)
     except Exception, error:
       error = error.message
   except Exception, error:
     error = error.message
开发者ID:HydroCouple,项目名称:FVHMComponent,代码行数:51,代码来源:installer_data.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python version_utils.get_version函数代码示例发布时间:2022-05-26
下一篇:
Python version.Version类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap