Browse Source

Added the DatahandlerOption class

Roland Haroutiounian 8 years ago
parent
commit
b3437848bb
1 changed files with 33 additions and 0 deletions
  1. 33
    0
      lodel/leapi/datahandlers/base_classes.py

+ 33
- 0
lodel/leapi/datahandlers/base_classes.py View File

@@ -488,3 +488,36 @@ class DatasConstructor(object):
488 488
         self._datas[fname] = value
489 489
         warnings.warn("Setting value of an DatasConstructor instance")
490 490
 
491
+
492
+## @brief Class designed to handle an option of a DataHandler
493
+class DatahandlerOption(object):
494
+
495
+    ## @brief instanciates a new Datahandler option object
496
+    #
497
+    # @param id str
498
+    # @param display_name MlString
499
+    # @param help_text MlString
500
+    # @param validator function
501
+    def __init__(self, id, display_name, help_text, validator):
502
+        self.__id = id
503
+        self.__display_name = display_name
504
+        self.__help_text = help_text
505
+        self.__validator = validator
506
+
507
+    @property
508
+    def id(self):
509
+        return self.__id
510
+
511
+    @property
512
+    def display_name(self):
513
+        return self.__display_name
514
+
515
+    @property
516
+    def help_text(self):
517
+        return self.__help_text
518
+
519
+    ## @brief checks a value corresponding to this option is valid
520
+    # @param value
521
+    # @return casted value
522
+    def check_value(self, value):
523
+        return self.__validator(value)

Loading…
Cancel
Save