def extensions(fmt): ext = OrderedDict() ext['tools'] = OrderedDict() for name, tool in sorted(get_tools().items()): ext['tools'][name] = getdoc(tool) ext['reports'] = OrderedDict() for name, report in sorted(get_reports().items()): ext['reports'][name] = getdoc(report) ext['extenders'] = OrderedDict() for name, extender in sorted(get_extenders().items()): ext['extenders'][name] = getdoc(extender) if fmt == 'toml': click.echo(basicserial.to_toml(ext, pretty=True)) elif fmt == 'json': click.echo(basicserial.to_json(ext, pretty=True)) elif fmt == 'yaml': click.echo(basicserial.to_yaml(ext, pretty=True)) elif fmt == 'csv': writer = csv.writer(click.get_text_stream('stdout')) writer.writerow(['type', 'name', 'description']) for type_ in ext: for name, description in ext[type_].items(): writer.writerow([type_, name, description])
def default_config(pyproject): config = get_default_config() # Don't include empty option dicts for tool in get_tools(): if not config[tool]['options']: del config[tool]['options'] if pyproject: config = {'tool': {'tidypy': config}} click.echo(basicserial.to_toml(config, pretty=True))
def list_codes(tools, fmt): all_tools = get_tools() tools = tools or sorted(all_tools.keys()) codes = OrderedDict() for tool in tools: codes[tool] = dict(all_tools[tool].get_all_codes()) if fmt == 'toml': click.echo(basicserial.to_toml(codes, pretty=True)) elif fmt == 'json': click.echo(basicserial.to_json(codes, pretty=True)) elif fmt == 'yaml': click.echo(basicserial.to_yaml(codes, pretty=True)) elif fmt == 'csv': writer = csv.writer(click.get_text_stream('stdout')) writer.writerow(['tool', 'code', 'message']) for tool in codes: for code, message in codes[tool].items(): writer.writerow([tool, code, message])
def execute(self, collector): issues = self.get_structure(collector) self.output(basicserial.to_toml(issues, pretty=True))