Various string cleanups (#30435)

* Remove some unnecessary string concatenations

* Replace some simple str.formats with f-strings

* Replace some string concatenations with f-strings
This commit is contained in:
Ville Skyttä authored and Paulus Schoutsen committed 2020-01-03 14:47:06 +01:00
1 parent 5ad209c6fd
commit fa4fa30461
105 files changed
+241 -314

No files matched your search

+1 -1
View File
@@ -38,7 +38,7 @@ def run(args: List) -> int:
print("Available scripts:", ", ".join(scripts))
return 1
script = importlib.import_module("homeassistant.scripts." + args[0])
script = importlib.import_module(f"homeassistant.scripts.{args[0]}")
config_dir = extract_config_dir()
+1 -1
View File
@@ -43,7 +43,7 @@ def color(the_color, *args, reset=None):
return parse_colors(the_color)
return parse_colors(the_color) + " ".join(args) + escape_codes[reset or "reset"]
except KeyError as k:
raise ValueError("Invalid color {} in {}".format(str(k), the_color))
raise ValueError(f"Invalid color {k!s} in {the_color}")
def run(script_args: List) -> int:
+3 -3
View File
@@ -27,10 +27,10 @@ def install_osx():
with open(path, "w", encoding="utf-8") as outp:
outp.write(plist)
except OSError as err:
print("Unable to write to " + path, err)
print(f"Unable to write to {path}", err)
return
os.popen("launchctl load -w -F " + path)
os.popen(f"launchctl load -w -F {path}")
print(
"Home Assistant has been installed. \
@@ -41,7 +41,7 @@ def install_osx():
def uninstall_osx():
"""Unload from launchd on OS X."""
path = os.path.expanduser("~/Library/LaunchAgents/org.homeassistant.plist")
os.popen("launchctl unload " + path)
os.popen(f"launchctl unload {path}")
print("Home Assistant has been uninstalled.")