L0laapk3 / FactorioMaps

L0laapk3's FactorioMaps mod
https://mods.factorio.com/mod/L0laapk3_FactorioMaps
Other
122 stars 22 forks source link

Paths not being resolved on unix-based #74

Closed trumank closed 4 years ago

trumank commented 4 years ago
Traceback (most recent call last):
  File "auto.py", line 14, in <module>
    with Path(__file__, "..", "packages.txt").open("r", encoding="utf-8") as f:
  File "/usr/lib/python3.8/pathlib.py", line 1213, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib/python3.8/pathlib.py", line 1069, in _opener
    return self._accessor.open(self, flags, mode)
NotADirectoryError: [Errno 20] Not a directory: 'auto.py/../packages.txt'

I'm not sure how it's currently supposed to be working unless Windows handles paths differently. It looks like everywhere __file__ is referenced, .resolve() needs to be called on the resulting path or the path will result in 'Not a directory' as __file__ is not a directory.

L0laapk3 commented 4 years ago

Thats strange that I haven't heard of this issue before yet. Would it be sufficient to simply add resolve() to all Path(__file__, ".." calls?

trumank commented 4 years ago

Would it be sufficient to simply add resolve() to all Path(__file__, ".." calls?

I think so. I did try that and it worked if the CWD was factorio/mods/L0laapk3_FactorioMaps_4.0.1 but it seemed to hang if it was anything else, though I may have missed a couple of places with my find replace.

L0laapk3 commented 4 years ago

Could you please test this commit? :)

trumank commented 4 years ago

Works for me. :+1: