Closed sgbaird closed 1 year ago
Good catch, there are a few things we could do here:
if path.is_file(): ...
cfp.add_section(module)
between line 161 and 162So you're saying you edited the code and option 2 worked for you?
@cthoyt cfp.add_section(module)
works if the section didn't already exist, but throws an error if the section already exists (IIRC).
I figured this out the hard way ;) so I added a check for non-existence.
For provenance, here's some code I used to create the file (and folder) in the correct location if it doesn't exist.
from os import path
from pathlib import Path
ini_dir = path.join(path.abspath(path.expanduser("~")), ".config")
ini_path = path.join(ini_dir, "zenodo.ini")
Path(ini_dir).mkdir(exist_ok=True, parents=True)
Path(ini_path).touch()
Are you saying there's still a persisting issue? This issue has been addressed, as far as I remember
I was getting the behavior of the files confused with something else. I don't think it's an issue anymore.
Related: https://github.com/cthoyt/zenodo-client/issues/6
https://github.com/cthoyt/pystow/blob/ecbe7ea9f044602be12fff1d9574071403bc900c/src/pystow/config_api.py#L151-L164
I needed to call
cfp.add_section(module)
before I could usecfp.set(module, key, value)
given the file doesn't already exist.