Skip to content

Commit

Permalink
chore: Run pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEvilSkeleton committed Jan 9, 2025
1 parent 5ccddbd commit 54d8a93
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions bottles/backend/managers/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ def __step_run_script(config: BottleConfig, step: dict):
)
return False

logging.info(f"Executing installer script…")
logging.info("Executing installer script…")
subprocess.Popen(
f"bash -c '{script}'",
shell=True,
cwd=ManagerUtils.get_bottle_path(config),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
).communicate()
logging.info(f"Finished executing installer script.")
logging.info("Finished executing installer script.")

@staticmethod
def __step_update_config(config: BottleConfig, step: dict):
Expand Down
2 changes: 1 addition & 1 deletion bottles/backend/managers/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def save_library(self, silent=False):
yaml.dump(self.__library, library_file)

if not silent:
logging.info(f"Library saved")
logging.info("Library saved")

def get_library(self):
"""
Expand Down
8 changes: 4 additions & 4 deletions bottles/backend/managers/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1531,27 +1531,27 @@ def delete_bottle(self, config: BottleConfig) -> bool:
logging.error("Empty path found. Disasters unavoidable.")
return False

logging.info(f"Removing applications installed with the bottle…")
logging.info("Removing applications installed with the bottle…")
for inst in glob(f"{Paths.applications}/{config.Name}--*"):
os.remove(inst)

logging.info(f"Removing library entries associated with this bottle…")
logging.info("Removing library entries associated with this bottle…")
library_manager = LibraryManager()
entries = library_manager.get_library().copy()
for _uuid, entry in entries.items():
if entry.get("bottle").get("name") == config.Name:
library_manager.remove_from_library(_uuid)

if config.Custom_Path:
logging.info(f"Removing placeholder…")
logging.info("Removing placeholder…")
with contextlib.suppress(FileNotFoundError):
os.remove(
os.path.join(
Paths.bottles, os.path.basename(config.Path), "placeholder.yml"
)
)

logging.info(f"Removing the bottle…")
logging.info("Removing the bottle…")
path = ManagerUtils.get_bottle_path(config)
subprocess.run(["rm", "-rf", path], stdout=subprocess.DEVNULL)

Expand Down
6 changes: 3 additions & 3 deletions bottles/backend/managers/steam.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def __get_library_folders(self) -> list | None:
_library_folders = SteamUtils.parse_vdf(f.read())

if _library_folders is None or not _library_folders.get("libraryfolders"):
logging.warning(f"Could not parse libraryfolders.vdf")
logging.warning("Could not parse libraryfolders.vdf")
return None

for _, folder in _library_folders["libraryfolders"].items():
Expand Down Expand Up @@ -172,7 +172,7 @@ def __get_local_config(self) -> dict:
data = SteamUtils.parse_vdf(f.read())

if data is None:
logging.warning(f"Could not parse localconfig.vdf")
logging.warning("Could not parse localconfig.vdf")
return {}

return data
Expand All @@ -188,7 +188,7 @@ def save_local_config(self, new_data: dict):
with open(self.localconfig_path, "w") as f:
SteamUtils.to_vdf(VDFDict(new_data), f)

logging.info(f"Steam config saved")
logging.info("Steam config saved")

@staticmethod
@lru_cache
Expand Down
2 changes: 1 addition & 1 deletion bottles/backend/managers/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def get_state_files(
file.close()
return files
except (OSError, IOError, yaml.YAMLError):
logging.error(f"Could not read the state files file.")
logging.error("Could not read the state files file.")
return {}

@staticmethod
Expand Down
8 changes: 4 additions & 4 deletions bottles/backend/utils/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ def create_desktop_entry(
os.remove(file)

with open(desktop_file, "w") as f:
f.write(f"[Desktop Entry]\n")
f.write("[Desktop Entry]\n")
f.write(f"Name={program.get('name')}\n")
f.write(
f"Exec={cmd_cli} run -p {shlex.quote(program.get('name'))} -b '{config.get('Name')}' -- %u\n"
)
f.write(f"Type=Application\n")
f.write(f"Terminal=false\n")
f.write(f"Categories=Application;\n")
f.write("Type=Application\n")
f.write("Terminal=false\n")
f.write("Categories=Application;\n")
f.write(f"Icon={icon}\n")
f.write(f"Comment=Launch {program.get('name')} using Bottles.\n")
f.write(f"StartupWMClass={program.get('name')}\n")
Expand Down
12 changes: 6 additions & 6 deletions bottles/backend/utils/steam.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def is_proton(path: str) -> bool:
"""
Checks if a directory is a Proton directory.
"""
toolmanifest = os.path.join(path, f"toolmanifest.vdf")
toolmanifest = os.path.join(path, "toolmanifest.vdf")
if not os.path.isfile(toolmanifest):
return False

Expand All @@ -70,7 +70,7 @@ def get_associated_runtime(path: str) -> Optional[str]:
"""
Get the associated runtime of a Proton directory.
"""
toolmanifest = os.path.join(path, f"toolmanifest.vdf")
toolmanifest = os.path.join(path, "toolmanifest.vdf")
if not os.path.isfile(toolmanifest):
logging.error(f"toolmanifest.vdf not found in Proton directory: {path}")
return None
Expand All @@ -93,10 +93,10 @@ def get_dist_directory(path: str) -> str:
Get the sub-directory containing the wine libraries and binaries.
"""
dist_directory = path
if os.path.isdir(os.path.join(path, f"dist")):
dist_directory = os.path.join(path, f"dist")
elif os.path.isdir(os.path.join(path, f"files")):
dist_directory = os.path.join(path, f"files")
if os.path.isdir(os.path.join(path, "dist")):
dist_directory = os.path.join(path, "dist")
elif os.path.isdir(os.path.join(path, "files")):
dist_directory = os.path.join(path, "files")
else:
logging.warning(
f"No /dist or /files sub-directory was found under this Proton directory: {path}"
Expand Down
2 changes: 1 addition & 1 deletion bottles/backend/utils/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def execute(self, command, env=None, colors="default", cwd=None):
shlex.quote(f"bash -c {command}"),
)
if "ENABLE_BASH" in os.environ:
command = " ".join(self.terminal) % (colors, f"bash")
command = " ".join(self.terminal) % (colors, "bash")
elif self.terminal[0] in ["xfce4-terminal"]:
command = " ".join(self.terminal) % "'sh -c %s'" % f"{command}"
elif self.terminal[0] in ["kitty", "foot", "konsole", "gnome-terminal"]:
Expand Down
2 changes: 1 addition & 1 deletion bottles/backend/wine/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def __get_exec_type(exec_path):
if _exec.endswith(".dll"):
return "dll"

