Commits

Alexander Shorin committed eb9b388

Add on_setup decorator to call custom functions during setup phase.

  • Participants
  • Parent commits ab35cff

Comments (0)

Files changed (1)

         self.subargparser = self.argparser.add_subparsers(
             title='commands',
             dest='command')
+        self._setup_handlers = []
+
         self.prepare()
 
     def prepare(self):
             self.config = self.config_loader.load_from_cfg(
                 self.args.config, self.name, defaults=self.config)
 
+    def on_setup(self, func):
+        self._setup_handlers.append(func)
+        return func
+
     def setup(self):
         self.setup_logging()
+        for func in self._setup_handlers:
+            func()
 
     def setup_logging(self):
         if 'logging' not in self.config: