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)
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
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)])
def pythonize(self, val): val = unique_value(val) return logging.getLevelName(val)
def pythonize(self, val): val = unique_value(val) return val
def pythonize(self, val): val = unique_value(val) return to_float(val)
def pythonize(self, val): val = unique_value(val) return logger.get_level_id(val)
def pythonize(self, val): val = unique_value(val) return _boolean_states[val.lower()]
def pythonize(val): val = unique_value(val) return _boolean_states[val.lower()]