def generate(self): d = {} log_file = filesnpaths.get_temp_file_path() num_all_programs = len(self.all_programs) for i in range(0, num_all_programs): program_path = self.all_programs[i] program_name = os.path.basename(program_path) if program_name in self.programs_to_skip: run.warning("Someone doesn't want %s to be in the output :/ Fine. Skipping." % (program_name)) progress.new('Bleep bloop') progress.update('%s (%d of %d)' % (program_name, i+1, num_all_programs)) output = utils.run_command_STDIN('%s --help' % (program_path), log_file, '').split('\n') if anvio.DEBUG: usage, description, params, output = parse_help_output(output) else: try: usage, description, params, output = parse_help_output(output) except Exception as e: progress.end() run.warning("The program '%s' does not seem to have the expected help menu output. Skipping to the next.\ For the curious, this was the error message: '%s'" % (program_name, str(e).strip())) continue d[program_name] = {'usage': usage, 'description': description, 'params': params, 'tags': get_meta_information_from_file(program_path, '__tags__'), 'resources': get_meta_information_from_file(program_path, '__resources__')} progress.end() os.remove(log_file) # generate output program_names = sorted([p for p in d if not p.startswith('anvi-script-')]) script_names = sorted([p for p in d if p.startswith('anvi-script-')]) vignette = {'vignette': d, 'program_names': program_names, 'script_names': script_names, 'all_names': program_names + script_names, 'meta': {'summary_type': 'vignette', 'version': '\n'.join(['|%s|%s|' % (t[0], t[1]) for t in anvio.get_version_tuples()]), 'date': utils.get_date()}} if anvio.DEBUG: run.warning(None, 'THE OUTPUT DICT') import json print(json.dumps(d, indent=2)) open(self.output_file_path, 'w').write(SummaryHTMLOutput(vignette, r=run, p=progress).render()) run.info('Output file', os.path.abspath(self.output_file_path))
def generate_pages_for_artifacts(self): """Generates static pages for artifacts in the output directory""" self.progress.new("Rendering artifact pages", progress_total_items=len(ANVIO_ARTIFACTS)) self.progress.update('...') for artifact in ANVIO_ARTIFACTS: self.progress.update(f"'{artifact}' ...", increment=True) d = { 'artifact': ANVIO_ARTIFACTS[artifact], 'meta': { 'summary_type': 'artifact', 'version': '\n'.join([ '|%s|%s|' % (t[0], t[1]) for t in anvio.get_version_tuples() ]), 'date': utils.get_date(), 'version_short_identifier': self.version_short_identifier } } d['artifact']['name'] = artifact d['artifact']['required_by'] = [ (r, '../../programs/%s' % r) for r in self.artifacts_info[artifact]['required_by'] ] d['artifact']['provided_by'] = [ (r, '../../programs/%s' % r) for r in self.artifacts_info[artifact]['provided_by'] ] d['artifact']['description'] = self.artifacts_info[artifact][ 'description'] d['artifact'][ 'icon'] = '../../images/icons/%s.png' % ANVIO_ARTIFACTS[ artifact]['type'] if anvio.DEBUG: self.progress.reset() run.warning(None, 'THE OUTPUT DICT') import json print(json.dumps(d, indent=2)) self.progress.update(f"'{artifact}' ... rendering ...", increment=False) artifact_output_dir = filesnpaths.gen_output_directory( os.path.join(self.artifacts_output_dir, artifact)) output_file_path = os.path.join(artifact_output_dir, 'index.md') open(output_file_path, 'w').write(SummaryHTMLOutput(d, r=run, p=progress).render()) self.progress.end()
def generate_pages_for_programs(self): """Generates static pages for programs in the output directory""" program_provides_requires_dict = self.get_program_requires_provides_dict( ) for program_name in self.programs: program = self.programs[program_name] d = { 'program': {}, 'meta': { 'summary_type': 'program', 'version': '\n'.join([ '|%s|%s|' % (t[0], t[1]) for t in anvio.get_version_tuples() ]), 'date': utils.get_date() } } d['program']['name'] = program_name d['program']['usage'] = program.usage d['program']['description'] = program.meta_info['description'][ 'value'] d['program']['resources'] = program.meta_info['resources']['value'] d['program']['requires'] = program_provides_requires_dict[ program_name]['requires'] d['program']['provides'] = program_provides_requires_dict[ program_name]['provides'] d['program']['icon'] = '../../images/icons/%s.png' % 'PROGRAM' d['artifacts'] = self.artifacts_info if anvio.DEBUG: run.warning(None, 'THE OUTPUT DICT') import json print(json.dumps(d, indent=2)) program_output_dir = filesnpaths.gen_output_directory( os.path.join(self.programs_output_dir, program_name)) output_file_path = os.path.join(program_output_dir, 'index.md') open(output_file_path, 'w').write(SummaryHTMLOutput(d, r=run, p=progress).render()) # create the program network, too program_network = ProgramsNetwork(argparse.Namespace( output_file=os.path.join(program_output_dir, "network.json"), program_names_to_focus=program_name), r=terminal.Run(verbose=False)) program_network.generate()
def generate_pages_for_artifacts(self): """Generates static pages for artifacts in the output directory""" for artifact in ANVIO_ARTIFACTS: d = { 'artifact': ANVIO_ARTIFACTS[artifact], 'meta': { 'summary_type': 'artifact', 'version': '\n'.join([ '|%s|%s|' % (t[0], t[1]) for t in anvio.get_version_tuples() ]), 'date': utils.get_date() } } d['artifact']['name'] = artifact d['artifact']['required_by'] = [ (r, '../../programs/%s' % r) for r in self.artifacts_info[artifact]['required_by'] ] d['artifact']['provided_by'] = [ (r, '../../programs/%s' % r) for r in self.artifacts_info[artifact]['provided_by'] ] d['artifact']['description'] = self.artifacts_info[artifact][ 'description'] d['artifact'][ 'icon'] = '../../images/icons/%s.png' % ANVIO_ARTIFACTS[ artifact]['type'] if anvio.DEBUG: run.warning(None, 'THE OUTPUT DICT') import json print(json.dumps(d, indent=2)) artifact_output_dir = filesnpaths.gen_output_directory( os.path.join(self.artifacts_output_dir, artifact)) output_file_path = os.path.join(artifact_output_dir, 'index.md') open(output_file_path, 'w').write(SummaryHTMLOutput(d, r=run, p=progress).render())