summaryrefslogtreecommitdiff
path: root/Pb_Api/ImPattern/Params.py
diff options
context:
space:
mode:
authoryo mama <pepper@scannerjammer.com>2015-03-05 19:09:51 -0800
committeryo mama <pepper@scannerjammer.com>2015-03-05 19:09:51 -0800
commite6dcac83910b1d022b05ca68fc8b0d4b2d32c619 (patch)
tree794165705c3d6e9003caae910fbcace9ebaa855f /Pb_Api/ImPattern/Params.py
parente7d397472c7f6f6ba7b911ae8afff9bcb6a56b92 (diff)
fixed some great stuff
Diffstat (limited to 'Pb_Api/ImPattern/Params.py')
-rw-r--r--Pb_Api/ImPattern/Params.py37
1 files changed, 32 insertions, 5 deletions
diff --git a/Pb_Api/ImPattern/Params.py b/Pb_Api/ImPattern/Params.py
index c01fd4d..a046d5e 100644
--- a/Pb_Api/ImPattern/Params.py
+++ b/Pb_Api/ImPattern/Params.py
@@ -1,18 +1,45 @@
#!/usr/bin/python2.7
+import re
from Pb_Api.Params import Pb_Api_Params
from Pb_Api.Param import Pb_Api_Param
+from Pb_Api.Param.Option import Pb_Api_Param_Option
+from Pb_Api.Param.Options import Pb_Api_Param_Options
from Pb_Api.Param.Username import Pb_Api_Param_Username
from Pb_Api.Param.Image_Url import Pb_Api_Param_Image_Url
from Pb_Api.Param.MultiSelect import Pb_Api_Param_MultiSelect
-pattern_url_options = [
- { "value":"1.png", "weight":1 },
- { "value":"2.png", "weight":1 },
-]
+from config import PATTERN_BASE_URL
+
+class Pattern_Url_Option(Pb_Api_Param_Option):
+ def __init__(self, **kwargs):
+ super(Pb_Api_Param_Option, self).__init__(**kwargs)
+ @classmethod
+ def from_name(cls, **kwargs):
+ formatted = "{}/{}.png".format(PATTERN_BASE_URL, kwargs["value"])
+ return cls(weight=kwargs["weight"], value=formatted )
+
+class Pattern_Url_Options:
+ def __init__(self, arr):
+ self._values = arr
+ def __iter__(self):
+ return self._values
+ def grep(self, s):
+ for i in self:
+ if re.match(s, i):
+ return i
+
+
+pattern_url_options = Pb_Api_Param_Options([
+ Pattern_Url_Option.from_name(weight=0, value=i) for i in range(1,100) ] + [
+ Pattern_Url_Option.from_name(weight=0, value="A{}".format(i)) for i in range(0, 42)
+])
+
+pattern_url_options.search("A10").weight = 20;
+
class ImPattern_Params(Pb_Api_Params):
def __init__(self):
self.params = [
- Pb_Api_Param_Username(name="username", required=1),
+ Pb_Api_Param_Username(name="username", required=0),
Pb_Api_Param_Image_Url(name="image_url", required=1),
Pb_Api_Param_MultiSelect(name="pattern_url", required=1, options=pattern_url_options)
]