Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- """TransPerm
- Tool that translates base-1 'tasks' to base-0 'tasks' and vice versa. A task is
- a underscore separated list of permutations.
- Usage:
- transperm (-0 | -1) [TASK ...]
- transperm (-h | --help)
- Options:
- -h --help Show this screen
- Happy birthday Henning!
- """
- import sys
- import re
- from permuta import Perm
- from docopt import docopt
- if __name__ == "__main__":
- arguments = docopt(__doc__, version='TransPerm 0.0.1')
- if arguments['TASK']:
- tasks = arguments['TASK']
- else:
- tasks = sys.stdin.readlines()
- for task in tasks:
- out = []
- for perm in map(Perm.to_standard, re.split("[^0-9]", task)):
- if arguments['-1']:
- out.append(''.join(str(int(p) + 1) for p in perm))
- else:
- out.append(''.join(str(p) for p in perm))
- sys.stdout.write('_'.join(out))
- sys.stdout.write('\n')
Add Comment
Please, Sign In to add comment