コード例 #1
0
ファイル: ok.py プロジェクト: pombredanne/ok
 def close(self, err):
     self.module_cache.close()
     if self.notify_on_close:
         status, color = ('There were errors.',
                          'red') if err else ('No error!', 'green')
         self.log(
             antsy.decorate('Complete! (fg/{} {})'.format(color, status)))
コード例 #2
0
ファイル: ok.py プロジェクト: pombredanne/ok
 def info(self, module):
     self.check_exists(module)
     if module not in self._cache:
         okapi.confirm(
             'The module "{}" must be downloaded first. Continue?'.format(
                 module))
     m = self.load(module)
     self._print_module(module)
     clip.echo(antsy.decorate(m.__doc__ or 'No info provided'))
コード例 #3
0
ファイル: ok.py プロジェクト: pombredanne/ok
 def _print_module(self, module):
     if module in self._cache:
         color, mark = ('green',
                        u'\u2713') if self._cache[module] else ('red',
                                                                u'\u2717')
         clip.echo(
             antsy.decorate('(fg/{} {} {})'.format(color,
                                                   mark.encode('utf8'),
                                                   module)))
     else:
         clip.echo(module)
コード例 #4
0
ファイル: ok.py プロジェクト: pombredanne/ok
 def run(self, task):
     if isinstance(task, (list, tuple)):
         for t in task:
             self.run(t)
     else:
         if hasattr(task, '__call__'):
             self.log(
                 antsy.decorate('Running task (b,fg/cyan {})'.format(
                     task.__doc__ or task.__name__)))
             task()
         else:
             # First check whether we can offload task to a module
             fname, fargs = task.partition(' ')[::2]
             if self.module_cache.exists(fname):
                 getattr(self, fname)(fargs)
             else:
                 self.shell(task)
     return self
コード例 #5
0
ファイル: ok.py プロジェクト: pombredanne/ok
 def log(self, message, important=True):
     if important or not self.silent:
         clip.echo(antsy.decorate('(b,fg/green [ok]) {}'.format(message)))