summaryrefslogtreecommitdiff
path: root/ricky/param/selections.py
blob: 303c92ee24389f531928ac3327e66c57c0e801dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from ricky.param.option import Selection
import sys
class Selections:
  def __init__(self, *args):
    self._values = args
  def __iter__(self):
    return iter(self._values)
  def __len__(self):
    return len(self._values)
  def __str__(self):
    return str(self._values)
  def __getitem__(self, i):
    return self._values[i]
  def search(self, s):
    for i in self:
      if str(s) in i.value:
        return i
  @classmethod
  def from_dict(cls, *args):
    selections = map(lambda x: Selection(**x), args);
    return cls(*selections);