-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathobjects.py
More file actions
77 lines (51 loc) · 1.49 KB
/
Copy pathobjects.py
File metadata and controls
77 lines (51 loc) · 1.49 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from helpers import str
import sys
class Array(list):
def __getattr__(self,key):
if key == 'length':
return len(self)
raise Exception('key not found') #TODO raise right exception, read docs ...
class Class(object):
def __init__(self,typ):
self.typ = typ
def getName(self):
return self.typ.__name__
def getInterfaces(self):
try:
return self.typ._interfaces
except:
return []
class Object(object):
__interfaces = []
def getClass(self):
return Class(self.__class__)
String = "".__class__
System = Object()
System.out = Object()
def println(*args):
print "".join([ str(i) for i in args])
def print_(o):
sys.stdout.write(str(o))
sys.stdout.flush()
System.out.println = println
System.out.print_ = print_
class Interface(object):
@classmethod
def getName(self):
return self.__name__
class Number(object):
pass
class Integer(int,Number):
pass
class Iterator(object):
def __init__(self,collection):
self.pos = 0
self.collection = collection
def hasNext(self):
return self.pos < len(self.collection)
def next(self):
self.pos += 1
return self.collection[self.pos-1]
def remove(self):
self.collection.pop(self.pos-1)
self.pos -= 1