Ejemplo n.º 1
0
def get_type(value):
    """Infer type from value."""
    if isinstance(value, string_types):
        return Type.STRING
    elif isinstance(value, (int, float)):
        return Type.NUMBER
    elif isinstance(value, bool):
        return Type.BOOLEAN

    raise exceptions.Error(
        'Value of unknown type: {value}'.format(value=value))
Ejemplo n.º 2
0
Archivo: api.py Proyecto: nivye/pydruid
def get_type(value):
    """
    Infer type from value.

    Note that bool is a subclass of int so order of statements matter.
    """

    if isinstance(value, string_types) or value is None:
        return Type.STRING
    elif isinstance(value, bool):
        return Type.BOOLEAN
    elif isinstance(value, (int, float)):
        return Type.NUMBER

    raise exceptions.Error(
        "Value of unknown type: {value}".format(value=value))
Ejemplo n.º 3
0
Archivo: api.py Proyecto: nivye/pydruid
 def g(self, *args, **kwargs):
     if self._results is None:
         raise exceptions.Error("Called before `execute`")
     return f(self, *args, **kwargs)
Ejemplo n.º 4
0
Archivo: api.py Proyecto: nivye/pydruid
 def g(self, *args, **kwargs):
     if self.closed:
         raise exceptions.Error(
             "{klass} already closed".format(klass=self.__class__.__name__))
     return f(self, *args, **kwargs)