Esempio n. 1
0
 def __repr__(self):
     result = "{}(".format(self.__class__.__name__)
     for k, v in iteritems(self.__data):
         result += "{}={}, ".format(k, v)
     result = result.rstrip(", ")
     result += ")"
     return result
Esempio n. 2
0
    def transform_params_to_database(self, params):
        """
        Takes a dictionary of parameters and recursively translates them into parameters appropriate for sending over
        Rexpro.

        :param params: The parameters to be sent to the function
        :type params: dict
        :rtype: dict

        """
        from mogwai.models.element import BaseElement
        from mogwai.models import Edge, Vertex
        from mogwai.properties import DateTime, Decimal, UUID

        if isinstance(params, dict):
            return {k: self.transform_params_to_database(v) for k, v in iteritems(params)}
        if isinstance(params, array_types):
            return [self.transform_params_to_database(x) for x in params]
        if isinstance(params, BaseElement):
            return params._id
        if inspect.isclass(params) and issubclass(params, Edge):
            return params.label
        if inspect.isclass(params) and issubclass(params, Vertex):
            return params.element_type
        if isinstance(params, datetime):
            return DateTime().to_database(params)
        if isinstance(params, _UUID):
            return UUID().to_database(params)
        if isinstance(params, _Decimal):
            return Decimal().to_database(params)
        return params
Esempio n. 3
0
 def __repr__(self):
     result = "{}(".format(self.__class__.__name__)
     for k, v in iteritems(self.__data):
         result += "{}={}, ".format(k, v)
     result = result.rstrip(", ")
     result += ")"
     return result