コード例 #1
0
ファイル: api.py プロジェクト: boorad/pydruid
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))
コード例 #2
0
ファイル: api.py プロジェクト: 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))
コード例 #3
0
ファイル: api.py プロジェクト: nivye/pydruid
 def g(self, *args, **kwargs):
     if self._results is None:
         raise exceptions.Error("Called before `execute`")
     return f(self, *args, **kwargs)
コード例 #4
0
ファイル: api.py プロジェクト: 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)