Path to stylesheet files breaks when running the script from another path
Running the script on the root folder (or any other folder) gives the following error:
henrique@henrique:~/rep/impygen$ impygen -i goldenCrate.json -o
Traceback (most recent call last):
File "/home/henrique/.local/bin/impygen", line 8, in <module>
sys.exit(generate_files())
File "/home/henrique/.local/lib/python3.8/site-packages/impygen/__init__.py", line 95, in generate_files
generate_opis(args.path, crate.boards)
File "/home/henrique/.local/lib/python3.8/site-packages/impygen/__init__.py", line 16, in generate_opis
opis = opi.Opi(save_dir=path, boards=boards_list)
File "/home/henrique/.local/lib/python3.8/site-packages/impygen/opi.py", line 14, in __init__
self.board_config = json.loads(board_file.read_text())
File "/usr/lib/python3.8/pathlib.py", line 1236, in read_text
with self.open(mode='r', encoding=encoding, errors=errors) as f:
File "/usr/lib/python3.8/pathlib.py", line 1222, in open
return io.open(self, mode, buffering, encoding, errors, newline,
File "/usr/lib/python3.8/pathlib.py", line 1078, in _opener
return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: 'stylesheets/board_config.json'
It works properly when run inside the folder impygen
:
henrique@henrique:~/rep/impygen/impygen$ impygen -i ../goldenCrate.json -o
henrique@henrique:~/rep/impygen/impygen$ ls
auto-gen-db auto-gen-opi db __init__.py __main__.py opi.py stylesheets styles.py templates tests
Edited by Henrique Silva