sparkfunX / Buzzard

Software tools for EAGLE silkscreen generation
100 stars 18 forks source link

Parsing collections with Linux line endings? Maybe? #16

Closed NPoole closed 4 years ago

NPoole commented 4 years ago

Eli can't write a valid collections.txt in VIM. We suspect this has to do with the parser and line endings but we are still working to confirm.

edspark commented 4 years ago

Good morning!

I'm a little more rested this morning. @NPoole your initial solution was correct. At the end of the last line in the text file was a new line character which was leading the with statement in generatCollection to add another blank line after the last line of text. Shown below is the extra element in the collection variable:

image

I had to delete the last character to also delete the hidden new line character (and then re-enter that last character) so that it would run smoothly for me.

A possible solution is to check the number of lines in the file and compare them to the length of the array, if the array length exceeds the number of lines and that last entry doesn't have any arguments - just pop it off.

I'm happy to do a pull request if that seems sufficient @oclyke or @NPoole.

edspark commented 4 years ago

Also it would be cool to be able to select the output mode with this. I know it's not taken in from the script and I think that's the way to go, but it should be taken in from the command line.

oclyke commented 4 years ago

Good spot Eli! Without looking too closely I wonder if we can handle these 'empty arrays' in a similar way to how I handled empty commands? It may be easier to maintain than counting lines vs. commands - particularly because right now the script is allowing blank lines (which are useful in lieu of comments to at least break your labels into logical chunks)

edspark commented 4 years ago

That works! I was being overly redundant by counting lines in an attempt to curb bugs I couldn't think of. Especially since generateCollection was already reading each individual line to parse arguments.

edspark commented 4 years ago

I added the "filter" line of code into my version of buzzard and it worked like a charm all weekend long.

NPoole commented 4 years ago

Awesome, pushed!