def main(args: argparse.Namespace, in_channel=sys.stdin, out_channel=sys.stdout) -> None: """ $ <cmd-prefix> gen <source> <target> """ template = NamedTemporaryFile(mode='w', encoding='utf-8') if args.source is None: read_from = in_channel else: read_from = Path(args.source).open('r') with read_from as f: slides = f.read() base_path = resource_filename('presentations', 'templates/base.plim') with codecs.open(base_path, mode='r', encoding='utf-8') as base_file: base_template = base_file.read() base_template = base_template.replace('{{{ presentation_slides }}}', slides) template.write(base_template) template.flush() args = [ '--encoding', 'utf8', '--preprocessor', 'presentations:preprocessor', '-o', args.output, '--html', template.name ] return plimc(args, out_channel)
def present(args=None, stdout=None): template = NamedTemporaryFile(mode='w', encoding='utf-8') with codecs.open('django-adt.slides', mode='r', encoding='utf-8') as presentation_file: base_path = resource_filename('presentations', 'templates/base.plim') with codecs.open(base_path, mode='r', encoding='utf-8') as base_file: base_template = base_file.read() presentation_template = presentation_file.read() base_template = base_template.replace( '{{{ presentation_slides }}}', presentation_template) template.write(base_template) template.flush() args = [ '--encoding', 'utf8', '--preprocessor', 'presentations:preprocessor', '-o', 'django-adt.html', '--html', template.name ] return plimc(args, stdout)
def test_cli_html_output(self): plimc(['--html', 'tests/fixtures/unicode_attributes_test.plim'], stdout=self.stdout)
def test_cli_mako_output(self): plimc(['tests/fixtures/unicode_attributes_test.plim'], stdout=self.stdout)