Yields all possible permutations from the options list
()
| 61 | return expanded |
| 62 | |
| 63 | def permutations(): |
| 64 | """Yields all possible permutations from the options list""" |
| 65 | count = len(option.abrvs) |
| 66 | |
| 67 | # Each option is a binary choice, so we use an int as a quick bitmap. |
| 68 | # To iterate over every possible permutation, all we have to do is increment |
| 69 | # up to the maximum value 2^(#options) |
| 70 | bitmap_max = 1 << count |
| 71 | |
| 72 | # Iterate over all possible permutations |
| 73 | for i in xrange(bitmap_max): |
| 74 | # Map the iteration's permutations using a bitmap |
| 75 | bitmap = [i >> n & 1 for n in xrange(count)] |
| 76 | for opts in _expand_options(bitmap): |
| 77 | yield(int(float(i)/bitmap_max*100), opts) |
| 78 | |
| 79 | def _build(dstdir, font, permutations): |
| 80 | for prcnt, opts in permutations: |
no test coverage detected