diff options
| author | pepperpepperpepper <pepper@scannerjammer.com> | 2015-10-04 21:05:22 -0700 |
|---|---|---|
| committer | pepperpepperpepper <pepper@scannerjammer.com> | 2015-10-04 21:05:22 -0700 |
| commit | 3629cf6d6d2b28f277c6d4d0e32ac10e4403ab85 (patch) | |
| tree | 861197220dafc39cbdd2d2147d72f4cf1b851160 | |
| parent | 69845d6d9594db1b1ed22a47c2042c48ef98b495 (diff) | |
fixed some bad structure
| -rw-r--r-- | ricky/imbreak/params.py | 2 | ||||
| -rw-r--r-- | ricky/imgradient/params.py | 2 | ||||
| -rw-r--r-- | ricky/imgrid/params.py | 2 | ||||
| -rw-r--r-- | ricky/impattern/params.py | 2 | ||||
| -rw-r--r-- | ricky/params.py | 22 |
5 files changed, 19 insertions, 11 deletions
diff --git a/ricky/imbreak/params.py b/ricky/imbreak/params.py index e5de5c7..01a46e4 100644 --- a/ricky/imbreak/params.py +++ b/ricky/imbreak/params.py @@ -46,7 +46,7 @@ expanded_options = Options.from_dict( class ImBreakParams(Params): def __init__(self): - self.params = [ + self._params = [ Username(name="username", required=0), ImageUrl(name="url", required=1), MultiSelect(name="finalformat", required=0, options=finalformat_options), diff --git a/ricky/imgradient/params.py b/ricky/imgradient/params.py index 88b7d46..9d44b2a 100644 --- a/ricky/imgradient/params.py +++ b/ricky/imgradient/params.py @@ -15,7 +15,7 @@ from ricky.imgradient.options import * class ImGradientParams(Params): def __init__(self): - self.params = [ + self._params = [ Username(name="username", required=0), NumberRange(name="width", required=1, options=width_options, min=100, max=800), NumberRange(name="height", required=1, options=height_options, min=100, max=800), diff --git a/ricky/imgrid/params.py b/ricky/imgrid/params.py index 8b63759..0d78c08 100644 --- a/ricky/imgrid/params.py +++ b/ricky/imgrid/params.py @@ -59,7 +59,7 @@ class Param_Opacity(NumberRange): class ImGridParams(Params): def __init__(self): - self.params = [ + self._params = [ Username(name="username", required=0), ImageUrl(name="bgimage", required=0), ImageUrl(name="imageinstead", required=0), diff --git a/ricky/impattern/params.py b/ricky/impattern/params.py index 90907fc..833bed1 100644 --- a/ricky/impattern/params.py +++ b/ricky/impattern/params.py @@ -19,7 +19,7 @@ class Pattern_UrlOption(Option): class ImPatternParams(Params): def __init__(self): - self.params = [ + self._params = [ Username(name="username", required=0), ImageUrl(name="image_url", required=1), MultiSelect(name="pattern_url", required=1, options=pattern_url_options) diff --git a/ricky/params.py b/ricky/params.py index 73a72fa..304ad2d 100644 --- a/ricky/params.py +++ b/ricky/params.py @@ -3,17 +3,19 @@ import pprint class Params(object): def __init__(self): self._api = None + self._params = [] + def param(self, name): - for p in self.params: + for p in self._params: if p.name == name: return p return None - def __str__(self): - return pprint.pformat({ "params": map(lambda x: vars(x), self.params) }) + def __str__(self): + return pprint.pformat({ "params": map(lambda x: vars(x), self._params) }) def randomize(self): - for el in self.params: + for el in self._params: if el.set_by_user: continue el.randomize() @@ -21,21 +23,27 @@ class Params(object): @property def api(self): return self._api + @api.setter def api(self, cls): self._api = cls + def execute(self): return self.api.call(self) def is_ready(self): - for p in self.params: + for p in self._params: if not p.is_ready and not p.default: sys.stderr.write("param not ready: {}".format(p)) return 0 return 1 - def as_dict(self): + + def __dict__(self): result = {} - for p in self.params: + for p in self._params: result[p.name] = p.value return result + + def as_dict(self): + return self.__dict__() |
