You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 11, 2021. It is now read-only.
So when I have the command zebra and in class Zebra(Base) I import class Alpaca from a different source, the main() function of the cli tries to execute run() on Alpaca. This is due to the fact that the main() method of the cli gets the commands with : if hasattr(name.commands, k) and v: module = getattr(name.commands, k)
and then accesses name.commands[0] if name.commands[0] != "Base".
But because in name.commands[0] is Alpaca because it is beeing imported by Zebra.
There is an easy fix for that:
for (k, v) in options.items(): if hasattr(name.commands, k) and v: module = getattr(unchained.commands, k) name.commands = getmembers(module, isclass) command = [c for c in name.commands if c[0].lower() == k.lower()][0][1] command = command(options) command.run()
Here the program checks weather c[0].lower() == k.lower() (with c we iterate over name.commands and in k is the command) this way command.run() gets the right Class.
The text was updated successfully, but these errors were encountered:
So when I have the command
zebra
and inclass Zebra(Base)
I import class Alpaca from a different source, the main() function of the cli tries to execute run() on Alpaca. This is due to the fact that the main() method of the cli gets the commands with :if hasattr(name.commands, k) and v: module = getattr(name.commands, k)
and then accesses name.commands[0] if name.commands[0] != "Base".
But because in name.commands[0] is Alpaca because it is beeing imported by Zebra.
There is an easy fix for that:
for (k, v) in options.items(): if hasattr(name.commands, k) and v: module = getattr(unchained.commands, k) name.commands = getmembers(module, isclass) command = [c for c in name.commands if c[0].lower() == k.lower()][0][1] command = command(options) command.run()
Here the program checks weather c[0].lower() == k.lower() (with c we iterate over name.commands and in k is the command) this way command.run() gets the right Class.
The text was updated successfully, but these errors were encountered: