Skip to content
Permalink
Browse files

Flip some code to use format

  • Loading branch information
nyalldawson committed May 21, 2018
1 parent 3de7b38 commit 343872b7195c147950278f45510a0a0e90cfbe8c
Showing with 9 additions and 9 deletions.
  1. +5 −5 python/pyplugin_installer/installer_data.py
  2. +4 −4 python/pyplugin_installer/version_compare.py
@@ -414,7 +414,7 @@ def xmlDownloaded(self):
trusted = True
icon = pluginNodes.item(i).firstChildElement("icon").text().strip()
if icon and not icon.startswith("http"):
icon = "http://%s/%s" % (QUrl(self.mRepositories[reposName]["url"]).host(), icon)
icon = "http://{}/{}".format(QUrl(self.mRepositories[reposName]["url"]).host(), icon)

if pluginNodes.item(i).toElement().hasAttribute("plugin_id"):
plugin_id = pluginNodes.item(i).toElement().attribute("plugin_id")
@@ -473,7 +473,7 @@ def xmlDownloaded(self):
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 200:
self.mRepositories[reposName]["error"] = QCoreApplication.translate("QgsPluginInstaller", "Server response is 200 OK, but doesn't contain plugin metatada. This is most likely caused by a proxy or a wrong repository URL. You can configure proxy settings in QGIS options.")
else:
self.mRepositories[reposName]["error"] = QCoreApplication.translate("QgsPluginInstaller", "Status code:") + " %d %s" % (
self.mRepositories[reposName]["error"] = QCoreApplication.translate("QgsPluginInstaller", "Status code:") + " {} {}".format(
reply.attribute(QNetworkRequest.HttpStatusCodeAttribute),
reply.attribute(QNetworkRequest.HttpReasonPhraseAttribute)
)
@@ -583,10 +583,10 @@ def pluginMetadata(fct):
If failed, fallbacks to the standard metadata """
locale = QLocale.system().name()
if locale and fct in translatableAttributes:
value = metadataParser("%s[%s]" % (fct, locale))
value = metadataParser("{}[{}]".format(fct, locale))
if value:
return value
value = metadataParser("%s[%s]" % (fct, locale.split("_")[0]))
value = metadataParser("{}[{}]".format(fct, locale.split("_")[0]))
if value:
return value
return metadataParser(fct)
@@ -614,7 +614,7 @@ def pluginMetadata(fct):
# if compatible, add the plugin to the list
if not isCompatible(pyQgisVersion(), qgisMinimumVersion, qgisMaximumVersion):
error = "incompatible"
errorDetails = "%s - %s" % (qgisMinimumVersion, qgisMaximumVersion)
errorDetails = "{} - {}".format(qgisMinimumVersion, qgisMaximumVersion)
elif not os.path.exists(metadataFile):
error = "broken"
errorDetails = QCoreApplication.translate("QgsPluginInstaller", "Missing metadata file")
@@ -195,9 +195,9 @@ def isCompatible(curVer, minVer, maxVer):
if len(maxVer) < 3:
maxVer += ["99"]

minVer = "%04d%04d%04d" % (int(minVer[0]), int(minVer[1]), int(minVer[2]))
maxVer = "%04d%04d%04d" % (int(maxVer[0]), int(maxVer[1]), int(maxVer[2]))
curVer = "%04d%04d%04d" % (int(curVer[0]), int(curVer[1]), int(curVer[2]))
minVer = "{:04n}{:04n}{:04n}".format(int(minVer[0]), int(minVer[1]), int(minVer[2]))
maxVer = "{:04n}{:04n}{:04n}".format(int(maxVer[0]), int(maxVer[1]), int(maxVer[2]))
curVer = "{:04n}{:04n}{:04n}".format(int(curVer[0]), int(curVer[1]), int(curVer[2]))

return (minVer <= curVer and maxVer >= curVer)

@@ -211,4 +211,4 @@ def pyQgisVersion():
if y == '99':
x = str(int(x) + 1)
y = z = '0'
return '%s.%s.%s' % (x, y, z)
return '{}.{}.{}'.format(x, y, z)

0 comments on commit 343872b

Please sign in to comment.
You can’t perform that action at this time.