fix: encoding on windows
This commit is contained in:
parent
8cae9b00a0
commit
ff8dd76190
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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']
|
||||
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
from pathlib import Path
|
||||
import tomllib
|
||||
|
||||
|
||||
data = tomllib.load(Path("/home/lars/music-kraken.conf").open("r"))
|
||||
print(data)
|
Loading…
Reference in New Issue
Block a user