management/render_processing.py
def render(self, context: Optional[dict] = None):
        """
        render the the file through the respective papermills
        """

        if context is None:
            context = {}

        if context:
            self.init_rendered_values(context)

        slug = self.slug

        render_dir = Path("_render", self.name, self.slug)
        if render_dir.exists() is False:
            render_dir.mkdir(parents=True)

        # papermill and render individual notebooks
        for n in self.notebooks:
            n.papermill(self.slug, self.params, rerun=self.options["rerun"])
            n.render(self.slug, hide_input=self.options["hide_input"])

        # combine for both md and html
        for ext in [".md", ".html"]:
            dest = self.rendered_filename(ext)
            files = [x.rendered_filename(self.slug, ext) for x in self.notebooks]
            combine_outputs(files, dest)
            resources_dir = files[0].parent / "_notebook_resources"
            dest_resources = dest.parent / "_notebook_resources"
            shutil.copytree(resources_dir, dest_resources, dirs_exist_ok=True)
            # copy resources folder

        # convert to docx
        input_path_html = self.rendered_filename(".html")
        output_path_doc = self.rendered_filename(".docx")
        template = Path("notebook_helper", "resources", "reference.docx")
        if template.exists() is False:
            raise ValueError("Missing Template")
        reference_doc = str(template)
        pypandoc.convert_file(
            str(input_path_html),
            "docx",
            outputfile=str(output_path_doc),
            extra_args=[
                f"--resource-path={str(render_dir)}",
                f"--reference-doc={reference_doc}",
            ],
        )

        render the the file through the respective papermills
        
render the the file through the respective papermills
render the the file through the respective papermills
def render(self, context: Optional[dict] = None):
        if context is None:
            context = {}
        if context:
            self.init_rendered_values(context)
        slug = self.slug
        render_dir = Path("_render", self.name, self.slug)
        if render_dir.exists() is False:
            render_dir.mkdir(parents=True)
        for n in self.notebooks:
            n.papermill(self.slug, self.params, rerun=self.options["rerun"])
            n.render(self.slug, hide_input=self.options["hide_input"])
        for ext in [".md", ".html"]:
            dest = self.rendered_filename(ext)
            files = [x.rendered_filename(self.slug, ext) for x in self.notebooks]
            combine_outputs(files, dest)
            resources_dir = files[0].parent / "_notebook_resources"
            dest_resources = dest.parent / "_notebook_resources"
            shutil.copytree(resources_dir, dest_resources, dirs_exist_ok=True)
        input_path_html = self.rendered_filename(".html")
        output_path_doc = self.rendered_filename(".docx")
        template = Path("notebook_helper", "resources", "reference.docx")
        if template.exists() is False:
            raise ValueError("Missing Template")
        reference_doc = str(template)
        pypandoc.convert_file(
            str(input_path_html),
            "docx",
            outputfile=str(output_path_doc),
            extra_args=[
                f"--resource-path={str(render_dir)}",
                f"--reference-doc={reference_doc}",
            ],
        )
def render ( self , context : Optional [ dict ] = None ) : if context is None : context = { } if context : self . init_rendered_values ( context ) slug = self . slug render_dir = Path ( "_render" , self . name , self . slug ) if render_dir . exists ( ) is False : render_dir . mkdir ( parents = True ) for n in self . notebooks : n . papermill ( self . slug , self . params , rerun = self . options [ "rerun" ] ) n . render ( self . slug , hide_input = self . options [ "hide_input" ] ) for ext in [ ".md" , ".html" ] : dest = self . rendered_filename ( ext ) files = [ x . rendered_filename ( self . slug , ext ) for x in self . notebooks ] combine_outputs ( files , dest ) resources_dir = files [ 0 ] . parent / "_notebook_resources" dest_resources = dest . parent / "_notebook_resources" shutil . copytree ( resources_dir , dest_resources , dirs_exist_ok = True ) input_path_html = self . rendered_filename ( ".html" ) output_path_doc = self . rendered_filename ( ".docx" ) template = Path ( "notebook_helper" , "resources" , "reference.docx" ) if template . exists ( ) is False : raise ValueError ( "Missing Template" ) reference_doc = str ( template ) pypandoc . convert_file ( str ( input_path_html ) , "docx" , outputfile = str ( output_path_doc ) , extra_args = [ f"--resource-path={str(render_dir)}" , f"--reference-doc={reference_doc}" , ] , )
render the the file through the respective papermills
render the the file through the respective papermills
"""
        render the the file through the respective papermills
        """ # papermill and render individual notebooks # combine for both md and html # copy resources folder # convert to docx
self
context
Optional[dict]