Example #1
0
 def pythonize(val):
     if isinstance(val, bool):
         return val
     val = unique_value(val).lower()
     if val in _boolean_states.keys():
         return _boolean_states[val]
     else:
         raise PythonizeError("Cannot convert '%s' to a boolean value" % val)
Example #2
0
 def pythonize(val):
     if isinstance(val, bool):
         return val
     val = unique_value(val).lower()
     if val in _boolean_states.keys():
         return _boolean_states[val]
     else:
         raise PythonizeError("Cannot convert '%s' to a boolean value" %
                              val)
Example #3
0
    def pythonize(self, val):
        """
            i.e: val = "192.168.10.24:445"
            NOTE: port is optional
        """
        val = unique_value(val)
        m = re.match("^([^:]*)(?::(\d+))?$", val)
        if m is None:
            raise ValueError

        addr = {'address': m.group(1)}
        if m.group(2) is not None:
            addr['port'] = int(m.group(2))

        return addr
Example #4
0
    def pythonize(self, val):
        """
            i.e: val = "192.168.10.24:445"
            NOTE: port is optional
        """
        val = unique_value(val)
        m = re.match("^([^:]*)(?::(\d+))?$", val)
        if m is None:
            raise ValueError

        addr = {'address': m.group(1)}
        if m.group(2) is not None:
            addr['port'] = int(m.group(2))

        return addr
Example #5
0
    def pythonize(self, val):
        val = unique_value(val)
        #import traceback; traceback.print_stack()
        def split(kv):
            m = re.match("^\s*([^\s]+)\s*=\s*([^\s]+)\s*$", kv)
            if m is None:
                raise ValueError

            return (
                m.group(1),
                # >2.4 only. we keep it for later. m.group(2) if self.elts_prop is None else self.elts_prop.pythonize(m.group(2))
                (self.elts_prop.pythonize(m.group(2)), m.group(2))[self.elts_prop is None]
            )

        if val is None:
            return(dict())

        # val is in the form "key1=addr:[port],key2=addr:[port],..."
        print ">>>", dict([split(kv) for kv in to_split(val)])
        return dict([split(kv) for kv in to_split(val)])
Example #6
0
    def pythonize(self, val):
        val = unique_value(val)
        #import traceback; traceback.print_stack()
        def split(kv):
            m = re.match("^\s*([^\s]+)\s*=\s*([^\s]+)\s*$", kv)
            if m is None:
                raise ValueError

            return (
                m.group(1),
                # >2.4 only. we keep it for later. m.group(2) if self.elts_prop is None else self.elts_prop.pythonize(m.group(2))
                (self.elts_prop.pythonize(m.group(2)), m.group(2))[self.elts_prop is None]
            )

        if val is None:
            return(dict())

        # val is in the form "key1=addr:[port],key2=addr:[port],..."
        print ">>>", dict([split(kv) for kv in to_split(val)])
        return dict([split(kv) for kv in to_split(val)])
Example #7
0
 def pythonize(self, val):
     val = unique_value(val)
     return logging.getLevelName(val)
Example #8
0
 def pythonize(self, val):
     val = unique_value(val)
     return val
Example #9
0
 def pythonize(self, val):
     val = unique_value(val)
     return to_float(val)
Example #10
0
 def pythonize(self, val):
     val = unique_value(val)
     return logging.getLevelName(val)
Example #11
0
 def pythonize(self, val):
     val = unique_value(val)
     return val
Example #12
0
 def pythonize(self, val):
     val = unique_value(val)
     return to_float(val)
Example #13
0
 def pythonize(self, val):
     val = unique_value(val)
     return logger.get_level_id(val)
Example #14
0
 def pythonize(self, val):
     val = unique_value(val)
     return _boolean_states[val.lower()]
Example #15
0
 def pythonize(val):
     val = unique_value(val)
     return _boolean_states[val.lower()]
Example #16
0
 def pythonize(self, val):
     val = unique_value(val)
     return logger.get_level_id(val)