diff --git a/dfhack/python/pydfhack/decorators.py b/dfhack/python/pydfhack/decorators.py new file mode 100644 index 000000000..702cf18f9 --- /dev/null +++ b/dfhack/python/pydfhack/decorators.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +""" +Decorators for bound classes +""" +from decorator import decorator + +@decorator +def suspend(func, self, *args, **kw): + """ + This decorator will try to suspend DF and start needed module before running func + """ + if self.prepare(): + return func(self, *args, **kw) + else: + raise Exception(u"Could not suspend/start")