stages/dnf.config: specify encondig for open
This is a pyling warning `W1514` "using open without explicitly specifying an encoding" in newer version, so fix this.
This commit is contained in:
parent
dd2d4c8708
commit
57b320f04f
1 changed files with 4 additions and 4 deletions
|
|
@ -75,7 +75,7 @@ def configure_variable(tree, name, value):
|
|||
"""
|
||||
vars_directory = "/etc/dnf/vars"
|
||||
|
||||
with open(f"{tree}{vars_directory}/{name}", "w") as f:
|
||||
with open(f"{tree}{vars_directory}/{name}", "w", encoding="utf-8") as f:
|
||||
f.write(value + "\n")
|
||||
|
||||
|
||||
|
|
@ -102,16 +102,16 @@ def make_dnf_config(tree, config_options):
|
|||
dnf_config = iniparse.SafeConfigParser()
|
||||
|
||||
try:
|
||||
with open(dnf_config_path, "r") as f:
|
||||
with open(dnf_config_path, "r", encoding="utf-8") as f:
|
||||
dnf_config.readfp(f)
|
||||
except FileNotFoundError:
|
||||
print(f"Warning: DNF configuration file '{dnf_config_path}' does not exist, will create it.")
|
||||
os.makedirs(f"{tree}/etc/dnf", exist_ok=True)
|
||||
|
||||
for section, items in config_options.items():
|
||||
for section, items in config_options.items():
|
||||
make_section(dnf_config, section, items)
|
||||
|
||||
with open(dnf_config_path, "w") as f:
|
||||
with open(dnf_config_path, "w", encoding="utf-8") as f:
|
||||
os.fchmod(f.fileno(), 0o644)
|
||||
dnf_config.write(f)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue