def format_records(self, format='text', mode='short', tags=None, reverse=False, *args, **kwargs): if format=='text' and mode=='short': return '\n'.join(self.get_labels(tags=tags, reverse=reverse)) else: records = self.find_records(tags=tags, reverse=reverse, *args, **kwargs) formatter = get_formatter(format)(records, project=self, tags=tags) return formatter.format(mode)
def format_records(self, format='text', mode='short', tags=None, reverse=False, *args, **kwargs): if format=='text' and mode=='short' and ('parameters' not in kwargs.keys()): return '\n'.join(self.get_labels(tags=tags, reverse=reverse, *args, **kwargs)) else: records = self.find_records(tags=tags, reverse=reverse, *args, **kwargs) formatter = get_formatter(format)(records, project=self, tags=tags) return formatter.format(mode)
def format_records(self, format='text', mode='short', tags=None, reverse=False): records = self.find_records(tags=tags, reverse=reverse) formatter = get_formatter(format)(records, project=self, tags=tags) return formatter.format(mode)
def view(argv): """View detail of a single record.""" usage = "%(prog)s view [options] LABEL" description = "View detail of a single record." parser = ArgumentParser(usage=usage, description=description) parser.add_argument('label') parser.add_argument('-s', '--script', action='store_true', help="show script content.") args = parser.parse_args(argv) project = load_project() record = project.get_record(args.label) if args.script: print('Main_File\t :', record.main_file) print(80 * '-') print(record.script_content) print(80 * '-') else: formatter = get_formatter('text')([record], project=project) print(formatter.format('long'))
def test__get_formatter__should_return_Formatter_subclass(self): for format in 'text', 'html', 'textdiff': assert issubclass(get_formatter(format), Formatter)
def export_records(self, records, indent=2): """Returns a string with a JSON representation of the given records.""" json_formatter = get_formatter('json')(records) return json_formatter.long()
def test__get_formatter__should_return_Formatter_subclass(self): for format in "text", "html", "textdiff": assert issubclass(get_formatter(format), Formatter)