| 35 | option.abrvs = option.abrvs[:-len(abrvs)] + [tuple(abrvs)] |
| 36 | |
| 37 | def _expand_options(bitmap): |
| 38 | # Apply the bitmap to the options |
| 39 | opts = compress(option.abrvs, bitmap) |
| 40 | |
| 41 | # Expand the permutations for all options |
| 42 | expanded = [[]] |
| 43 | for opt in opts: |
| 44 | if isinstance(opt, tuple): |
| 45 | expanded = [items + [prmtn] for items in expanded for prmtn in opt] |
| 46 | else: |
| 47 | expanded = [items + [opt] for items in expanded] |
| 48 | |
| 49 | return expanded |
| 50 | |
| 51 | def permutations(): |
| 52 | """Yields all possible permutations from the options list""" |