Skip to content

Instantly share code, notes, and snippets.

@phargogh
Created March 12, 2020 20:17
Show Gist options
  • Save phargogh/a1e33f060738cf9d921e7d7b6e4e4d60 to your computer and use it in GitHub Desktop.
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
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