-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite pad_sort_key
to account for alphanumeric pads.
#17
Conversation
Rewrote pad_sort_key to account for alphanumeric pads.
pcbnew2boardview.py
Outdated
else: | ||
return (1, name) | ||
parts = re.split('([0-9]+)', pad_name) | ||
alphanumeric_parts = [f"{int(text):09d}" if text.isdigit() else text for text in parts if text] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will just as well, without hardcoding numbers:
alphanumeric_parts = [f"{int(text):09d}" if text.isdigit() else text for text in parts if text] | |
alphanumeric_parts = [text[::-1] if text.isdigit() else text for text in parts if text] |
(It reverses the digit order by using a weird bit of Python syntax. It's basically str(reversed(text))
but in one operation.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested it and it still works great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I may need to open a new PR but I will wait on confirmation from you to see if this can be reopened on your end.
I apologize for all of the disorder caused by my PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No this PR cannot be reopened since it was merged.
I will encourage you to learn how to use Git.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I'm very sorry for the mix-up. I'm much better at hardware than I am software. I will make a new PR for this just so that you don't have to be reliant on the .obdata
one to fix this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also yeah there's a logic error, I think this should actually work:
import re # at the beginning of file
def natural_sort_key(s):
return [int(text) if text.isdigit() else text.casefold()
for text in re.compile('([0-9]+)').split(s)]
Co-authored-by: Catherine <whitequark@whitequark.org>
Implemented natural_sort_key fix from whitequark#17 (comment)
This PR rewrites the
![Screenshot 2024-03-19 011926](https://private-user-images.githubusercontent.com/53708281/314660497-de75469f-ef63-4644-acdb-54522bd56b95.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2OTEyMDYsIm5iZiI6MTcxOTY5MDkwNiwicGF0aCI6Ii81MzcwODI4MS8zMTQ2NjA0OTctZGU3NTQ2OWYtZWY2My00NjQ0LWFjZGItNTQ1MjJiZDU2Yjk1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI5VDE5NTUwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM2NzEzYWZmYTM5YTY2M2Y1YTVlZGY0ODMzYTYyODE3NzFkZWMzZmQ5Y2NjNDQxYTRmNzhhMzQwYmI2ZDZiNWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.vKfzS-2KDgabbJAaPrwyyOXrJ-zVKHvA55OXrFlPO3Q)
![Screenshot 2024-03-19 203507](https://private-user-images.githubusercontent.com/53708281/314660505-ed250bd9-31ad-4f9c-a04e-ae3f844a0eba.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2OTEyMDYsIm5iZiI6MTcxOTY5MDkwNiwicGF0aCI6Ii81MzcwODI4MS8zMTQ2NjA1MDUtZWQyNTBiZDktMzFhZC00ZjljLWEwNGUtYWUzZjg0NGEwZWJhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI5VDE5NTUwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE5YmIwMDE1NGU4MjdmYjJjOTRhNmMzOWY5OTYxNmI0YTllZGFmYjdjMmY1YmU4MTQ0YzM0ODZlNzFlNzg2ZWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.aFtHXJa5ofIL6YrzvKhSD9dagNhC6jLPeciKsXxcdpw)
pad_sort_key
function to account for pad names such asA0
found on BGA packages. Below is a before and after with U30 on Glasgow. Previously, the pads were orderedA1, A10, A11, A2, A3....
but now they are in the proper order.