pineapplemachine / PyDwarf

Mod Dwarf Fortress with the power of Python.
Other
42 stars 11 forks source link

namespace expansion fails to find package #8

Closed awillats closed 3 years ago

awillats commented 3 years ago

having

scripts:
 [...]
 -pineapple.boneflux

works fine but

scripts:
 [...]
 -boneflux

throws the following error:

Traceback (most recent call last):
  File "manager.py", line 86, in <module>
    __main__(parseargs())
  File "manager.py", line 52, in __main__
    session.run()
  File "/Users/adam/Documents/Games/DwarfFortress/PyDwarf/pydwarf/session.py", line 76, in run
    self.handleall()
  File "/Users/adam/Documents/Games/DwarfFortress/PyDwarf/pydwarf/session.py", line 170, in handleall
    for info in infos: self.handle(info)
  File "/Users/adam/Documents/Games/DwarfFortress/PyDwarf/pydwarf/session.py", line 159, in handle
    funcs = self.funcs(uristinstance, name, func, match, version)
  File "/Users/adam/Documents/Games/DwarfFortress/PyDwarf/pydwarf/session.py", line 138, in funcs
    scriptname, version=checkversion, match=scriptmatch, session=self
  File "/Users/adam/Documents/Games/DwarfFortress/PyDwarf/pydwarf/urist.py", line 68, in get
    candidates = urist.registrar[name]
  File "/Users/adam/Documents/Games/DwarfFortress/PyDwarf/pydwarf/registrar.py", line 75, in __getitem__
    raise KeyError('Failed to find "%s" in namespace %s.' % (name, str(self)))
KeyError: 'Failed to find "boneflux" in namespace root.'

may be due to a difference in how paths are handled on mac?

pineapplemachine commented 3 years ago

It looks like the documentation which claims you can write just boneflux is not correct. Possibly this was true in an earlier release or pre-release version of PyDwarf and the documentation became out of date. The documentation will have to be fixed, but in the meantime please go ahead and just use the fully qualified names e.g. pineapple.boneflux.

pineapplemachine commented 3 years ago

The issue is closed by these commits, which fix the incorrect documentation. (I'm pretty sure this is all the places it's mentioned, but please let me know if you see others.)

Possibly this option to write shorter script names could be added to PyDwarf in the future, but it's been a long time since I was adding new features to PyDwarf as opposed to just keeping it running. Note also that this added feature would need to include a sensible conflict resolution system in case more than one script has the same unqualified name.

https://github.com/pineapplemachine/PyDwarf/commit/50d8430df82312a26d63589d2ecf7d31078a79a5

https://github.com/pineapplemachine/PyDwarf/commit/50d8430df82312a26d63589d2ecf7d31078a79a5

awillats commented 3 years ago

yeah i think just writing the full script path for now is perfectly fine and the most straightforward low-maintenance solution