remove format literals so we can support python 3.5

This commit is contained in:
Damien Elmes 2018-01-16 16:07:30 +10:00
parent 4f0e6561e8
commit 118326df1e
8 changed files with 22 additions and 21 deletions

View File

@ -4,8 +4,8 @@
import sys
if sys.version_info[0] < 3 or sys.version_info[1] < 6:
raise Exception("Anki requires Python 3.6+")
if sys.version_info[0] < 3 or sys.version_info[1] < 5:
raise Exception("Anki requires Python 3.5+")
if sys.getfilesystemencoding().lower() in ("ascii", "ansi_x3.4-1968"):
raise Exception("Anki requires a UTF-8 locale.")

View File

@ -330,7 +330,7 @@ class AddonsDialog(QDialog):
if not addon:
return
if re.match(r"^\d+$", addon):
openLink(aqt.appShared + f"info/{addon}")
openLink(aqt.appShared + "info/{}".format(addon))
else:
showWarning(_("Add-on was not downloaded from AnkiWeb."))

View File

@ -1383,7 +1383,7 @@ where id in %s""" % ids2str(sf))
self._updatePreviewButtons()
self._previewWeb.eval(
f"{func}({json.dumps(txt)},'{bodyclass}');")
"{}({},'{}');".format(func, json.dumps(txt), bodyclass))
def _onPreviewShowBothSides(self, toggle):
self._previewBothSides = toggle

View File

@ -145,8 +145,9 @@ add-ons section</a> of our support site.
else:
platname = "Linux"
return f"""\
Anki {appVersion} Python {platform.python_version()} Qt {QT_VERSION_STR} PyQt {PYQT_VERSION_STR}
Platform: {platname}
Flags: frz={getattr(sys, "frozen", False)} ao={self.mw.addonManager.dirty}
"""
return """\
Anki {} Python {} Qt {} PyQt {}
Platform: {}
Flags: frz={} ao={}
""".format(appVersion, platform.python_version(), QT_VERSION_STR, PYQT_VERSION_STR, platname,
getattr(sys, "frozen", False), self.mw.addonManager.dirty)

View File

@ -288,7 +288,7 @@ close the profile or restart Anki."""))
if getattr(w, "silentlyClose", None):
w.close()
else:
showWarning(f"Window should have been closed: {w}")
showWarning("Window should have been closed: {}".format(w))
def unloadProfileAndExit(self):
self.unloadProfile(self.cleanupAndExit)

View File

@ -119,12 +119,12 @@ class Reviewer:
def revHtml(self):
extra = self.mw.col.conf.get("reviewExtra", "")
return f"""
return """
<div id=_mark>&#x2605;</div>
<div id=_flag>&#x2691;</div>
<div id=qa></div>
{extra}
"""
{}
""".format(extra)
def _initWeb(self):
self._reps = 0

View File

@ -503,7 +503,7 @@ class MenuList:
end = items[-1].title
prefix = os.path.commonprefix([start.upper(), end.upper()])
n = len(prefix)+1
return f"{start[:n].upper()}-{end[:n].upper()}"
return "{}-{}".format(start[:n].upper(), end[:n].upper())
class SubMenu(MenuList):
def __init__(self, title):

View File

@ -217,21 +217,21 @@ border-radius:5px; font-family: Helvetica }"""
from aqt import mw
head = mw.baseHTML() + head + csstxt + jstxt
html=f"""
html = """
<!doctype html>
<html><head>
<title>{self.title}</title>
<title>{}</title>
<style>
body {{ zoom: {self.zoomFactor()}; {fontspec} }}
{buttonspec}
body {{ zoom: {}; {} }}
{}
</style>
{head}
{}
</head>
<body>{body}</body>
</html>"""
<body>{}</body>
</html>""".format(self.title, self.zoomFactor(), fontspec, buttonspec, head, body)
#print(html)
self.setHtml(html)