Skip to content

Commit

Permalink
config: Set the config path when we read the file
Browse files Browse the repository at this point in the history
Fixes #79. cfg_path was a terrible decision, and really shouldn't exist.
The idea was for the config object to keep track of where it was loaded
from -- but I'm abusing the ever loving stuffing out of it, and it
should be removed in a future release.

For the time being, however, I'm moving this line within the conditional
to ensure that cfg_path is only set when we are directly reading a file
on the disk. It's pedantic, but hopefully this will prevent any further
undefined behavior until I can revamp the config system.
  • Loading branch information
tkuester committed Jul 30, 2023
1 parent c3a594b commit 9650dc7
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions taky/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def load_config(path=None, explicit=False):
cfg_dir = os.path.realpath(os.path.dirname(path))
with open(path, "r", encoding="utf8") as cfg_fp:
ret_config.read_file(cfg_fp, source=path)

# We know the file exists now, set the config path
ret_config.set("taky", "cfg_path", path)
elif explicit:
raise FileNotFoundError("Config file required, but not present")
else:
Expand All @@ -75,9 +78,6 @@ def load_config(path=None, explicit=False):

ret_config.set("taky", "root_dir", ".")
ret_config.set("dp_server", "upload_path", "./dp-user")

# Set the config path
ret_config.set("taky","cfg_path",path)

# Make directories absolute
for (sect, opt) in [
Expand Down Expand Up @@ -136,7 +136,5 @@ def load_config(path=None, explicit=False):
f_path = os.path.realpath(os.path.join(cfg_dir, f_path))
ret_config.set("ssl", f_name, f_path)



app_config.clear()
app_config.update(ret_config)

0 comments on commit 9650dc7

Please sign in to comment.