forked from cillana/sikulix4python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsxbase.py
More file actions
54 lines (45 loc) · 1.56 KB
/
sxbase.py
File metadata and controls
54 lines (45 loc) · 1.56 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
from . sxgateway import *
SX = SXPKG.script.SX
SXRegion = SXPKG.script.Region
SXScreen = SXPKG.script.Screen
SXLocation = SXPKG.script.Location
SXImage = SXPKG.script.Image
SXImagePath = SXPKG.script.ImagePath
SXApp = SXPKG.script.App
class SXBase():
SXClass = SX
def __init__(self, *args):
success = True;
try:
self.instance = self.SXClass.getDefaultInstance4py()
if len(args) > 0:
self.instance = self.SXClass.make4py(convertArgs(args))
except:
success = False
if not success:
raise Exception("Class not prepared for SikuliX")
exit(1)
def __str__(self):
return self.instance.toString()
def __getattr__(self, item):
currentObject = self.instance;
def temp_method(*args, **kwargs):
mCall = item + "("
mCallError = "" + mCall
countArgs = len(args)
if countArgs > 0:
mCall += "args[0]"
mCallError += "%s" % (args[0])
for nArg in range(1, countArgs):
mCall += ", args[%d]" % nArg
mCallError += ", %s" % (args[nArg])
mCall += ")"
mCallError += ")"
try:
toEval = "currentObject." + mCall
result = eval(toEval, {"currentObject": self.instance, "args": args})
return result
except:
print("Method missing: %s::%s" % (currentObject, mCallError))
return currentObject
return temp_method