예제 #1
0
 def __eq__(self, other):
     if other == None:
         return False
     elif (hasattr2(other, '_get_object_id')):
         return self.equals(other)
     else:
         return other.__eq__(self)
예제 #2
0
파일: java_gateway.py 프로젝트: gdw2/py4j
 def __eq__(self, other):
     if other == None:
         return False
     elif (hasattr2(other, '_get_object_id')):
         return self.equals(other)
     else:
         return other.__eq__(self)
예제 #3
0
파일: java_gateway.py 프로젝트: gdw2/py4j
    def help(self, var, pattern=None, short_name=True, display=True):
        """Displays a help page about a class or an object.

        :param var: JavaObject or JavaClass for which a help page will be
         generated.

        :param pattern: Star-pattern used to filter the members. For example
         'get*Foo' may return getMyFoo, getFoo, getFooBar, but not bargetFoo.

        :param short_name: If True, only the simple name of the parameter
         types and return types will be displayed. If False, the fully
         qualified name of the types will be displayed.

        :param display: If True, the help page is displayed in an interactive
         page similar to the `help` command in Python. If False, the page is
         returned as a string.
        """
        if hasattr2(var, '_get_object_id'):
            command = HELP_COMMAND_NAME +\
                      HELP_OBJECT_SUBCOMMAND_NAME +\
                      var._get_object_id() + '\n' +\
                      get_command_part(pattern) +\
                      get_command_part(short_name) +\
                      END_COMMAND_PART
            answer = self._gateway_client.send_command(command)
        elif hasattr2(var, '_fqn'):
            command = HELP_COMMAND_NAME +\
                      HELP_CLASS_SUBCOMMAND_NAME +\
                      var._fqn + '\n' +\
                      get_command_part(pattern) +\
                      get_command_part(short_name) +\
                      END_COMMAND_PART
            answer = self._gateway_client.send_command(command)
        else:
            raise Py4JError('var is neither a Java Object nor a Java Class')

        help_page = get_return_value(answer, self._gateway_client, None, None)
        if (display):
            ttypager(help_page)
        else:
            return help_page
예제 #4
0
    def help(self, var, pattern=None, short_name=True, display=True):
        """Displays a help page about a class or an object.

        :param var: JavaObject or JavaClass for which a help page will be
         generated.

        :param pattern: Star-pattern used to filter the members. For example
         'get*Foo' may return getMyFoo, getFoo, getFooBar, but not bargetFoo.

        :param short_name: If True, only the simple name of the parameter
         types and return types will be displayed. If False, the fully
         qualified name of the types will be displayed.

        :param display: If True, the help page is displayed in an interactive
         page similar to the `help` command in Python. If False, the page is
         returned as a string.
        """
        if hasattr2(var, '_get_object_id'):
            command = HELP_COMMAND_NAME +\
                      HELP_OBJECT_SUBCOMMAND_NAME +\
                      var._get_object_id() + '\n' +\
                      get_command_part(pattern) +\
                      get_command_part(short_name) +\
                      END_COMMAND_PART
            answer = self._gateway_client.send_command(command)
        elif hasattr2(var, '_fqn'):
            command = HELP_COMMAND_NAME +\
                      HELP_CLASS_SUBCOMMAND_NAME +\
                      var._fqn + '\n' +\
                      get_command_part(pattern) +\
                      get_command_part(short_name) +\
                      END_COMMAND_PART
            answer = self._gateway_client.send_command(command)
        else:
            raise Py4JError('var is neither a Java Object nor a Java Class')

        help_page = get_return_value(answer, self._gateway_client, None, None)
        if (display):
            ttypager(help_page)
        else:
            return help_page
예제 #5
0
 def can_convert(self, object):
     return hasattr2(object, "keys") and hasattr2(object, "__getitem__")
예제 #6
0
 def can_convert(self, object):
     # Check for iterator protocol and should not be an instance of byte
     # array (taken care of by protocol)
     return hasattr2(object, "__iter__") and not isbytearray(object) and\
         not ispython3bytestr(object) and not isinstance(object, basestring)
예제 #7
0
 def can_convert(self, object):
     return hasattr2(object, "keys") and hasattr2(object, "__getitem__")
예제 #8
0
 def can_convert(self, object):
     # Check for iterator protocol and should not be an instance of byte
     # array (taken care of by protocol)
     return hasattr2(object, "__iter__") and not isbytearray(object) and\
         not ispython3bytestr(object) and not isinstance(object, basestring)
예제 #9
0
 def can_convert(self, object):
     return hasattr2(object, 'keys') and hasattr2(object, '__getitem__')
예제 #10
0
 def can_convert(self, object):
     return hasattr2(object, '__iter__')
예제 #11
0
 def can_convert(self, object):
     return hasattr2(object, 'keys') and hasattr2(object, '__getitem__')
예제 #12
0
 def can_convert(self, object):
     return hasattr2(object, '__iter__')