Use f-strings everywhere else

This commit is contained in:
Milan Stute
2020-12-02 16:18:57 +01:00
parent bf7cea785c
commit d96fa1d7ef
4 changed files with 8 additions and 13 deletions
+1 -1
View File
@@ -26,6 +26,6 @@ __version__ = "0.12.2"
if platform.system() == "Darwin":
dyld_path = os.environ.get("DYLD_LIBRARY_PATH", "") # save old path
archive_path = "/usr/local/opt/libarchive/lib"
os.environ["DYLD_LIBRARY_PATH"] = "{}:{}".format(dyld_path, archive_path)
os.environ["DYLD_LIBRARY_PATH"] = f"{dyld_path}:{archive_path}"
logger = logging.getLogger(__name__)
+2 -2
View File
@@ -97,7 +97,7 @@ class AirDropClient:
logger.debug(f"Send {url} request")
AirDropUtil.write_debug(
self.config, body, "send_{}_request.plist".format(url.lower().strip("/"))
self.config, body, f"send_{url.lower().strip('/')}_request.plist"
)
_headers = self._get_headers()
@@ -119,7 +119,7 @@ class AirDropClient:
AirDropUtil.write_debug(
self.config,
response_bytes,
"send_{}_response.plist".format(url.lower().strip("/")),
f"send_{url.lower().strip('/')}_response.plist",
)
if http_resp.status != 200:
+3 -5
View File
@@ -81,9 +81,7 @@ class AirDropConfig:
self.port = server_port
if service_id is None:
service_id = "{0:0{1}x}".format(
random.randint(0, 0xFFFFFFFFFFFF), 12
) # random 6-byte string in base16
service_id = f"{random.randint(0, 0xFFFFFFFFFFFF):012x}" # random 6-byte string in base16
self.service_id = service_id
self.debug = debug
@@ -109,7 +107,7 @@ class AirDropConfig:
self.root_ca_file = resource_filename("opendrop", "certs/apple_root_ca.pem")
if not os.path.exists(self.root_ca_file):
raise FileNotFoundError(
"Need Apple root CA certificate: {}".format(self.root_ca_file)
f"Need Apple root CA certificate: {self.root_ca_file}"
)
self.key_dir = os.path.join(self.airdrop_dir, "keys")
@@ -148,7 +146,7 @@ class AirDropConfig:
"-out",
"certificate.pem",
"-subj",
"/CN={}".format(self.computer_name),
f"/CN={self.computer_name}",
],
cwd=self.key_dir,
stdout=subprocess.PIPE,
+2 -5
View File
@@ -54,14 +54,11 @@ class AirDropServer:
if self.ip_addr is None:
if self.config.interface == "awdl0":
raise RuntimeError(
"Interface {} does not have an IPv6 address. "
"Make sure that `owl` is running.".format(self.config.interface)
f"Interface {self.config.interface} does not have an IPv6 address. Make sure that `owl` is running."
)
else:
raise RuntimeError(
"Interface {} does not have an IPv6 address".format(
self.config.interface
)
f"Interface {self.config.interface} does not have an IPv6 address"
)
self.Handler = AirDropServerHandler