Skip to content

Commit

Permalink
Flip some code to use format
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 21, 2018
1 parent 3de7b38 commit 343872b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions python/pyplugin_installer/installer_data.py
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions python/pyplugin_installer/version_compare.py
Expand Up @@ -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)

Expand All @@ -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.