def print_statuses(self, uptodate_msg='All tasks up-to-date!', outofdate_msg='Some tasks out of date!'): '''Print the up-to-date status of all tasks. Args: uptodate_msg (str): The message to print if all tasks are up to date. Returns: tuple: A bool (True if all up to date) and a dictionary of statuses. ''' uptodate, statuses = self.check_uptodate() if uptodate: print(ui.paragraph(uptodate_msg)) else: print(ui.paragraph(outofdate_msg)) uptodate_list = [t for t,s in statuses.items() if s is True] outofdate_list = [t for t,s in statuses.items() if s is False] if uptodate_list: print('\nUp-to-date tasks:') print(ui.listing(uptodate_list)) if outofdate_list: print('\nOut-of-date tasks:') print(ui.listing(outofdate_list)) return uptodate, statuses
def test_listing(self): d = {'a': 2, 'b': 5, 'c': 10} exp_d = '* a: 2\n* b: 5\n* c: 10\n' exp_l = '* a\n* b\n* c\n' assert listing(d) == exp_d assert listing(d.keys()) == exp_l
def print_meta(handler): '''Print metadata about the database pipeline. Args: handler (handler.TaskHandler): The database task handler. ''' print(ui.header('Info', level=4)) info = {'Doit Database': handler.dep_file, 'Database Directory': handler.directory} print(ui.listing(info))
def run_annotation(handler): '''Run the annotation pipeline from the given handler. Prints the appropriate output and exits of the pipeline is alredy completed. Args: handler (handler.TaskHandler): Handler with tasks for the pipeline. ''' print(ui.header('Annotation', level=3)) print(ui.header('Info', level=4)) info = {'Doit Database': handler.dep_file, 'Input Transcriptome': handler.files['transcriptome']} print(ui.listing(info)) msg = '*All annotation tasks up-to-date.*' uptodate, statuses = handler.print_statuses(uptodate_msg=msg) if not uptodate: return handler.run() else: print('**Pipeline is already completed!**') sys.exit(0)