Last active
February 9, 2024 03:33
-
-
Save spilth/8442f2d1329ad00272f7cb3a6489f3d9 to your computer and use it in GitHub Desktop.
PrintKey to SBL
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
def values_or_defaults(section="0", subsection="0", block="0", lot="0", subplot="0", suffix="0"): | |
return section, subsection, block, lot, subplot, suffix | |
def print_key_to_sbl(print_key): | |
parts = print_key.replace(".", "-").split("-") | |
section, subsection, block, lot, subplot, suffix = values_or_defaults(*parts) | |
return (f'{section.zfill(3)}' | |
f'{subsection.zfill(3)}' | |
f'{block.zfill(4)}' | |
f'{lot.zfill(3)}' | |
f'{subplot.zfill(3)}' | |
f'{suffix.zfill(4)}') | |
assert (print_key_to_sbl("109.11-1-23") == "10901100010230000000") | |
assert (print_key_to_sbl("109.-1-23") == "10900000010230000000") | |
assert (print_key_to_sbl("109.-1-23.2") == "10900000010230020000") |
@rtwalz Glad you found it useful! How did you manage to find it?
I googled “printkey to sbl” and it was the first result!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank for you sharing this, I was about to write my own and this saved me a good 30 min!