biobootloader / wolverine

MIT License
5.22k stars 516 forks source link

Access prompt.txt via consistent path #30

Open tomviner opened 1 year ago

tomviner commented 1 year ago

Imagine this folder structure:

$ tree
.
├── project
│   └── script.py
└── wolverine
    └── wolverine.py

I'd like to run wolverine.py from within my project folder. But I get:

$ python /tmp/wolverine/wolverine.py script.py
Traceback (most recent call last):
  File "/tmp/wolverine/wolverine.py", line 20, in <module>
    with open("prompt.txt") as f:
         ^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'prompt.txt'

The fix is to calculate the path to prompt.txt relative to wolverine.py.

The allows running in the following way.

cd project
python ../wolverine/wolverine.py script.py