def __generatePermutations(self): """ Combines all values to a set of permutations. These define all possible combinations of the configured settings """ fields = self.__fields values = {} for key in fields: if "values" in fields[key]: values[key] = fields[key]["values"] elif "default" in fields[key] and not "detect" in fields[key]: values[key] = [fields[key]["default"]] # Thanks to eumiro via http://stackoverflow.com/questions/3873654/combinations-from-dictionary-with-list-values-using-python names = sorted(values) combinations = [ dict(zip(names, prod)) for prod in itertools.product(*(values[name] for name in names)) ] permutations = [ Permutation.getPermutation(combi) for combi in combinations ] return permutations
def process(self, code, contextId=""): node = Parser.parse(code) permutation = Permutation.Permutation({ 'debug': False, 'legacy': True, 'engine': 'webkit', 'version': 3, 'fullversion': 3.11 }) Permutate.patch(node, permutation) return Compressor.Compressor().compress(node)
def process(self, code): callerName = inspect.stack()[1][3][5:] permutation = Permutation.Permutation({ "jasy.engine": "gecko", "jasy.debug": True }) tree = Engine.getTree(code, callerName) tree = Engine.permutateTree(tree, permutation) tree = Engine.reduceTree(tree) return Engine.compressTree(tree)
def setStaticPermutation(self, **argv): """Sets current permutation to a static permutation which contains all values hardly wired to static values using setField() or given via additional named parameters.""" combi = {} for name in self.__fields: entry = self.__fields[name] if not "detect" in entry: combi[name] = entry["default"] for name in argv: combi[name] = argv[name] if not combi: self.__permutation = None return None permutation = Permutation.getPermutation(combi) self.__permutation = permutation return permutation
def __generatePermutations(self): """ Combines all values to a set of permutations. These define all possible combinations of the configured settings """ fields = self.__fields values = {} for key in fields: if "values" in fields[key]: values[key] = fields[key]["values"] elif "default" in fields[key] and not "detect" in fields[key]: values[key] = [fields[key]["default"]] # Thanks to eumiro via http://stackoverflow.com/questions/3873654/combinations-from-dictionary-with-list-values-using-python names = sorted(values) combinations = [dict(zip(names, prod)) for prod in itertools.product(*(values[name] for name in names))] permutations = [Permutation.getPermutation(combi) for combi in combinations] return permutations