diff --git a/src/music_kraken/utils/config/config.py b/src/music_kraken/utils/config/config.py index 91414eb..2a44fd8 100644 --- a/src/music_kraken/utils/config/config.py +++ b/src/music_kraken/utils/config/config.py @@ -50,8 +50,8 @@ class Config: return "\n".join(component.toml_string for component in self.component_list) def write(self): - with self.config_file.open("w") as conf_file: - conf_file.write(self.toml_string, encoding="utf-8") + with self.config_file.open("w", encoding="utf-8") as conf_file: + conf_file.write(self.toml_string) def read(self): if not self.config_file.is_file(): @@ -60,7 +60,7 @@ class Config: return toml_data = {} - with self.config_file.open("r") as conf_file: + with self.config_file.open("r", encoding="utf-8") as conf_file: toml_data = toml.load(conf_file) for component in self.component_list: diff --git a/src/music_kraken/utils/debug_utils.py b/src/music_kraken/utils/debug_utils.py index 9541c53..a13ecb7 100644 --- a/src/music_kraken/utils/debug_utils.py +++ b/src/music_kraken/utils/debug_utils.py @@ -11,7 +11,7 @@ def dump_to_file(file_name: str, payload: str, is_json: bool = False, exit_after if is_json: payload = json.dumps(json.loads(payload), indent=4) - with path.open("w") as f: + with path.open("w", encoding="utf-8") as f: f.write(payload) if exit_after_dump: diff --git a/src/music_kraken/utils/path_manager/music_directory.py b/src/music_kraken/utils/path_manager/music_directory.py index 0a0ea72..c0e0167 100644 --- a/src/music_kraken/utils/path_manager/music_directory.py +++ b/src/music_kraken/utils/path_manager/music_directory.py @@ -27,7 +27,7 @@ def get_xdg_music_directory() -> Path: def get_music_dir_from_xdg_file(xdg_file_path: os.PathLike) -> Optional[Path]: try: - with open(xdg_file_path, 'r') as f: + with open(xdg_file_path, 'r', encoding="utf-8") as f: data = "[XDG_USER_DIRS]\n" + f.read() config = configparser.ConfigParser(allow_no_value=True) config.read_string(data) diff --git a/src/music_kraken/utils/shared.py b/src/music_kraken/utils/shared.py index 20726f1..09e2737 100644 --- a/src/music_kraken/utils/shared.py +++ b/src/music_kraken/utils/shared.py @@ -13,6 +13,8 @@ def get_random_message() -> str: return random.choice(main_settings['happy_messages']) +ENCODING = "utf-8" + HIGHEST_ID = 2**main_settings['id_bits'] diff --git a/src/settings.py b/src/settings.py deleted file mode 100644 index 6a14b84..0000000 --- a/src/settings.py +++ /dev/null @@ -1,6 +0,0 @@ -from pathlib import Path -import tomllib - - -data = tomllib.load(Path("/home/lars/music-kraken.conf").open("r")) -print(data) \ No newline at end of file