Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Expected bug - SlideSet not passing along args to Slide #307

@kheffah

Description

@kheffah

Describe the bug
This is a bug that needs to be addressed after PR #303 is merged and before PR #301 is merged into master (or vice versa). Since PR #301 introduces a new parameter, use_largeimage to Slide, this parameter needs to also be passed along to Slide. To avoid conflicts, this should be done between the time one of these two PRs is merged into master.

Expected behavior

  • SlideSet should take an extra parameter, slide_kwargs which is a dict, which gets expanded and passed along as-is to each Slide when it is called by the iterator.
  • While we're at it, SlideSet should disallow positional arguments beyond the the obligatory ones.

Solution would be something like this:

class SlideSet:
    """Slideset object. It is considered a collection of Slides."""

    def __init__(
        self,
        slides_path: str,
        processed_path: str,
        valid_extensions: List[str],
        *,
        keep_slides: List[str] = None,
        slide_kwargs: dict = None,
    ) -> None:
        self._slides_path = slides_path
        self._processed_path = processed_path
        self._valid_extensions = valid_extensions
        self._keep_slides = keep_slides
        self._slide_kwargs = slide_kwargs

    def __iter__(self) -> Iterator[Slide]:
        """Slides of the slideset

        Returns
        -------
        generator of `Slide` objects.
        """
        slide_names = [
            name
            for name in os.listdir(self._slides_path)
            if (os.path.splitext(name)[1] in self._valid_extensions)
        ]
        if self._keep_slides is not None:
            slide_names = [name for name in slide_names if name in self._keep_slides]
        return iter(
            [
                Slide(
                    os.path.join(self._slides_path, name), 
                    self._processed_path,
                    **self._slide_kwargs
                )
                for name in slide_names
            ]
        )

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingroadmapRoadmap features we are/wanna workin' on

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions