Commit ad137039 authored by Romain Casati's avatar Romain Casati

Better string formating.

parent 5c85172f
......@@ -19,8 +19,7 @@ def main():
args = parser.parse_args()
if args.install:
print('Installing Basthon kernel {} in current directory'.format(
implementation))
print(f'Installing Basthon kernel {implementation} in current directory')
data_path = Path(__file__).parent / 'data'
......
......@@ -67,7 +67,7 @@ def hack_sympy():
"""
latex = sep.join(sympy.latex(expr) for expr in args)
kernel.display_event({"display_type": "sympy",
"content": "$${}$$".format(latex)})
"content": f"$${latex}$$"})
sympy.pretty_print = pretty_print
......
......@@ -69,8 +69,7 @@ def request(method, url, **kwargs):
""" See requests.request """
# url params
if "params" in kwargs:
url += "?" + "&".join(("{}={}".format(k, v)
for k, v in kwargs["params"].items()))
url += "?" + "&".join((f"{k}={v}" for k, v in kwargs["params"].items()))
req = js.eval("var __basthon_req = new XMLHttpRequest(); __basthon_req") # hack for using js try/catch (see below)
req.open(method.lower(), url, False) # synchronous request
req.overrideMimeType('text/plain; charset=x-user-defined')
......
......@@ -60,7 +60,7 @@ def _tag_func(tag):
# Better use method bind of DOMNode objects
node.addEventListener(key[2:], value)
elif key == "style":
node.setAttribute("style", ';'.join("{}: {}".format(k, v)
node.setAttribute("style", ';'.join(f"{k}: {v}"
for k, v in value.items()))
elif "href" in key:
node.setAttributeNS(_xlink_ns, "href", value)
......
......@@ -70,11 +70,11 @@ def galerie(*args):
domain = 'console' if file.endswith('.py') else 'notebook'
url = f"https://{domain}.basthon.fr/?from={urllib.parse.quote(url)}"
if aux is not None:
url += '&aux={}'.format(urllib.parse.quote(aux))
url += f"&aux={urllib.parse.quote(aux)}"
return url
return "".join(one_img.format(SITEURL=SITEURL,
img_name='{}.png'.format(Path(file).with_suffix('')),
img_name=f"{Path(file).with_suffix('')}.png",
description=data['desc'],
url=url(file, data.get('aux')))
for file, data in examples.items())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment