This repository was archived by the owner on Oct 2, 2020. It is now read-only.
schlib improvement to handle double-quote text in symbol user fields#324
Open
eeintech wants to merge 1 commit intoKiCad:masterfrom
Open
schlib improvement to handle double-quote text in symbol user fields#324eeintech wants to merge 1 commit intoKiCad:masterfrom
eeintech wants to merge 1 commit intoKiCad:masterfrom
Conversation
eeintech
commented
Apr 23, 2020
Comment on lines
+156
to
+158
| if '\\"' in line: | ||
| import re | ||
| line = re.findall(r'(?:[^\s,"]|"(?:\\.|[^"])*")+', line) |
Author
There was a problem hiding this comment.
If double-quote detected in line, split using regex instead of posix
…t contains double-quotes (ex: in reference to 'inch' imperial unit)
37813e1 to
36eebf3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While working on my little tool to parse symbol library files, I've noticed that there was a little bug to handle user fields (F3 and up) when a double-quote was inserted in the text field, the library parser was handling it as an escape quote. It appears to come from the shlex command parser which has no insight on how to treat this character.
I've tried to solve it using shlex but eventually gave up, I even posted on StackOverflow:
https://stackoverflow.com/questions/60877782/python-shlex-posix-usage-dilemma
Instead, I've found regex pattern matching for user fields containing double-quotes works well, based on this answer:
https://stackoverflow.com/a/16710842/12794913
I've tested this change quite extensively as I've been doing a lot of library clean-up for my company.
I'm open to other implementation, just wanted to give a heads-up on this little annoying bug.
Here is a little code snippet if you want to understand the issue I'm referring to: