How to use the scrapbook.scraps.Scrap function in scrapbook

To help you get started, we’ve selected a few scrapbook examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nteract / scrapbook / scrapbook / models.py View on Github external
# Hydrate with output_displays
                        (
                            scrap.name,
                            Scrap(
                                scrap.name,
                                scrap.data,
                                scrap.encoder,
                                output_displays.get(scrap.name),
                            ),
                        )
                        for scrap in output_data_scraps.values()
                    ]
                )
                for name, display in output_displays.items():
                    if name not in output_scraps:
                        output_scraps[name] = Scrap(name, None, "display", display)
                scraps.update(output_scraps)

        return scraps
github nteract / scrapbook / scrapbook / models.py View on Github external
def _fetch_scraps(self):
        """Returns a dictionary of the data recorded in a notebook."""
        scraps = Scraps()

        for cell in self.cells:
            for output in cell.get("outputs", []):
                output_data_scraps = self._extract_output_data_scraps(output)
                output_displays = self._extract_output_displays(output)

                # Combine displays with data while trying to preserve ordering
                output_scraps = Scraps(
                    [
                        # Hydrate with output_displays
                        (
                            scrap.name,
                            Scrap(
                                scrap.name,
                                scrap.data,
                                scrap.encoder,
                                output_displays.get(scrap.name),
                            ),
                        )
                        for scrap in output_data_scraps.values()
                    ]
                )
                for name, display in output_displays.items():
                    if name not in output_scraps:
                        output_scraps[name] = Scrap(name, None, "display", display)
                scraps.update(output_scraps)

        return scraps