mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-06-05 20:38:26 +02:00
Missing weapons now raise a warning, and recursive directory parsing.
In order to avoid parsing arbitrary python files encountered during directory recursion, ``makesheets`` now checks each python file for a string listing the *dungeonsheets_version* before trying to import the character file.
This commit is contained in:
@@ -697,13 +697,10 @@ class Character():
|
||||
try:
|
||||
NewWeapon = findattr(weapons, weapon)
|
||||
except AttributeError:
|
||||
try:
|
||||
findattr(spells, weapon)
|
||||
except AttributeError:
|
||||
raise AttributeError(f'Weapon "{weapon}" is not defined')
|
||||
else:
|
||||
warnings.warn(f"Ignoring spell {weapon} listed as weapon.")
|
||||
return
|
||||
warnings.warn(f"Unknown weapon '{weapon}'. Please add it to ``weapons.py`` "
|
||||
"or submit an issue: https://github.com/canismarko/dungeon-sheets/issues",
|
||||
RuntimeWarning)
|
||||
return
|
||||
weapon_ = NewWeapon(wielder=self)
|
||||
elif issubclass(weapon, weapons.Weapon):
|
||||
weapon_ = weapon(wielder=self)
|
||||
|
||||
Reference in New Issue
Block a user