Skip to content

Instantly share code, notes, and snippets.

@spilth
Last active February 9, 2024 03:33
Show Gist options
  • Save spilth/8442f2d1329ad00272f7cb3a6489f3d9 to your computer and use it in GitHub Desktop.
Save spilth/8442f2d1329ad00272f7cb3a6489f3d9 to your computer and use it in GitHub Desktop.
PrintKey to SBL
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")
@spilth
Copy link
Author

spilth commented Feb 9, 2024

@rtwalz Glad you found it useful! How did you manage to find it?

@rtwalz
Copy link

rtwalz commented Feb 9, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment