Chris Spencer
2015-10-22 15:19:26 UTC
Is it possible to dynamically define a Fabric task?
Currently, in order to make `fab` show the task mymodule.mytask, I need to
define the function `mytask` inside `mymodule`. As I use Fabric more, I'm
finding this gets very tedious, because different modules often define
similar functions, so I end up writing duplicate code. I'm trying to
refactor my code to be more object-oriented, and would like to register
class methods as tasks, but I can't find a reliable way to do this.
How can I tell Fabric to expose an arbitrary callable with a specific name,
regardless of which package or module it resides in?
Currently, in order to make `fab` show the task mymodule.mytask, I need to
define the function `mytask` inside `mymodule`. As I use Fabric more, I'm
finding this gets very tedious, because different modules often define
similar functions, so I end up writing duplicate code. I'm trying to
refactor my code to be more object-oriented, and would like to register
class methods as tasks, but I can't find a reliable way to do this.
How can I tell Fabric to expose an arbitrary callable with a specific name,
regardless of which package or module it resides in?