mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-06-17 08:47:49 +00:00
Fix most formatting and linting errors
This commit is contained in:
+13
-10
@@ -2,33 +2,36 @@ from json import dump, load
|
||||
from os import mkdir, path, listdir, rename
|
||||
from shutil import chown
|
||||
|
||||
from helpers import get_home_path, get_homebrew_path, get_user, get_user_group, get_user_owner
|
||||
from helpers import (
|
||||
get_homebrew_path,
|
||||
get_user,
|
||||
get_user_group,
|
||||
get_user_owner,
|
||||
)
|
||||
|
||||
|
||||
class SettingsManager:
|
||||
def __init__(self, name, settings_directory = None) -> None:
|
||||
def __init__(self, name, settings_directory=None) -> None:
|
||||
USER = get_user()
|
||||
GROUP = get_user_group()
|
||||
wrong_dir = get_homebrew_path()
|
||||
if settings_directory == None:
|
||||
if settings_directory is None:
|
||||
settings_directory = path.join(wrong_dir, "settings")
|
||||
|
||||
self.path = path.join(settings_directory, name + ".json")
|
||||
|
||||
#Create the folder with the correct permission
|
||||
# Create the folder with the correct permission
|
||||
if not path.exists(settings_directory):
|
||||
mkdir(settings_directory)
|
||||
chown(settings_directory, USER, GROUP)
|
||||
|
||||
#Copy all old settings file in the root directory to the correct folder
|
||||
# Copy all old settings file in the root directory to the correct folder
|
||||
for file in listdir(wrong_dir):
|
||||
if file.endswith(".json"):
|
||||
rename(path.join(wrong_dir,file),
|
||||
path.join(settings_directory, file))
|
||||
rename(path.join(wrong_dir, file), path.join(settings_directory, file))
|
||||
self.path = path.join(settings_directory, name + ".json")
|
||||
|
||||
|
||||
#If the owner of the settings directory is not the user, then set it as the user:
|
||||
# If the owner of the settings directory is not the user, then set it as the user:
|
||||
if get_user_owner(settings_directory) != USER:
|
||||
chown(settings_directory, USER, GROUP)
|
||||
|
||||
@@ -36,7 +39,7 @@ class SettingsManager:
|
||||
|
||||
try:
|
||||
open(self.path, "x", encoding="utf-8")
|
||||
except FileExistsError as e:
|
||||
except FileExistsError:
|
||||
self.read()
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user