Skip to content

Commit

Permalink
add Parameter.permutate(data)
Browse files Browse the repository at this point in the history
  • Loading branch information
laszewsk committed Jan 24, 2024
1 parent 4ee6be8 commit e5437de
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/cloudmesh/common/parameter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from cloudmesh.common.dotdict import dotdict
from hostlist import expand_hostlist
from itertools import product


class Parameter(object):
Expand Down Expand Up @@ -212,3 +213,18 @@ def separate(text, sep=":"):
return text.split(sep, 1)
else:
return None, text

@staticmethod
def permutate(data):
"""returns a list of all permutations of the dict
Args:
data: the dict
Returns:
list of dicts
"""
keys = data.keys()
values = data.values()
permutations = [dict(zip(keys, v)) for v in product(*values)]
return permutations

0 comments on commit e5437de

Please sign in to comment.