Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello, I probably find I bug in 'deepsvg/svglib /svg.py' (merge_group) #39

Open
JasonLLLLLLLLLLL opened this issue Dec 30, 2023 · 0 comments

Comments

@JasonLLLLLLLLLLL
Copy link

JasonLLLLLLLLLLL commented Dec 30, 2023

From the line 250 to 255, there is a func called merge_groups().
the code is as follows:

    def merge_groups(self):
        path_group = self.svg_path_groups[0]
        for path_group in self.svg_path_groups[1:]:
            path_group.svg_paths.extend(path_group.svg_paths)
        self.svg_path_groups = [path_group]
        return self

The variable path_group is being reused in the for loop, which causes confusion to me when I use this function. Inside the loop, path_group.svg_paths.extend(path_group.svg_paths) doesn't make sense because it is trying to extend path_group.svg_paths with itself. This is likely an error.
I think it is should be(the **group** is the difference between the two codes):

    def merge_groups(self):
        path_group = self.svg_path_groups[0]
        for **group** in self.svg_path_groups[1:]:
            path_group.svg_paths.extend(**group**.svg_paths)
        self.svg_path_groups = [path_group]
        return self

I use a different variable name (group) in the for loop. Here, path_group.svg_paths.extend(group.svg_paths) correctly extends the svg_paths of the first group.
Hopefully, You can notice this message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant