spakin / SimpInkScr

Simple Inkscape Scripting
https://inkscape.org/~pakin/%E2%98%85simple-inkscape-scripting
GNU General Public License v3.0
320 stars 31 forks source link

Fixing and improving the removal of imports when using VSCode #133

Closed rmcginty closed 5 months ago

rmcginty commented 5 months ago

The line that I replaced was supposed to be removing the duplicate import that is required in a script if you want to develop in VSCode and have code completion, etc... It turns out the line didn't actually do anything because the replace method of a string doesn't change the string, so it needed to be reassigned to the variable, like code = code.replace(...

While fixing and testing this change, I realized that just a little more work and it could remove more combinations and iterations of the imports that might be used or suggested by VSCode, so I built and tested a regex that seems to do the trick with just about every situation I've come across while using VSCode and all the Python tools.

I'm open to comments and/or feedback, so please let me know if there are any suggestions!

rmcginty commented 5 months ago

See the replacement regex and let me know what you think.