diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-03-06 00:52:17 -0800 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-03-06 00:52:17 -0800 |
| commit | 107b40de0a2a7bcb6abcebb9aabd0f5bb7dabb4b (patch) | |
| tree | 6bed9434b1821f9eb5e4f87283e6761a61fcb66b | |
| parent | 497adf6689bdbe6183c6343062572b84a26892b2 (diff) | |
option
| -rw-r--r-- | Pb_Api/Param/Option.py | 9 | ||||
| -rw-r--r-- | Pb_Api/Param/Options.py | 13 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Pb_Api/Param/Option.py b/Pb_Api/Param/Option.py new file mode 100644 index 0000000..2a345e7 --- /dev/null +++ b/Pb_Api/Param/Option.py @@ -0,0 +1,9 @@ +class Pb_Api_Param_Option(dict): + def __init__(self, **kwargs): + super(Pb_Api_Param_Option, self).__init__(**kwargs) + self.value = kwargs["value"] + self.weight = kwargs["weight"] + def __getattr__(self, attr): + return self.get(attr) + __setattr__= dict.__setitem__ + __delattr__= dict.__delitem__ diff --git a/Pb_Api/Param/Options.py b/Pb_Api/Param/Options.py new file mode 100644 index 0000000..d19f42a --- /dev/null +++ b/Pb_Api/Param/Options.py @@ -0,0 +1,13 @@ +class Pb_Api_Param_Options: + def __init__(self, arr): + self._values = arr + def __iter__(self): + return iter(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 |
