Ejemplo n.º 1
0
 def __new__(cls, *args, **kwargs):
     try:
         exception = kwargs["exception"]
         error_cls = type(xstr(exception), (cls, ), {})
     except KeyError:
         error_cls = cls
     return Exception.__new__(error_cls, *args)
Ejemplo n.º 2
0
 def __new__(cls, *args, **kwargs):
     try:
         exception = kwargs["exception"]
         error_cls = type(xstr(exception), (cls,), {})
     except KeyError:
         error_cls = cls
     return Exception.__new__(error_cls, *args)
Ejemplo n.º 3
0
    def type(name):
        """ Return the :class:`.Relationship` subclass corresponding to a
        given name.

        :param name: relationship type name
        :returns: `type` object
        """
        for s in Relationship.__subclasses__():
            if s.__name__ == name:
                return s
        return type(xstr(name), (Relationship, ), {})
Ejemplo n.º 4
0
    def type(name):
        """ Return the :class:`.Relationship` subclass corresponding to a
        given name.

        :param name: relationship type name
        :returns: `type` object

        Example::

            >>> KNOWS = Relationship.type("KNOWS")
            >>> KNOWS(a, b)
            KNOWS(Node('Person', name='Alice'), Node('Person', name='Bob')

        """
        for s in Relationship.__subclasses__():
            if s.__name__ == name:
                return s
        return type(xstr(name), (Relationship, ), {})
Ejemplo n.º 5
0
 def parse(cls, s, default_host=None, default_port=None):
     s = xstr(s)
     if s.startswith("["):
         # IPv6
         host, _, port = s[1:].rpartition("]")
         port = port.lstrip(":")
         try:
             port = int(port)
         except (TypeError, ValueError):
             pass
         return cls((host or default_host or "localhost", port
                     or default_port or 0, 0, 0))
     else:
         # IPv4
         host, _, port = s.partition(":")
         try:
             port = int(port)
         except (TypeError, ValueError):
             pass
         return cls((host or default_host or "localhost", port
                     or default_port or 0))
Ejemplo n.º 6
0
 def parse(cls, s, default_host=None, default_port=None):
     s = xstr(s)
     if not isinstance(s, str):
         raise TypeError("Address.parse requires a string argument")
     if s.startswith("["):
         # IPv6
         host, _, port = s[1:].rpartition("]")
         port = port.lstrip(":")
         try:
             port = int(port)
         except (TypeError, ValueError):
             pass
         return cls((host or default_host or "localhost", port
                     or default_port or 0, 0, 0))
     else:
         # IPv4
         host, _, port = s.partition(":")
         try:
             port = int(port)
         except (TypeError, ValueError):
             pass
         return cls((host or default_host or "localhost", port
                     or default_port or 0))
Ejemplo n.º 7
0
 def __str__(self):
     return xstr(cypher_repr(self))
Ejemplo n.º 8
0
 def __str__(self):
     return xstr(self.__unicode__())
Ejemplo n.º 9
0
 def __str__(self):
     return xstr(self.__unicode__())