Skip to content

Commit 343872b

Browse files
committed
Flip some code to use format
1 parent 3de7b38 commit 343872b

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎python/pyplugin_installer/installer_data.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def xmlDownloaded(self):
414414
trusted = True
415415
icon = pluginNodes.item(i).firstChildElement("icon").text().strip()
416416
if icon and not icon.startswith("http"):
417-
icon = "http://%s/%s" % (QUrl(self.mRepositories[reposName]["url"]).host(), icon)
417+
icon = "http://{}/{}".format(QUrl(self.mRepositories[reposName]["url"]).host(), icon)
418418

419419
if pluginNodes.item(i).toElement().hasAttribute("plugin_id"):
420420
plugin_id = pluginNodes.item(i).toElement().attribute("plugin_id")
@@ -473,7 +473,7 @@ def xmlDownloaded(self):
473473
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 200:
474474
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.")
475475
else:
476-
self.mRepositories[reposName]["error"] = QCoreApplication.translate("QgsPluginInstaller", "Status code:") + " %d %s" % (
476+
self.mRepositories[reposName]["error"] = QCoreApplication.translate("QgsPluginInstaller", "Status code:") + " {} {}".format(
477477
reply.attribute(QNetworkRequest.HttpStatusCodeAttribute),
478478
reply.attribute(QNetworkRequest.HttpReasonPhraseAttribute)
479479
)
@@ -583,10 +583,10 @@ def pluginMetadata(fct):
583583
If failed, fallbacks to the standard metadata """
584584
locale = QLocale.system().name()
585585
if locale and fct in translatableAttributes:
586-
value = metadataParser("%s[%s]" % (fct, locale))
586+
value = metadataParser("{}[{}]".format(fct, locale))
587587
if value:
588588
return value
589-
value = metadataParser("%s[%s]" % (fct, locale.split("_")[0]))
589+
value = metadataParser("{}[{}]".format(fct, locale.split("_")[0]))
590590
if value:
591591
return value
592592
return metadataParser(fct)
@@ -614,7 +614,7 @@ def pluginMetadata(fct):
614614
# if compatible, add the plugin to the list
615615
if not isCompatible(pyQgisVersion(), qgisMinimumVersion, qgisMaximumVersion):
616616
error = "incompatible"
617-
errorDetails = "%s - %s" % (qgisMinimumVersion, qgisMaximumVersion)
617+
errorDetails = "{} - {}".format(qgisMinimumVersion, qgisMaximumVersion)
618618
elif not os.path.exists(metadataFile):
619619
error = "broken"
620620
errorDetails = QCoreApplication.translate("QgsPluginInstaller", "Missing metadata file")

‎python/pyplugin_installer/version_compare.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ def isCompatible(curVer, minVer, maxVer):
195195
if len(maxVer) < 3:
196196
maxVer += ["99"]
197197

198-
minVer = "%04d%04d%04d" % (int(minVer[0]), int(minVer[1]), int(minVer[2]))
199-
maxVer = "%04d%04d%04d" % (int(maxVer[0]), int(maxVer[1]), int(maxVer[2]))
200-
curVer = "%04d%04d%04d" % (int(curVer[0]), int(curVer[1]), int(curVer[2]))
198+
minVer = "{:04n}{:04n}{:04n}".format(int(minVer[0]), int(minVer[1]), int(minVer[2]))
199+
maxVer = "{:04n}{:04n}{:04n}".format(int(maxVer[0]), int(maxVer[1]), int(maxVer[2]))
200+
curVer = "{:04n}{:04n}{:04n}".format(int(curVer[0]), int(curVer[1]), int(curVer[2]))
201201

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

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

0 commit comments

Comments
 (0)