Created
March 12, 2020 20:17
-
-
Save phargogh/a1e33f060738cf9d921e7d7b6e4e4d60 to your computer and use it in GitHub Desktop.
Print Multiple Flow Direction weights to the CLI when given a packed weight
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
import sys | |
def doit(): | |
packed_flow_dir = int(sys.argv[1]) | |
weights = [(packed_flow_dir >> 4*i) & 0xF for i in range(8)] | |
weights = [str(w).rjust(2, ' ') for w in weights] | |
print(weights) | |
print('%s | %s | %s' % (weights[3], weights[2], weights[1])) | |
print('---+----+---') | |
print('%s | | %s' % (weights[4], weights[0])) | |
print('---+----+---') | |
print('%s | %s | %s' % (weights[5], weights[6], weights[7])) | |
if __name__ == '__main__': | |
doit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment