Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Fix writing of Number=A and G INFO/FORMAT fields #53
Currently, the Reader stores field Numbers of A and G as negative integers, and the Writer doesn't convert them back to letters.
To make it easier to reverse the cast to integer, I changed the conversion method. Instead of converting using hard-coded if/elif, I've made a module-level dictionary for both conversion and reversal lookup. I'm using if/else because I've read that it's faster than try/except if the check is expected to fail over half the time, and I put
For writing the header fields, I switched to use str.format() (instead of C-style) and added a method that uses the conversion dictionary to switch the integers back to the correct letters.
In the third commit I removed the '.' if None str()