summaryrefslogtreecommitdiff
path: root/lib/param/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/param/__init__.py')
-rw-r--r--lib/param/__init__.py76
1 files changed, 11 insertions, 65 deletions
diff --git a/lib/param/__init__.py b/lib/param/__init__.py
index 10ea7a6..4f3daba 100644
--- a/lib/param/__init__.py
+++ b/lib/param/__init__.py
@@ -1,65 +1,11 @@
-import time
-import sys
-
-from config import WORKING_DIR
-
-class BadParamError(Exception):
- pass
-
-
-class Param(object):
- def __init__(self, classname="", **kwargs):
- self._working_dir = WORKING_DIR
- self._now = kwargs.get("now", str(int(time.time())));
- self._classname = classname
- for key, value in kwargs.items():
- setattr(self, key, value)
-
- def __nonzero__(self):
- return True if self.value else False
-
- def __str__(self):
- return str(self.value)
-
- def __eq__(self, other):
- return self.value == other
-
- def __ne__(self, other):
- return self.value != other
-
- def set_val(self, value):
- try:
- self.value = value
- except Exception as e:
- self.err_warn("Unable to set value {}".format(value))
-
- def err_warn(self, s, error=None):
- self._error_log(s, error=error);
- raise BadParamError("%s - %s" % (self._classname, s))
-
- def __getattr__(self, key):
- try:
- return self.__getattribute__(key);
- except AttributeError:
- return None
-
- def err_fatal(self, s, error=None):
- self._log(s, error, fatal=True);
- sys.exit(1);
-
- def _error_log(self, s, error=None, fatal=False):
- message = "ERROR - BAD PARAM"
- if fatal: message += "- [FATAL] -"
- sys.stderr.write("{}:{} - {}\n".format(message, self._classname, s))
- if error:
- sys.stderr.write("PARAM ERROR: {}\n".format(str(error)))
-
-from param.int_ import Int
-from param.raw import Raw
-from param.bool_ import Bool
-from param.enum import Enum
-from param.json import Json
-from param.color import Color
-from param.float_ import Float
-from param.img_url import Img_url
-from param.string import String
+"""imports for the param package"""
+from .param import Param
+from .int_ import Int
+from .raw import Raw
+from .bool_ import Bool
+from .enum import Enum
+from .json import Json
+from .color import Color
+from .float_ import Float
+from .img_url import Img_url
+from .string import String