twtxt.txt
. Getting the directory with os.path.dirname("twtxt.txt")
resulted in an empty string that was passed to os.listdir("")
which then raised FileNotFoundError: [Errno 2] No such file or directory: ''
. That in turn was transformed to None
, indicating that there is no previous archive feed available. Hence no prev
metadata field was generated for my main feed. os.path.abspath(…)
to the rescue!If I had used
./twtxt.txt
in the command line argument, I would not have run into this problem. This is basically what I did the last times. Ran the script from another directory, so the relative path still contained some directory component when cutting off the filename at the end.For the unit test I stumbled across [contextlib.chdir(…)](https://docs.python.org/3/library/contextlib.html#contextlib.chdir). This is very neat! Unfortunately, no Python 3.11 for me, yet. :-(