Yields all possible permutations from the options list
()
| 49 | return expanded |
| 50 | |
| 51 | def permutations(): |
| 52 | """Yields all possible permutations from the options list""" |
| 53 | count = len(option.abrvs) |
| 54 | |
| 55 | # Each option is a binary choice, so we use an int as a quick bitmap. |
| 56 | # To iterate over every possible permutation, all we have to do is increment |
| 57 | # up to the maximum value 2^(#options) |
| 58 | bitmap_max = 1 << count |
| 59 | |
| 60 | # Iterate over all possible permutations |
| 61 | for i in xrange(bitmap_max): |
| 62 | # Map the iteration's permutations using a bitmap |
| 63 | bitmap = [i >> n & 1 for n in xrange(count)] |
| 64 | for opts in _expand_options(bitmap): |
| 65 | yield(int(float(i)/bitmap_max*100), opts) |
| 66 | |
| 67 | def _build(dstdir, font, permutations): |
| 68 | # Ensure that the destination directory exists |
no test coverage detected