Beispiel #1
0
    def preprocess(self, nb, resources):
        """Concatenates the cells from the header and footer notebooks to the
        given cells.

        """
        new_cells = []

        # header
        if self.header:
            with open(self.header, 'r') as fh:
                header_nb = read_nb(fh, 'ipynb')
            new_cells.extend(header_nb.worksheets[0].cells)

        # body
        new_cells.extend(nb.worksheets[0].cells)

        # footer
        if self.footer:
            with open(self.footer, 'r') as fh:
                footer_nb = read_nb(fh, 'ipynb')
            new_cells.extend(footer_nb.worksheets[0].cells)

        nb.worksheets[0].cells = new_cells
        super(IncludeHeaderFooter, self).preprocess(nb, resources)

        return nb, resources
    def _concatenate_notebooks(self, cells):
        """Concatenates the cells from the header and footer notebooks to the
        given cells.

        """
        new_cells = []

        # header
        if self.header != "":
            with open(self.header, 'r') as fh:
                header_nb = read_nb(fh, 'ipynb')
            new_cells.extend(header_nb.worksheets[0].cells)

        # body
        new_cells.extend(cells)

        # footer
        if self.footer != "":
            with open(self.footer, 'r') as fh:
                footer_nb = read_nb(fh, 'ipynb')
            new_cells.extend(footer_nb.worksheets[0].cells)

        return new_cells
 def setup(self):
     with open("tests/files/test.ipynb", "r") as fh:
         self.nb = read_nb(fh, "ipynb")
     self.cells = self.nb.worksheets[0].cells
     self.preprocessor = AssignmentPreprocessor()
Beispiel #4
0
 def setup(self):
     self.pth = os.path.split(os.path.realpath(__file__))[0]
     with open(os.path.join(self.pth, "files/test.ipynb"), "r") as fh:
         self.nb = read_nb(fh, 'ipynb')
     self.cells = self.nb.worksheets[0].cells
 def setup(self):
     with open("tests/files/test.ipynb", "r") as fh:
         self.nb = read_nb(fh, 'ipynb')
     self.cells = self.nb.worksheets[0].cells
     self.preprocessor = GradingPreprocessor()
     self.preprocessor.autograder_tests_file = "tests/files/autograder_tests.json"