SVG-Optimiser icon indicating copy to clipboard operation
SVG-Optimiser copied to clipboard

Python3 support (work in progress).

Open skakri opened this issue 10 years ago • 2 comments

Python 3 support.

skakri avatar Jan 31 '15 21:01 skakri

Hi, Peter.

This pull request is work in progress to keep you up to date with the changes I've implemented/intending to implement.

I've stumbled upon your project and wanted to use it in my application, which uses Python3 (my scope is – upload SVG, clean it up, remove styles and style it via external, generated CSS).

This is a stub to add Python 3 support. I intend to use six compatibility layer, to keep Python 2 support.

I've also renamed internal/external functions, to use underscored naming. If you think that this change could break users' code, we could add camelCased function aliases with deprecation messages. I'd like to also rename module name (file cleanSVG.py) to clean_svg if you don't mind.

Also I wish to implement two extra (optional) named parameters to extract_styles method – in my use case I need to strip fill style and keep others (I wish to change fill style via external CSS dynamically). Parameters are as folows: - internal (boolean) – if True (default, same as current behaviour) – store styles in SVG file in class, False – omits _add_style_element function call and adds generated CSS to instance.stylesheet instead so SVG and styles can be used separately. - strip (list) – if defined (defaults to empty list) – strips these styles completely. They won't be available in instance.stylesheet if called with internal parameter.

I need this to be implemented "as soon as possible"™, so I'm going to make a sub-branch from this one and rebase later, if that's okay.

I'm open to comments and suggestions.

skakri avatar Jan 31 '15 21:01 skakri

I just checked, actually these changes work with Python 2 just fine (tests would be great though, as I've tested with only a couple of SVGs).

skakri avatar Jan 31 '15 22:01 skakri