File: bark.py

package info (click to toggle)
jython 2.7.2%2Brepack1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 62,676 kB
  • sloc: python: 640,908; java: 306,458; xml: 1,984; sh: 522; ansic: 126; makefile: 76
file content (34 lines) | stat: -rw-r--r-- 1,207 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from __future__ import print_function

import sys
from java.io import Serializable
from java.util.concurrent import Callable

from clamp import PackageProxy


class Dog(Callable, Serializable):
    # FIXME in a future branch, support the ability to call __init__
    # via __initProxy__ To support this functionality, the test
    # version of the clamp module in this directory needs to add a
    # Java constructor with an Object... arg list; possibly introspect
    # the arg list of __init__; or get some additional metadata from
    # the initialization of PackageProxy.
    __proxymaker__ = PackageProxy("org.python.test")
                
    def __init__(self):
        self.name = "Rover"
        self.number = 42
        
    def whoami(self):
        return self.name

    def call(self):
        # Using print forces use of PySystemState and shows it's initialized
        print("%s barks %s times" % (self.name, self.number))
        # Verify that site has been imported and therefore
        # site-packages and distutils/setuptools goodness is available
        return "site" in sys.modules

    def __eq__(self, other):
        return self.name == other.name and self.number == other.number