logging.warning(f"Not a common executable type, trying to launch it anyway.")
logging.warning("Not a common executable type, trying to launch it anyway.")
return "unsupported"

def run_cli(self):
Expand Down
8 changes: 4 additions & 4 deletions bottles/backend/wine/winecommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def _get_runner_info(self) -> tuple[str, str]:
Additionally, check for its corresponding runtime.
"""
runner_runtime = SteamUtils.get_associated_runtime(runner)
runner = os.path.join(SteamUtils.get_dist_directory(runner), f"bin/wine")
runner = os.path.join(SteamUtils.get_dist_directory(runner), "bin/wine")

elif runner.startswith("sys-"):
"""
Expand Down Expand Up @@ -523,10 +523,10 @@ def get_cmd(
gamescope_run = tempfile.NamedTemporaryFile(mode="w", suffix=".sh").name

# Create temporary sh script in /tmp where Gamescope will execute it
file = [f"#!/usr/bin/env sh\n"]
file = ["#!/usr/bin/env sh\n"]
file.append(f"{command} $@")
if mangohud_available and params.mangohud:
file.append(f" &\nmangoapp")
file.append(" &\nmangoapp")
with open(gamescope_run, "w") as f:
f.write("".join(file))

Expand Down Expand Up @@ -756,7 +756,7 @@ def run(self) -> Result[Optional[str]]:
# UnicodeDecodeError: codec mismatch
# LookupError: unknown codec name
# TypeError: codec is None
logging.warning(f"stdout decoding failed")
logging.warning("stdout decoding failed")
rv = str(stdout_data)[2:-1] # trim b''

# "ShellExecuteEx" exception may occur while executing command,
Expand Down
6 changes: 3 additions & 3 deletions bottles/frontend/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def manage_reg(self):

if _action in ["add", "edit"]:
if _data is None or _key_type not in allowed_types:
sys.stderr.write(f"Missing or invalid data or key type\n")
sys.stderr.write("Missing or invalid data or key type\n")
exit(1)
Reg(bottle).add(_key, _value, _data, _key_type)
elif _action == "del":
Expand Down Expand Up @@ -655,7 +655,7 @@ def run_program(self):

if _program is not None:
if _executable is not None:
sys.stderr.write(f"Cannot specify both --program and --executable\n")
sys.stderr.write("Cannot specify both --program and --executable\n")
exit(1)

if _program not in [p["name"] for p in programs]:
Expand Down Expand Up @@ -744,7 +744,7 @@ def generate_standalone(self):
os.remove(standalone_path)

with open(standalone_path, "w") as f:
f.write(f"#!/bin/bash\n")
f.write("#!/bin/bash\n")
for k, v in env.items():
f.write(f"export {k}='{v}'\n")
f.write(f"{cmd}\n")
Expand Down
2 changes: 1 addition & 1 deletion bottles/frontend/widgets/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def update_progress(
status: Optional[Status] = None,
):
if status == Status.FAILED:
logging.error(f"Component installation failed")
logging.error("Component installation failed")
self.set_err()
return False

Expand Down

0 comments on commit 54d8a93

Please sign in to comment.